00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
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
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
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
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