CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes
IODConfig Class Referenceabstract

#include <IODConfig.h>

Inheritance diagram for IODConfig:
IDBObject FEConfigBadStripDat FEConfigBadStripInfo FEConfigBadTTDat FEConfigBadTTInfo FEConfigBadXTDat FEConfigBadXTInfo FEConfigFgrInfo FEConfigLinInfo FEConfigLUTInfo FEConfigMainInfo FEConfigPedInfo FEConfigSlidingInfo FEConfigSpikeInfo FEConfigTimingInfo FEConfigWeightInfo ODBadTTDat ODBadTTInfo ODBadXTDat ODBadXTInfo ODCCSConfig ODCCSCycle ODCond2ConfInfo ODDCCConfig ODDCCCycle ODDCUConfig ODDCUCycle ODDelaysDat ODEcalCycle ODFEDAQConfig ODFEDelaysInfo ODFEPedestalOffsetInfo ODFEWeightsInfo ODGolBiasCurrentDat ODGolBiasCurrentInfo ODJBH4Config ODJBH4Cycle ODLaserConfig ODLaserCycle ODLTCConfig ODLTCCycle ODLTSConfig ODLTSCycle ODPedestalOffsetsDat ODRunConfigCycleInfo ODRunConfigInfo ODRunConfigSeqInfo ODScanConfig ODScanCycle ODSRPConfig ODSRPCycle ODTCCConfig ODTCCCycle ODTCCEEConfig ODTCCEECycle ODTowersToByPassDat ODTowersToByPassInfo ODTTCciConfig ODTTCciCycle ODTTCFConfig ODTTCFCycle ODVfeToRejectDat ODVfeToRejectInfo ODWeightsDat ODWeightsSamplesDat

Public Types

typedef oracle::occi::Clob Clob
 
typedef oracle::occi::SQLException SQLException
 
typedef oracle::occi::Statement Statement
 
typedef oracle::occi::Stream Stream
 

Public Member Functions

std::string getConfigTag ()
 
virtual std::string getTable ()=0
 
void setConfigTag (std::string x)
 
- 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 ()
 

Public Attributes

std::string m_config_tag
 

Protected Member Functions

void checkPrepare () noexcept(false)
 
void createReadStatement () noexcept(false)
 
void populateClob (Clob &clob, std::string fname, unsigned int bufsize) noexcept(false)
 
virtual void prepareWrite () noexcept(false)=0
 
unsigned char * readClob (Clob &clob, int size) noexcept(false)
 
void setPrefetchRowCount (int ncount) noexcept(false)
 
void terminateReadStatement () noexcept(false)
 
void terminateWriteStatement () noexcept(false)
 
- Protected Member Functions inherited from IDBObject
void checkConnection () const noexcept(false)
 

Protected Attributes

Statementm_readStmt
 
Statementm_writeStmt
 
- Protected Attributes inherited from IDBObject
oracle::occi::Connection * m_conn
 
oracle::occi::Environment * m_env
 

Additional Inherited Members

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

Detailed Description

Abstract interface for data in the conditions DB

Definition at line 18 of file IODConfig.h.

Member Typedef Documentation

typedef oracle::occi::Clob IODConfig::Clob

Definition at line 23 of file IODConfig.h.

typedef oracle::occi::SQLException IODConfig::SQLException

Definition at line 20 of file IODConfig.h.

typedef oracle::occi::Statement IODConfig::Statement

Definition at line 21 of file IODConfig.h.

typedef oracle::occi::Stream IODConfig::Stream

Definition at line 22 of file IODConfig.h.

Member Function Documentation

void IODConfig::checkPrepare ( )
inlineprotectednoexcept

Definition at line 36 of file IODConfig.h.

36  {
37  if (m_writeStmt == nullptr) {
38  throw(std::runtime_error("Write statement not prepared"));
39  }
40  }
Statement * m_writeStmt
Definition: IODConfig.h:33
void IODConfig::createReadStatement ( )
inlineprotectednoexcept

Definition at line 50 of file IODConfig.h.

References IDBObject::m_conn.

50 { m_readStmt = m_conn->createStatement(); }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
Statement * m_readStmt
Definition: IODConfig.h:34
std::string IODConfig::getConfigTag ( )
inline

Definition at line 30 of file IODConfig.h.

References m_config_tag.

30 { return m_config_tag; }
std::string m_config_tag
Definition: IODConfig.h:25
virtual std::string IODConfig::getTable ( )
pure virtual
void IODConfig::populateClob ( Clob clob,
std::string  fname,
unsigned int  bufsize 
)
inlineprotectednoexcept

Definition at line 67 of file IODConfig.h.

References edmScanValgrind::buffer, gather_cfg::cout, MillePedeFileConverter_cfg::e, end, FrontierConditions_GlobalTag_cff::file, alignmentValidation::fname, recoMuon::in, findQualityFiles::size, and AlCaHLTBitMon_QueryRunRegistry::string.

