rasdaman API
transaction.hh
Go to the documentation of this file.
1 /*
2 * This file is part of rasdaman community.
3 *
4 * Rasdaman community is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * Rasdaman community is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with rasdaman community. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann /
18 rasdaman GmbH.
19 *
20 * For more information please see <http://www.rasdaman.org>
21 * or contact Peter Baumann via <baumann@rasdaman.com>.
22 /
33 //@ManMemo: Module: {\bf rasodmg}
34 
35 #ifndef _D_TRANSACTION_
36 #define _D_TRANSACTION_
37 
38 #include "raslib/error.hh"
39 #include "raslib/oid.hh"
40 
41 class r_Object;
42 
43 #include "rasodmg/set.hh"
44 #include "rasodmg/ref.hh"
45 
46 /*@Doc:
47 
48  Transactions can be started, committed, aborted, and checkpointed.
49  It is important to note that all access, creation, modification,
50  and deletion of persistent objects must be done within a transaction.
51  Right now, only one transaction can be active at a time.
52 
53 */
54 
58 class r_Transaction
59 {
60 public:
62  enum r_TAStatus { active, inactive, comiting, aborting };
63 
65  enum r_TAMode { read_write, read_only };
66 
68  r_Transaction();
69 
71  ~r_Transaction();
72 
74  void begin( r_TAMode mode = read_write ) throw( r_Error );
86  void commit() throw( r_Error );
101  void abort();
103 
105  inline r_TAStatus get_status() const;
106 
108  inline r_TAMode get_mode() const;
109 
110  //@Man: Methods and types for internal use only:
112 
115  static r_Transaction* actual_transaction;
116 
118  r_Ref_Any load_object( const r_OId& oid );
119 
121  enum GenRefType { MINTERVAL, SINTERVAL, POINT, OID, SCALAR };
122 
124  void add_object_list( GenRefType type, void* ref );
125 
127 
128 
129 private:
131  void add_object_list( const r_Ref<r_Object>& );
132 
134  r_TAStatus ta_state;
135 
137  r_TAMode ta_mode;
138 
140  r_Set< r_Ref<r_Object> > object_list;
141 
142  // element type of non \Ref{r_Object} list maintained by the transaction
143  typedef struct
144  {
145  GenRefType type;
146  void* ref;
147  } GenRefElement;
148 
150  r_Set< GenRefElement* > non_object_list;
151 
152  friend class r_Object;
153 };
154 
155 #define DEF_TRANSACTION
156 
157 #include "rasodmg/iterator.hh"
158 // For HP cfront compiler each template instantiation used in a library
159 // must be defined in an included header.
160 typedef r_Iterator<r_Object*> r_Iterator_r_Object_dummy;
161 #include "rasodmg/transaction.icc"
162 
163 #ifdef EARLY_TEMPLATE
164 #ifdef __EXECUTABLE__
165 #ifdef __VISUALC__
166 #include "rasodmg/ref.cpp"
167 #else
168 #include "rasodmg/ref.cc"
169 #endif
170 #endif
171 #endif
172 
173 
174 #endif