00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef HCOREDATABASEPGSQL_HH_
00021 #define HCOREDATABASEPGSQL_HH_
00022
00023
00024 #include "cpsp/HCoreDatabase.hh"
00025 #include <string>
00026
00027 namespace cpsp
00028 {
00035 class HCoreDatabasePGSQL : public HCoreDatabase
00036 {
00037 private:
00038 static const std::string DEF_DBNAME, DEF_USERNAME, DEF_PASSWORD;
00039
00040 protected:
00041
00042 unsigned int coreSize;
00043 unsigned int minHH, maxHH;
00044
00045 bool connected;
00046 bool cursorOpen;
00047
00048 void closeCursor();
00049
00050 public:
00051 HCoreDatabasePGSQL();
00052 HCoreDatabasePGSQL( const std::string& hostName,
00053 const std::string& dbName = DEF_DBNAME,
00054 const std::string& user = DEF_USERNAME,
00055 const std::string& password = DEF_PASSWORD);
00056 virtual ~HCoreDatabasePGSQL();
00057
00060 virtual bool initCoreAccess( const biu::LatticeDescriptor& latDescr,
00061 const unsigned int size,
00062 const unsigned int minContacts=0,
00063 const unsigned int maxContacts=INT_MAX);
00064
00071 virtual bool getNextCore(HCore& toFill);
00072
00074 virtual unsigned int getActCoreSize() { return coreSize; }
00075
00078 virtual unsigned int getActMinHHcontacts() { return minHH; }
00079
00082 virtual void setActMinHHcontacts(const unsigned int minContacts) {
00083 minHH = minContacts;
00084 }
00085
00088 virtual unsigned int getActMaxHHcontacts() { return maxHH; }
00089
00092 bool connect(const std::string& dbAtServer,
00093 const std::string& dbName = DEF_DBNAME,
00094 const std::string& user = DEF_USERNAME,
00095 const std::string& password = DEF_PASSWORD);
00096
00099 bool isConnected() const { return connected; }
00100
00102 bool disconnect();
00103
00104 };
00105
00106 }
00107
00108 #endif