67  {
68  try {
69  // Uses stream here
70  std::cout << "Populating the Clob using writeBuffer(Stream) method" << std::endl;
71  std::cout << "we are here0" << std::endl;
72 
73  const char *file = fname.c_str();
74  std::cout << "we are here0.5 file is:" << fname << std::endl;
75 
76  std::ifstream inFile;
77  inFile.open(file, std::ios::in);
78  if (!inFile) {
79  std::cout << fname << " file not found\n";
80  inFile.close();
81 
82  std::string fname2 = "/nfshome0/ecaldev/francesca/null_file.txt";
83  inFile.open(fname2.c_str(), std::ios::in);
84  }
85  if (bufsize == 0) {
86  inFile.seekg(0, std::ios::end);
87  bufsize = inFile.tellg();
88  std::cout << " bufsize =" << bufsize << std::endl;
89  // set file pointer to start again
90  inFile.seekg(0, std::ios::beg);
91  }
92 
93  char *buffer = new char[bufsize + 1];
94 
95  std::cout << "we are here1" << std::endl;
96  unsigned int size;
97  Stream *strm = clob.getStream();
98  std::cout << "we are here2" << std::endl;
99  // while(inFile)
100  // {
101  int buf = 0;
102  memset(buffer, buf, bufsize + 1);
103  inFile.read(buffer, bufsize);
104  std::cout << "we are here2.5" << std::endl;
105 
106  strm->writeBuffer(buffer, strlen(buffer));
107  std::cout << "we are here2.6" << std::endl;
108 
109  //}
110  std::cout << "we are here3" << std::endl;
111  strcpy(buffer, " ");
112  size = strlen(buffer);
113  strm->writeLastBuffer(buffer, size);
114  clob.closeStream(strm);
115  inFile.close();
116  std::cout << "we are here4" << std::endl;
117  delete[] buffer;
118 
119  } catch (SQLException &e) {
120  throw(std::runtime_error(std::string("populateClob(): ") + e.getMessage()));
121  }
122 
123  std::cout << "Populating the Clob - Success" << std::endl;
124  }
size
Write out results.
oracle::occi::Stream Stream
Definition: IODConfig.h:22
#define end
Definition: vmac.h:39
string fname
main script
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20
virtual void IODConfig::prepareWrite ( )
protectedpure virtualnoexcept
unsigned char* IODConfig::readClob ( Clob clob,
int  size 
)
inlineprotectednoexcept

Definition at line 126 of file IODConfig.h.

References edmScanValgrind::buffer, gather_cfg::cout, MillePedeFileConverter_cfg::e, mps_fire::i, findQualityFiles::size, and AlCaHLTBitMon_QueryRunRegistry::string.

126  {
127  try {
128  Stream *instream = clob.getStream(1, 0);
129  unsigned char *buffer = new unsigned char[size];
130  int buf = 0;
131  memset(buffer, buf, size);
132 
133  instream->readBuffer((char *)buffer, size);
134  std::cout << "remember to delete the char* at the end of the program ";
135  for (int i = 0; i < size; ++i)
136  std::cout << (char)buffer[i];
137  std::cout << std::endl;
138 
139  clob.closeStream(instream);
140 
141  return buffer;
142 
143  } catch (SQLException &e) {
144  throw(std::runtime_error(std::string("readClob(): ") + e.getMessage()));
145  }
146  }
size
Write out results.
oracle::occi::Stream Stream
Definition: IODConfig.h:22
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20
void IODConfig::setConfigTag ( std::string  x)
inline
void IODConfig::setPrefetchRowCount ( int  ncount)
inlineprotectednoexcept

Definition at line 52 of file IODConfig.h.

52 { m_readStmt->setPrefetchRowCount(ncount); }
Statement * m_readStmt
Definition: IODConfig.h:34
void IODConfig::terminateReadStatement ( )
inlineprotectednoexcept

Definition at line 54 of file IODConfig.h.

References gather_cfg::cout, IDBObject::m_conn, noexcept, and prepareWrite().

54  {
55  if (m_readStmt != nullptr) {
56  m_conn->terminateStatement(m_readStmt);
57  } else {
58  std::cout << "Warning from IDataItem: statement was aleady closed" << std::endl;
59  }
60  }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
Statement * m_readStmt
Definition: IODConfig.h:34
void IODConfig::terminateWriteStatement ( )
inlineprotectednoexcept

Definition at line 42 of file IODConfig.h.

References gather_cfg::cout, and IDBObject::m_conn.

42  {
43  if (m_writeStmt != nullptr) {
44  m_conn->terminateStatement(m_writeStmt);
45  } else {
46  std::cout << "Warning from IDataItem: statement was aleady closed" << std::endl;
47  }
48  }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
Statement * m_writeStmt
Definition: IODConfig.h:33

Member Data Documentation

std::string IODConfig::m_config_tag

Definition at line 25 of file IODConfig.h.

Referenced by getConfigTag().

Statement* IODConfig::m_readStmt
protected

Definition at line 34 of file IODConfig.h.

Statement* IODConfig::m_writeStmt
protected

Definition at line 33 of file IODConfig.h.