1 /**
  2  * The Render Engine
  3  * AbstractStorage
  4  *
  5  * @fileoverview The base object from which all storage objects are derived.
  6  *
  7  * @author: Brett Fattori (brettf@renderengine.com)
  8  * @author: $Author: bfattori@gmail.com $
  9  * @version: $Revision: 1557 $
 10  *
 11  * Copyright (c) 2011 Brett Fattori (brettf@renderengine.com)
 12  *
 13  * Permission is hereby granted, free of charge, to any person obtaining a copy
 14  * of this software and associated documentation files (the "Software"), to deal
 15  * in the Software without restriction, including without limitation the rights
 16  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 17  * copies of the Software, and to permit persons to whom the Software is
 18  * furnished to do so, subject to the following conditions:
 19  *
 20  * The above copyright notice and this permission notice shall be included in
 21  * all copies or substantial portions of the Software.
 22  *
 23  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 24  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 25  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 26  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 27  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 28  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 29  * THE SOFTWARE.
 30  *
 31  */
 32 
 33 // The class this file defines and its required classes
 34 R.Engine.define({
 35     "class":"R.storage.AbstractStorage",
 36     "requires":[
 37         "R.engine.PooledObject"
 38     ]
 39 });
 40 
 41 /**
 42  * @class <tt>R.storage.AbstractStorage</tt> is the base class of all storage objects.
 43  *
 44  * @param name {String} The name of the object
 45  * @extends R.engine.PooledObject
 46  * @constructor
 47  * @description This base class is considered abstract and should not be
 48  *              instantiated directly.  See {@link R.storage.TransientStorage},
 49  *              {@link R.storage.PersistentStorage}, or {@link R.storage.IndexedStorage} for
 50  *              implementations.
 51  */
 52 R.storage.AbstractStorage = function () {
 53     return R.engine.PooledObject.extend(/** @scope R.storage.AbstractStorage.prototype */{
 54 
 55         storageObject:null,
 56 
 57         /** @private */
 58         constructor:function (name) {
 59             this.base(name || "AbstractStorage");
 60             this.storageObject = this.initStorageObject();
 61         },
 62 
 63         /**
 64          * Destroy the object, cleaning up any events that have been
 65          * attached to this object.
 66          */
 67         destroy:function () {
 68             this.storageObject.flush();
 69             this.base();
 70         },
 71 
 72         /**
 73          * Release the object back into the object pool.
 74          */
 75         release:function () {
 76             this.base();
 77             this.storageObject = null;
 78         },
 79 
 80         /**
 81          * [ABSTRACT] Initialize the storage object which holds the data
 82          * @return {Object} The storage object
 83          */
 84         initStorageObject:function () {
 85             return null;
 86         },
 87 
 88         /**
 89          * Get the storage object
 90          * @return {Object} The DOM object being used to store data
 91          */
 92         getStorageObject:function () {
 93             return this.storageObject;
 94         },
 95 
 96         /**
 97          * Set the storage object
 98          *
 99          * @param storageObject {Object} The DOM object to use to store data
100          */
101         setStorageObject:function (storageObject) {
102             this.storageObject = storageObject;
103         },
104 
105         /**
106          * [ABSTRACT] Finalize any pending storage requests.
107          */
108         flush:function () {
109         },
110 
111         /**
112          * [ABSTRACT] Save the data to the storage object
113          */
114         saveData:function (data) {
115         },
116 
117         /**
118          * [ABSTRACT] Load data from the storage object.
119          */
120         loadData:function () {
121             return null;
122         }
123 
124     }, /** @scope R.storage.AbstractStorage.prototype */ {
125 
126         /**
127          * Get the class name of this object
128          *
129          * @return {String} "R.storage.AbstractStorage"
130          */
131         getClassName:function () {
132             return "R.storage.AbstractStorage";
133         }
134 
135     });
136 
137 };