1 /**
  2  * The Render Engine
  3  * TransientStorage
  4  *
  5  * @fileoverview A storage object where data only exists during the browser session.
  6  *
  7  * @author: Brett Fattori (brettf@renderengine.com)
  8  * @author: $Author: bfattori $
  9  * @version: $Revision: 1555 $
 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.TransientStorage",
 36     "requires":[
 37         "R.storage.BrowserStorage"
 38     ]
 39 });
 40 
 41 /**
 42  * @class <tt>R.storage.TransientStorage</tt> is used to hold data that is used only
 43  *     while the game is active.  Transient data is an alternative to using
 44  *     a lot of local variables or object structures to store the data.
 45  *     <p/>
 46  *     Data is stored and retrieved using a SQL-like syntax.  For information
 47  *     about the SQL syntax, see http://code.google.com/p/trimpath/wiki/TrimQuery
 48  *
 49  * @param name {String} The name of the object
 50  * @extends R.storage.BrowserStorage
 51  * @constructor
 52  * @description This class of storage is used to hold data during the current
 53  *     browser session only.
 54  */
 55 R.storage.TransientStorage = function () {
 56     return R.storage.BrowserStorage.extend(/** @scope R.storage.TransientStorage.prototype */{
 57 
 58         enabled:null,
 59 
 60         /** @private */
 61         constructor:function (name) {
 62             this.enabled = R.engine.Support.sysInfo().support.storage.session;
 63             AssertWarn(this.enabled, "TransientStorage is not supported by browser - DISABLED");
 64             this.base(name);
 65         },
 66 
 67         /**
 68          * Release the object back into the object pool.
 69          */
 70         release:function () {
 71             this.base();
 72             this.enabled = null;
 73         },
 74 
 75         /**
 76          * Initialize the storage object to the localStorage browser object
 77          * @return {Object} The <tt>sessionStorage</tt> object
 78          */
 79         initStorageObject:function () {
 80             return window.sessionStorage;
 81         },
 82 
 83         /**
 84          * A unique identifier for the table name.
 85          * @param name {String} The table name
 86          * @return {String} A unique identifier
 87          */
 88         getTableUID:function (name) {
 89             return this.base(name) + "TS";
 90         }
 91 
 92     }, /** @scope R.storage.TransientStorage.prototype */ {
 93 
 94         /**
 95          * Get the class name of this object
 96          *
 97          * @return {String} "R.storage.TransientStorage"
 98          */
 99         getClassName:function () {
100             return "R.storage.TransientStorage";
101         }
102 
103     });
104 
105 };
106