00001 /* 00002 EyeDB Object Database Management System 00003 Copyright (C) 1994-2008 SYSRA 00004 00005 EyeDB is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Lesser General Public 00007 License as published by the Free Software Foundation; either 00008 version 2.1 of the License, or (at your option) any later version. 00009 00010 EyeDB is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Lesser General Public License for more details. 00014 00015 You should have received a copy of the GNU Lesser General Public 00016 License along with this library; if not, write to the Free Software 00017 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 00018 */ 00019 00020 /* 00021 Author: Eric Viara <viara@sysra.com> 00022 */ 00023 00024 00025 #ifndef _EYEDB_TRANSACTION_H 00026 #define _EYEDB_TRANSACTION_H 00027 00028 #include <eyedb/ObjCache.h> 00029 00030 namespace eyedb { 00031 00040 class Transaction { 00041 00042 // ---------------------------------------------------------------------- 00043 // Transaction Interface 00044 // ---------------------------------------------------------------------- 00045 public: 00050 unsigned int getTID() const {return tid;} 00051 00056 const TransactionParams& getParams() const {return params;} 00057 00062 Database *getDatabase() {return db;} 00063 00064 00070 Status setParams(const TransactionParams ¶ms); 00071 00078 static Status checkParams(const TransactionParams ¶ms, 00079 Bool strict = True); 00080 00081 // cache management 00086 Status cacheInvalidate(); 00087 00093 Status setCacheActive(Bool on_off); 00094 00100 void cacheObject(const Oid &oid, Object *o); 00101 00106 void uncacheObject(Object *o); 00107 00112 void uncacheObject(const Oid &_oid); 00113 00114 // ---------------------------------------------------------------------- 00115 // Transaction Private Part 00116 // ---------------------------------------------------------------------- 00117 private: 00118 friend class Database; 00119 Transaction(Database *, const TransactionParams &); 00120 00121 Status begin(); 00122 Status commit(); 00123 Status abort(); 00124 void cacheInit(); 00125 00126 ~Transaction(); 00127 00128 Database *db; 00129 unsigned int tid; 00130 TransactionParams params; 00131 ObjCache *cache; 00132 Bool cache_on; 00133 Bool incoherency; 00134 00135 void setIncoherency(); 00136 Object *getObject(const Oid &oid) { 00137 return (cache_on ? (Object *)cache->getObject(oid) : NULL); 00138 } 00139 00140 ObjectList *getObjects() { 00141 return (cache_on ? cache->getObjects() : NULL); 00142 } 00143 }; 00144 00149 } 00150 00151 #endif