CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Protected Member Functions | Protected Attributes | Friends
LocationDef Class Reference

#include <LocationDef.h>

Inheritance diagram for LocationDef:
IDef IUniqueDBObject IDBObject

Public Member Functions

int fetchID () throw (std::runtime_error)
 
std::string getLocation () const
 
 LocationDef ()
 
bool operator!= (const LocationDef &l) const
 
bool operator== (const LocationDef &l) const
 
void setByID (int id) throw (std::runtime_error)
 
void setLocation (std::string loc)
 
virtual ~LocationDef ()
 
- Public Member Functions inherited from IDBObject
oracle::occi::Connection * getConn () const
 
oracle::occi::Environment * getEnv () const
 
void setConnection (oracle::occi::Environment *env, oracle::occi::Connection *conn)
 
virtual ~IDBObject ()
 

Protected Member Functions

void fetchAllDefs (std::vector< LocationDef > *fillVec) throw (std::runtime_error)
 
- Protected Member Functions inherited from IDBObject
void checkConnection () const throw (std::runtime_error)
 

Protected Attributes

std::string m_loc
 
- Protected Attributes inherited from IUniqueDBObject
int m_ID
 
- Protected Attributes inherited from IDBObject
oracle::occi::Connection * m_conn
 
oracle::occi::Environment * m_env
 

Friends

class EcalCondDBInterface
 

Additional Inherited Members

- Static Public Attributes inherited from IDBObject
static int const ECALDB_NROWS =1024
 

Detailed Description

Def for Location information

Definition at line 12 of file LocationDef.h.

Constructor & Destructor Documentation

LocationDef::LocationDef ( )

Definition at line 10 of file LocationDef.cc.

References NULL.

11 {
12  m_env = NULL;
13  m_conn = NULL;
14  m_ID = 0;
15  m_loc = "";
16 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
#define NULL
Definition: scimark2.h:8
std::string m_loc
Definition: LocationDef.h:32
LocationDef::~LocationDef ( )
virtual

Definition at line 20 of file LocationDef.cc.

21 {
22 }

Member Function Documentation

void LocationDef::fetchAllDefs ( std::vector< LocationDef > *  fillVec)
throw (std::runtime_error
)
protected

Definition at line 103 of file LocationDef.cc.

References alignCSCRings::e, setByID(), and IDBObject::setConnection().

105 {
106  this->checkConnection();
107  try {
108  Statement* stmt = m_conn->createStatement();
109  stmt->setSQL("SELECT def_id FROM location_def ORDER BY def_id");
110  ResultSet* rset = stmt->executeQuery();
111 
112  LocationDef locationDef;
113  locationDef.setConnection(m_env, m_conn);
114 
115  while(rset->next()) {
116  locationDef.setByID( rset->getInt(1) );
117  fillVec->push_back( locationDef );
118  }
119  } catch (SQLException &e) {
120  throw(std::runtime_error("LocationDef::fetchAllDefs: "+e.getMessage()));
121  }
122 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:26
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
void setByID(int id)
Definition: LocationDef.cc:76
void checkConnection() const
Definition: IDBObject.h:41
int LocationDef::fetchID ( )
throw (std::runtime_error
)
virtual

Implements IUniqueDBObject.

Definition at line 43 of file LocationDef.cc.

References alignCSCRings::e.

45 {
46  // Return def from memory if available
47  if (m_ID) {
48  return m_ID;
49  }
50 
51  this->checkConnection();
52 
53  try {
54  Statement* stmt = m_conn->createStatement();
55  stmt->setSQL("SELECT def_id FROM location_def WHERE "
56  "location = :location");
57  stmt->setString(1, m_loc);
58 
59  ResultSet* rset = stmt->executeQuery();
60 
61  if (rset->next()) {
62  m_ID = rset->getInt(1);
63  } else {
64  m_ID = 0;
65  }
66  m_conn->terminateStatement(stmt);
67  } catch (SQLException &e) {
68  throw(std::runtime_error("LocationDef::fetchID: "+e.getMessage()));
69  }
70 
71  return m_ID;
72 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:26
std::string m_loc
Definition: LocationDef.h:32
void checkConnection() const
Definition: IDBObject.h:41
string LocationDef::getLocation ( ) const

Definition at line 26 of file LocationDef.cc.

Referenced by EcalTPGDBApp::printTag(), and EcalErrorMask::readDB().

27 {
28  return m_loc;
29 }
std::string m_loc
Definition: LocationDef.h:32
bool LocationDef::operator!= ( const LocationDef l) const
inline

Definition at line 28 of file LocationDef.h.

References m_loc.

28 { return m_loc != l.m_loc; }
std::string m_loc
Definition: LocationDef.h:32
bool LocationDef::operator== ( const LocationDef l) const
inline

Definition at line 27 of file LocationDef.h.

References m_loc.

27 { return m_loc == l.m_loc; }
std::string m_loc
Definition: LocationDef.h:32
void LocationDef::setByID ( int  id)
throw (std::runtime_error
)
virtual

Implements IUniqueDBObject.

Definition at line 76 of file LocationDef.cc.

References alignCSCRings::e.

Referenced by fetchAllDefs().

78 {
79  this->checkConnection();
80 
81  try {
82  Statement* stmt = m_conn->createStatement();
83 
84  stmt->setSQL("SELECT location FROM location_def WHERE def_id = :1");
85  stmt->setInt(1, id);
86 
87  ResultSet* rset = stmt->executeQuery();
88  if (rset->next()) {
89  m_loc = rset->getString(1);
90  m_ID = id;
91  } else {
92  throw(std::runtime_error("LocationDef::setByID: Given def_id is not in the database"));
93  }
94 
95  m_conn->terminateStatement(stmt);
96  } catch (SQLException &e) {
97  throw(std::runtime_error("LocationDef::setByID: "+e.getMessage()));
98  }
99 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:26
std::string m_loc
Definition: LocationDef.h:32
void checkConnection() const
Definition: IDBObject.h:41
void LocationDef::setLocation ( std::string  loc)

Friends And Related Function Documentation

friend class EcalCondDBInterface
friend

Definition at line 14 of file LocationDef.h.

Member Data Documentation

std::string LocationDef::m_loc
protected

Definition at line 32 of file LocationDef.h.

Referenced by operator!=(), and operator==().