00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef _EYEDB_CONNECTION_H
00026 #define _EYEDB_CONNECTION_H
00027
00028 class ConnHandle;
00029
00030 namespace eyedb {
00031
00037 class ConnectionPeer;
00038 class ServerMessageDisplayer;
00039
00043 class Connection {
00044
00045
00046
00047
00048 public:
00052 Connection();
00053
00061 Connection(bool opening, const char *host = DefaultHost,
00062 const char *port = DefaultIDBPort);
00063
00070 Status open(const char *host = DefaultHost,
00071 const char *port = DefaultIDBPort);
00072
00077 Status close();
00078
00083 const char *getHost() const;
00084
00089 const char *getIDBPort() const;
00090
00095 int getServerUid() const;
00096
00101 int getServerPid() const;
00102
00107 Status sendInterrupt();
00108
00113 ConnHandle *getConnHandle() {return connh;}
00114
00118 ~Connection();
00119
00124 static void setDefaultHost(const char *host);
00125
00130 static const char *getDefaultHost();
00131
00136 static void setDefaultIDBPort(const char *port);
00137
00142 static const char *getDefaultIDBPort();
00143
00148 static void setAuthRequired(Bool set_auth_required);
00149
00154 static void setDefaultUser(const char *user);
00155
00160 static const char *getDefaultUser();
00161
00166 static void setDefaultPasswd(const char *passwd);
00167
00172 static const char *getDefaultPasswd();
00173
00178 static std::string makeUser(const char *_ser);
00179
00180 static const char
00181 LocalHost[],
00182 DefaultHost[],
00183 DefaultIDBPort[],
00184 DefaultIDBPortValue[];
00185
00191 void *setUserData(void *ud);
00192
00197 void *getUserData(void);
00198
00203 const void *getUserData(void) const;
00204
00210 Status echoServerMessages(const ServerMessageDisplayer &dsp) const;
00211
00212
00217 static Bool isBackendInterrupted();
00218
00223 static void setServerMessage(const char *msg);
00224
00231 static void setOutOfBandData(unsigned int type, unsigned char *data,
00232 unsigned int len);
00233
00234
00235
00236
00237 private:
00238 friend class ConnectionPeer;
00239
00240 char *host;
00241 char *port;
00242 int sv_pid, sv_uid;
00243 void *user_data;
00244 void *oql_info;
00245
00246 static char *default_host, *default_port, *default_user, *default_passwd;
00247
00248 static Bool set_auth_required;
00249
00250 ConnHandle *connh;
00251
00252 Status echoServerMessages(unsigned int mask, FILE *fd, std::ostream *os) const;
00253
00254
00255
00256
00257 public:
00258 static void init();
00259 static void _release();
00260 void *setOQLInfo(void *);
00261 void *getOQLInfo();
00262 struct ServerMessageContext;
00263 };
00264
00265 class ServerMessageDisplayer {
00266 public:
00267 virtual void display(const char *msg) const = 0;
00268 virtual ~ServerMessageDisplayer() {}
00269 };
00270
00271 class StdServerMessageDisplayer : public ServerMessageDisplayer {
00272
00273 public:
00274 StdServerMessageDisplayer(FILE *fd = stdout);
00275 StdServerMessageDisplayer(std::ostream &);
00276
00277 virtual void display(const char *msg) const;
00278
00279 virtual ~StdServerMessageDisplayer() {}
00280
00281 private:
00282 FILE *fd;
00283 std::ostream *os;
00284 };
00285
00290 }
00291
00292 #endif