rasdaman complete source
clientcomm.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 /
35 #ifndef _CLIENTCOMM_
36 #define _CLIENTCOMM_
37 
38 #include "raslib/rminit.hh"
39 #include "raslib/error.hh"
40 #include "rasodmg/oqlquery.hh"
41 #include "rasodmg/marray.hh"
42 
43 #include "raslib/primitivetype.hh"
44 
45 
46 template <class T> class r_Set;
47 class r_Ref_Any;
48 class r_Base_Type;
49 class r_Parse_Params;
50 
51 
59 // @Doc
60 
61 /* The class ClientComm represents {\bf one} connection between
62  {\bf one} client entity (e.g. an object of class \Ref{r_Database}) and
63  the server. Therefore, the host name has to be provided at
64  the constructor.
65 */
66 
67 class ClientComm
68 {
69 public:
70 
72  virtual ~ClientComm() throw();
73 
74  // the class is not necessary singleton, but the type of the actual object depends on the environment
75  static ClientComm* createObject(const char* rasmgrName, int rasmgrPort);
76 
91  static void useRNP() throw();
92  static void useRPC() throw();
93  static bool internalSettingIsRNP() throw();
94 
95  virtual bool effectivTypeIsRNP() throw() = 0;
96 
97  //@Man: Database methods
99  //RNP: all made pure
101 
103  virtual int openDB( const char* database ) = 0;
105  virtual int closeDB() = 0;
107  virtual int createDB( const char* name ) throw(r_Error) = 0;
109  virtual int destroyDB( const char* name ) throw(r_Error) = 0;
110 
112 
113 
114  //@Man: Transaction methods
116 
119  virtual int openTA( unsigned short readOnly = 0 ) throw(r_Error) =0;
121  virtual int commitTA() throw(r_Error) =0;
123  virtual int abortTA() =0;
124 
126 
127 
128  //@Man: MDD methods
130 
133  virtual void insertMDD( const char* collName, r_GMarray* mar ) throw( r_Error ) =0;
135  virtual r_Ref_Any getMDDByOId( const r_OId& oid ) throw( r_Error ) =0;
136 
138 
139 
140  //@Man: Collection methods
142 
145  virtual void insertColl( const char* collName, const char* typeName, const r_OId& oid ) throw( r_Error ) =0;
147  virtual void deleteCollByName( const char* collName ) throw( r_Error ) =0;
149  virtual void deleteObjByOId( const r_OId& oid ) throw( r_Error ) =0;
151  virtual void removeObjFromColl( const char* name, const r_OId& oid ) throw ( r_Error ) =0;
153  virtual r_Ref_Any getCollByName( const char* name ) throw( r_Error ) =0;
155  virtual r_Ref_Any getCollByOId ( const r_OId& oid ) throw( r_Error ) =0;
157  virtual r_Ref_Any getCollOIdsByName( const char* name ) throw( r_Error ) =0;
159  virtual r_Ref_Any getCollOIdsByOId ( const r_OId& oid ) throw( r_Error ) =0;
160 
162 
163 
164  //@Man: Query methods
166 
169  virtual void executeQuery( const r_OQL_Query& query, r_Set< r_Ref_Any >& result ) throw( r_Error ) =0;
170  /*@Doc:
171  Executes a retrieval query of type \Ref{r_OQL_Query} and returns the result. Every
172  MDD object of the MDD collection is fetched from the server and inserted
173  in the resulting \Ref{r_Set}.
174  */
175 
177  virtual void executeQuery( const r_OQL_Query& query ) throw( r_Error ) =0;
178  /*@Doc:
179  Executes an update query of type \Ref{r_OQL_Query}.
180  */
181 
183 
184 
185 
186  //@Man: System methods
188 
191  virtual r_OId getNewOId( unsigned short objType ) throw(r_Error) = 0;
192 
194  virtual unsigned short getObjectType( const r_OId& oid ) throw(r_Error) = 0;
195 
196  enum r_Type_Type
197  {
198  r_SetType_Type = 1,
199  r_MDDType_Type = 2
200  };
201 
204  virtual char* getTypeStructure( const char* typeName, r_Type_Type typeType ) throw(r_Error) =0;
205 
207 
208 
210  static int changeEndianness( r_GMarray* mdd, const r_Base_Type* bt=NULL );
212  static int changeEndianness( const r_GMarray* mdd, void *newData, const r_Base_Type* bt=NULL );
213 
215  virtual unsigned long getClientID() const = 0;
216 
217 
218  //@Man: Methods for asynchronious alive signal concept
220 
222  virtual void triggerAliveSignal() = 0;
229  virtual void sendAliveSignal() = 0;
237  virtual int setTransferFormat( r_Data_Format format, const char* formatParams=NULL ) =0;
239 
241  virtual int setStorageFormat( r_Data_Format format, const char *formatParams=NULL ) =0;
242 
244  virtual const char *getExtendedErrorInfo() throw(r_Error) =0;
245 
247  const char* getServerName();
248 
250  virtual void setUserIdentification(const char *userName, const char *plainTextPassword) =0;
251 
253  virtual void setMaxRetry(unsigned int newMaxRetry) = 0;
254 
256  virtual unsigned int getMaxRetry() = 0;
257 
259  virtual void setTimeoutInterval(int seconds) = 0;
260  virtual int getTimeoutInterval() = 0;
261 
263 
264 
265 protected:
267  ClientComm() throw( r_Error );
268 
269 private:
270 
271  static bool currentProtocolIsRNP;
272 };
273 
274 #endif