rasdaman complete source
database.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 #ifndef _D_DATABASE_
34 #define _D_DATABASE_
35 
36 #include "raslib/rminit.hh"
37 #include "raslib/error.hh"
38 #include "rasodmg/object.hh"
39 #include "raslib/mddtypes.hh"
40 
41 // forward declarations
42 class r_Object;
43 class r_Transaction;
44 class ClientComm;
45 class r_Ref_Any;
46 
47 //@ManMemo: Module: {\bf rasodmg}
48 
49 /*@Doc:
50 
51  A database object must be instantiated and opened before
52  starting any transaction which uses the database, and closed
53  after ending these transactions.
54 
55 */
56 
61 {
62 public:
65 
68  {
69  CELL = 3,
70  MARRAY = 2,
72  };
73 
75  r_Database();
76 
78  r_Database( const char* name ) throw(r_Error);
85  ~r_Database();
87 
89  void open( const char* database_name, access_status status = read_write )
90  throw( r_Error );
107  void close();
109 
111  void create( const char* name ) throw( r_Error );
120  void destroy( const char* name ) throw( r_Error );
130  void set_servername( const char* name, int port = RASMGRPORT) throw(r_Error);
137  void set_useridentification( const char* name, const char *plain_pass ) throw(r_Error);
145  inline access_status get_status() const;
147 
149  void set_object_name( r_Object& obj, const char* name ) throw(r_Error);
159  r_Ref_Any lookup_object( const char* name ) const
161  throw( r_Error );
176  r_Ref_Any lookup_object( const r_OId& oid ) const
178  throw( r_Error );
193  r_Type* get_type_schema(const char* typeName, type_schema typetype) throw (r_Error);
210  void set_transfer_format( r_Data_Format format, const char *formatParams=NULL ) throw( r_Error );
225  void set_storage_format( r_Data_Format format, const char *formatParams=NULL) throw( r_Error );
232  static r_Database* actual_database;
234 
235 
236  //@Man: Methods for internal use only:
238  const r_OId get_new_oid( unsigned short objType ) const throw(r_Error);
241 
242 
243 
244  // creates an empty MDD collection on the server
245  void insertColl( const char* collName, const char* typeName, const r_OId& oid ) throw( r_Error );
246 
248  void removeObjFromColl( const char* name, const r_OId& oid ) throw ( r_Error );
249 
250  ClientComm* getComm();
251 private:
253  ClientComm* communication;
254 
256  access_status db_status;
257 
259  char* rasmgrName;
260 
262  int rasmgrPort;
263 
265  char* userName;
266 
268  char* plainPass;
269 };
270 
271 #include "rasodmg/database.icc"
272 #include "rasodmg/ref.hh"
273 
274 #endif
access_status get_status() const
get the actual status
type_schema
possible types define by symbolic names
Definition: database.hh:67
r_Type * get_type_schema(const char *typeName, type_schema typetype)
void set_useridentification(const char *name, const char *plain_pass)
set the user name and password
void open(const char *database_name, access_status status=read_write)
open a database
static r_Database * actual_database
stores a pointer to the actually opened database
Definition: database.hh:233
Definition: error.hh:88
Definition: raslib/type.hh:56
void removeObjFromColl(const char *name, const r_OId &oid)
removes an object from a collection
void set_storage_format(r_Data_Format format, const char *formatParams=NULL)
set the storage format for newly created MDD for this client
void close()
close a database
void insertColl(const char *collName, const char *typeName, const r_OId &oid)
Definition: database.hh:60
Definition: clientcomm.hh:67
Definition: database.hh:64
r_Ref_Any lookup_object(const char *name) const
lookup named objects in a database (must be called within open database and running transaction) ...
Definition: object.hh:64
r_Data_Format
Definition: mddtypes.hh:133
ClientComm * getComm()
~r_Database()
destructor
Definition: database.hh:71
Definition: database.hh:64
Definition: ref.hh:65
Definition: database.hh:64
Definition: database.hh:69
r_Database()
default constructor
void create(const char *name)
create a database with fixed schema RasDaSchema
Definition: database.hh:70
void destroy(const char *name)
destroy a database
Definition: database.hh:64
const int RASMGRPORT
Definition: rminit.hh:59
void set_object_name(r_Object &obj, const char *name)
give a name to an object (signature is not ODMG conformant because of compiler bug) ...
Definition: oid.hh:47
void set_servername(const char *name, int port=RASMGRPORT)
set the server name
void set_transfer_format(r_Data_Format format, const char *formatParams=NULL)
set the transfer compression format, both for data sent from the server to the client and the other w...
access_status
possible database states
Definition: database.hh:64
const r_OId get_new_oid(unsigned short objType) const