Main Page   Class Hierarchy   Compound List   File List   Compound Members  

TDBConnection.hh

00001 #ifndef _T_DB_CONNECTION_HH
00002 #define _T_DB_CONNECTION_HH
00003 
00004 #include <libpq-fe.h>
00005 #include "TString.hh"
00006 #include "TDBResult.hh"
00007 
00008 
00016 class TDBConnection
00017 {
00018 public:
00019   
00025   inline bool IsValid () { return myConn; }
00026   
00032   inline TString& ErrorMessage () { return myErrorMessage; }
00033   
00040   TDBResult* Execute (const TString& command);
00041   
00042   
00043 private:
00044   
00045   /* Only the connection manager can create connections. */
00046   friend class TDBConnectionManager;
00047 
00048   /* FIXME: No copying for now! */
00049   TDBConnection (const TDBConnection&);
00050   TDBConnection& operator=(const TDBConnection&);
00051   
00052   TDBConnection ();
00053   
00054   ~TDBConnection () { Close (); }
00055   
00060   void Open (const TString &username,
00061              const TString &password,
00062              const TString &database,
00063              const TString &host,
00064              const TString &port);
00065   
00069   void Close ();
00070   
00071   
00072   /* PostgreSQL connection */
00073   PGconn* myConn;
00074   
00075   /* Contains error message */
00076   TString myErrorMessage;
00077 };
00078 
00079 #endif // _T_DB_CONNECTION_HH

Generated on Sat Feb 15 18:37:16 2003 for Tools by doxygen1.3-rc2