QDb Class Reference

Inheritance diagram for QDb:

QApolloDbBase

List of all members.


Detailed Description

base class for db interface

Public Types

typedef std::vector< QVdt > column
typedef std::map< std::string,
column > 
QDbTable

Public Member Functions

double DoQueryDouble (const std::string &Query)
 make query and expect a single double as output
int DoQueryInt (const std::string &Query)
 make query and expect a single int as output
bool DoQueryBool (const std::string &Query)
 make query and expect a single bool as output
std::string DoQueryString (const std::string &Query)
 make query and expect a single string as output
std::vector< double > & DoQueryVectorDouble (const std::string &Query)
 make query and expect a vector of double as output
const QDbTable DoQuery (const std::string &Query, int MaxLines=1000)
 make query and expect a table as output
bool DoSQLNoReturn (const std::string &query)
 make query and expect no output
int DoExec (const std::string &Query)
 Execute an INSERT, UPDATE, DELETE, FETCH, or MOVE statement.

Protected Member Functions

 QDb (const std::string &ip, const std::string &port, const std::string &usr, const std::string &pwd, const std::string &db)
 protected constructor called by child classes
bool Connect ()
 open connection to db
bool DisConnect ()
 close connection to db
bool isConnected () const
 check connection status
const QDbTable DoQuery (const std::string &Table, const std::string &Where, const std::string &Fields, const std::string &Order, int MaxLines)
 Perform a SELECT query with simplified syntax.
const char * DataBase () const

Private Member Functions

const char * Server () const
const char * Port () const
const char * User () const
const char * Passwd () const

Private Attributes

PGconn * fConnection
bool fConnected
std::string fServerIpAddress
std::string fServerIpPort
std::string fUserName
std::string fPasswd
std::string fDataBase

Constructor & Destructor Documentation

QDb::QDb ( const std::string &  ip,
const std::string &  port,
const std::string &  usr,
const std::string &  pwd,
const std::string &  db 
) [protected]

protected constructor called by child classes

Parameters:
ip network address or name of the db host
port port the db is listening to
usr username for db authentication
pwd password for db authentication
db db name


Member Function Documentation

const QDb::QDbTable QDb::DoQuery ( const std::string &  Query,
int  MaxLines = 1000 
)

make query and expect a table as output

Parameters:
MaxLines determine max number of lines to be returned by the query.
  • If Maxlines is zero all ntuples are returned.
  • If Maxlines is positive at most MaxLines are returned.
  • An exception is thrown if MaxLines is negative and the performed query returned more than (-MaxLines) ntuples.

References Connect(), and QError::SetDescription().

Referenced by DoQuery(), QApolloDbBase::GetLastRun(), QApolloDbBase::GetListOfChannels(), QApolloDbBase::GetListOfUsers(), QApolloDbBase::GetRuns(), QApolloDbBase::GetRunTypes(), QApolloDbBase::GetSettingsBasketIds(), QApolloDbBase::GetSettingsBaskets(), QApolloDbBase::Init(), QApolloDbBase::InsertNewRun(), QApolloDbBase::InsertStartComments(), QApolloDbBase::LoadDefaultTriggerSettings(), QApolloDbBase::LoadHardwareProfile(), QApolloDbBase::LoadHwSettings(), and QApolloDbBase::LoadTriggerSettings().

int QDb::DoExec ( const std::string &  Query  ) 

Execute an INSERT, UPDATE, DELETE, FETCH, or MOVE statement.

Returns:
Number of rows affected

References Connect(), and QError::SetDescription().

Referenced by QApolloDbBase::UndoInsertRun().

bool QDb::isConnected (  )  const [inline, protected]

check connection status

Returns:
true if connected, false otherwise

Referenced by Connect(), and QApolloDbBase::Init().


The documentation for this class was generated from the following files:

Generated on Tue Nov 16 10:50:05 2010 for CUORE Software by  doxygen 1.5.6
INFN Genova privacy policy