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 
59 {
60 public:
63 
66 
68  r_Transaction();
69 
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 
116 
118  r_Ref_Any load_object( const r_OId& oid );
119 
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.
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
r_Transaction()
default constructor
r_TAStatus
possible states of the transaction
Definition: transaction.hh:62
Definition: transaction.hh:121
Definition: transaction.hh:58
Definition: transaction.hh:121
Definition: transaction.hh:121
Definition: collection.hh:40
Definition: transaction.hh:62
r_TAMode
possible transaction modes
Definition: transaction.hh:65
r_TAStatus get_status() const
returns the current state
void abort()
abort transaction and forget changes within transaction
Definition: error.hh:88
Definition: oqlquery.hh:45
static r_Transaction * actual_transaction
store a pointer to the actual transaction
Definition: transaction.hh:115
Definition: transaction.hh:62
r_TAMode get_mode() const
returns current mode
Definition: transaction.hh:121
Definition: transaction.hh:62
Definition: transaction.hh:121
Definition: oqlquery.hh:46
r_Ref_Any load_object(const r_OId &oid)
load an object (internal use only)
Definition: object.hh:64
Definition: transaction.hh:65
Definition: ref.hh:65
void begin(r_TAMode mode=read_write)
start the transaction
void commit()
commit transaction and make changes persistent
~r_Transaction()
destructor, an active transaction is aborted
Definition: transaction.hh:62
GenRefType
possible non-r_Object values maintained by the transaction
Definition: transaction.hh:121
Definition: transaction.hh:65
r_Iterator< r_Object * > r_Iterator_r_Object_dummy
Definition: transaction.hh:160
Definition: oid.hh:47
void add_object_list(GenRefType type, void *ref)
adds a non-r_Object to the list of persistent objects