rasdaman complete source
adminif.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 */
23 #ifndef _ADMINIF_HH_
24 #define _ADMINIF_HH_
25 
26 /************************************************************************
27  *
28 = *
29  * PURPOSE:
30  *
31  *
32  * COMMENTS:
33  *
34  ***********************************************************************/
35 
36 class AdminIf;
37 class DatabaseIf;
38 
39 class r_Error;
40 
41 #include <iostream>
42 #include "lists.h"
43 
44 class AdminIf;
45 
46 //@ManMemo: Module: {\bf reladminif}.
47 
48 /*@Doc:
49 An AdminIf instance has to be obtained, before any work with the base
50 DBMS can be done. Only one instance can exist at any time. The class
51 follows the singleton design pattern (Gamma et. al. p. 127ff.).
52 
53 {\bf Functionality}
54 
55 At the moment, AdminIf is responsible for the state of a transaction.
56 persistent objects rely on this class to decide if they should write
57 changes back into the db. It also carries a list of compressed tiles.
58 Before a session is opened, no persistence capable classes can be used (e.g.
59 \Ref{BLOBTile})! Remember to also create a \Ref{DatabaseIf} instance
60 before using a persistence capable class.
61 
62 {\bf Example}
63 
64 {\tt AdminIf* myAdmin = AdminIf::instance();}
65 
66 ...
67 
68 {\tt delete myAdmin;}
69 
70 */
71 
72 const int SYSTEMNAME_MAXLEN=256;
81 class AdminIf
82 {
83 public:
84  static AdminIf* instance();
85  /*@Doc:
86  satic function used to access instance of AdminIf and start session.
87  */
88 
90  /*@Doc:
91  static function used to access the current databaseif object
92  */
93 
94  static void setCurrentDatabaseIf(DatabaseIf* db);
95  /*@Doc:
96  static function used to store the current databaseif object in AdminIf
97  this function should only be called by DatabaseIf, DatabasIf
98  is responsible for setting the databaseif object to
99  NULL at destruction time.
100  */
101 
102  ~AdminIf();
103  /*@Doc:
104  issues a ROLLBACK WORK RELEASE
105  deinitializes the ObjectBroker
106  deinitializes benchmark timers
107  */
108 
109  static char* getSystemName();
110  /*@Doc:
111  returns Oracle on oracle
112  */
113 
114  static void setReadOnlyTA(bool newReadOnlyTA);
115  /*@Doc:
116  sets readOnlyTA, should only be used by \Ref{TransactionIf}
117  */
118 
119  static bool isReadOnlyTA();
120  /*@Doc:
121  checks for read only TA.
122  */
123 
124  static bool isAborted();
125  /*@Doc:
126  used by DBObject::validate() to determine if it should execute the persistency functions
127  */
128 
129  static void setAborted(bool newAborted);
130  /*@Doc:
131  used by transactionif to set the aborted status of the transaction
132  */
133 
134 protected:
135  AdminIf() throw (r_Error);
136  /*@Doc:
137  constructor, can not be used from outside.
138  initializes the objectbroker
139  does a CONNECT, when successful sets validConnection to true else false,
140  then a ROLLBACK WORK RELEASE
141  throws exception if connection fails
142  */
143 
144 private:
145  static AdminIf* myInstance;
146  /*@Doc:
147  pointer to instance (just needed for Singleton pattern).
148  */
149 
150  static DatabaseIf* myDatabaseIf;
151  /*@Doc:
152  pointer to the current DatabaseIf object
153  */
154 
155  static bool validConnection;
156  /*@Doc:
157  flag for error when opening session: false if error.
158  */
159 
160  static bool readOnlyTA;
161  /*@Doc:
162  flag for read only transactions
163  */
164 
165  static const char dbmsName[SYSTEMNAME_MAXLEN];
166  /*@Doc:
167  holds the specific name of dbms
168  */
169 
170  static char systemName[SYSTEMNAME_MAXLEN+1];
171  /*@Doc:
172  Store the dbms name using dbmsName
173  */
174 
175  static bool _isAborted;
176  /*@Doc:
177  flag for aborted transactions
178  */
179 };
180 
181 #endif
Definition: databaseif.hh:66
Definition: adminif.hh:81
static char * getSystemName()
static DatabaseIf * getCurrentDatabaseIf()
static void setCurrentDatabaseIf(DatabaseIf *db)
static AdminIf * instance()
static void setAborted(bool newAborted)
const int SYSTEMNAME_MAXLEN
Definition: adminif.hh:72
static bool isReadOnlyTA()
static bool isAborted()
static void setReadOnlyTA(bool newReadOnlyTA)