00001 /* 00002 * The information in this file is 00003 * Copyright(c) 2007 Ball Aerospace & Technologies Corporation 00004 * and is subject to the terms and conditions of the 00005 * GNU Lesser General Public License Version 2.1 00006 * The license text is available from 00007 * http://www.gnu.org/licenses/lgpl.html 00008 */ 00009 00010 00011 #ifndef SESSIONRESOURCE_H__ 00012 #define SESSIONRESOURCE_H__ 00013 00014 #include "SessionManager.h" 00015 00016 /** 00017 * Prevent saving of the session for a time. 00018 * 00019 * This prevents saving of the session (auto-save and user initiated save) while the SessionSaveLock exists. 00020 * This is used to temporarily stop the session from saving when it would be unwise to 00021 * save the session. Reference counting is used for locks. If two locks are in place, destruction of the first 00022 * SessionSaveLock will not unlock session saving, but will decrement the lock count. 00023 * 00024 * This is typically created at the beginning of a long, processor or 00025 * memory intensive procedure. Care should be used when locking session save as it overrides 00026 * the user's auto-save preference. An example of use follows. 00027 * @code 00028 * void processData() 00029 * { 00030 * SessionSaveLock saveLock; 00031 * // run the algorithm here 00032 * } 00033 * @endcode 00034 */ 00035 class SessionSaveLock 00036 { 00037 public: 00038 /** 00039 * Lock session saves. 00040 */ 00041 SessionSaveLock() 00042 { 00043 Service<SessionManager>()->lockSessionSave(); 00044 } 00045 00046 /** 00047 * Unlock session saves. 00048 */ 00049 ~SessionSaveLock() 00050 { 00051 Service<SessionManager>()->unlockSessionSave(); 00052 } 00053 }; 00054 00055 #endif