dbinfo.h
Go to the documentation of this file.00001 #ifndef DBINFO_HH
00002 #define DBINFO_HH
00003
00004
00005 #include <iostream>
00006 #include <fstream>
00007 #include <string>
00008 #include <map>
00009
00010
00011 using namespace std;
00012
00013
00014 struct aceparam {
00015 string host;
00016 int port;
00017 string path;
00018 aceparam() :host(), port(0), path("") {}
00019
00020 aceparam(const aceparam& ap) { host=ap.host; port=ap.port; path=ap.path; }
00021 aceparam(const string &h, const int p, const string &pa) : host(h), port(p), path(pa) {}
00022 aceparam& operator=(const aceparam& ap);
00023 friend ostream& operator<<(ostream &ou, const aceparam& ap) {
00024 ou << ap.host << ", " << ap.port << ", " << ap.path;
00025 return ou;
00026 }
00027 };
00028
00029
00030 class dbinfo {
00031 public:
00032 dbinfo() { if(hostmap.empty()) init(); }
00037 string getAddress(const string &hn);
00038 bool mapEmpty() const { return hostmap.empty(); }
00039
00044 static void init();
00048 static map<string, string> hostmap;
00049 };
00050
00051 class acedbinfo : public dbinfo {
00052 private:
00053 map<string, aceparam> info;
00054 public:
00055 acedbinfo();
00056 int getPort(const string &dbn);
00057 string getHost(const string &dbn);
00058 string getPath(const string &dbn);
00059 pair<string, int> connectInfo(const string &dbn);
00060 friend ostream& operator<<(ostream &ou, const acedbinfo& ai);
00061 };
00062
00063 class pgdbinfo : public dbinfo {
00064 private:
00065 map<string, string> info;
00066 public:
00067
00068 pgdbinfo();
00069 string getHost(const string &dbn);
00070 string getHostAddress(const string &dbn) { return getAddress(getHost(dbn)); }
00071 };
00072
00073 class MysqlDBInfo {
00074 private:
00075 string user;
00076 string password;
00077 public:
00082 MysqlDBInfo();
00083 string getUser() { return user; }
00084 string getPassword() { return password; }
00085 };
00086
00087 #endif