CMS 3D CMS Logo

Public Types | Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes

IODConfig Class Reference

#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

List of all members.

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 Attributes

std::string m_config_tag

Protected Member Functions

void checkPrepare () throw (std::runtime_error)
void createReadStatement () throw (std::runtime_error)
void populateClob (Clob &clob, std::string fname, unsigned int bufsize) throw (std::runtime_error)
virtual void prepareWrite ()=0 throw (std::runtime_error)
unsigned char * readClob (Clob &clob, int size) throw (std::runtime_error)
void setPrefetchRowCount (int ncount) throw (std::runtime_error)
void terminateReadStatement () throw (std::runtime_error)
void terminateWriteStatement () throw (std::runtime_error)

Protected Attributes

Statementm_readStmt
Statementm_writeStmt

Detailed Description

Abstract interface for data in the conditions DB

Definition at line 19 of file IODConfig.h.


Member Typedef Documentation

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

Definition at line 25 of file IODConfig.h.

Definition at line 22 of file IODConfig.h.

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

Definition at line 23 of file IODConfig.h.

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

Definition at line 24 of file IODConfig.h.


Member Function Documentation

void IODConfig::checkPrepare ( ) throw (std::runtime_error) [inline, protected]

Definition at line 39 of file IODConfig.h.

References m_writeStmt, and NULL.

    {
      if (m_writeStmt == NULL) {
        throw(std::runtime_error("Write statement not prepared"));
      }
    }
void IODConfig::createReadStatement ( ) throw (std::runtime_error) [inline, protected]

Definition at line 58 of file IODConfig.h.

References IDBObject::m_conn, and m_readStmt.

  {
      m_readStmt=m_conn->createStatement();
  }
std::string IODConfig::getConfigTag ( ) [inline]

Definition at line 32 of file IODConfig.h.

References m_config_tag.

{return m_config_tag;}
virtual std::string IODConfig::getTable ( ) [pure virtual]
void IODConfig::populateClob ( Clob clob,
std::string  fname,
unsigned int  bufsize 
) throw (std::runtime_error) [inline, protected]

Definition at line 88 of file IODConfig.h.

References gather_cfg::cout, alignCSCRings::e, end, mergeVDriftHistosByStation::file, recoMuon::in, findQualityFiles::size, and AlCaHLTBitMon_QueryRunRegistry::string.

{

  try{
      // Uses stream here
      std::cout << "Populating the Clob using writeBuffer(Stream) method" << std::endl;
      std::cout<<"we are here0"<<std::endl; 

      char *file = (char *)fname.c_str();
      std::cout<<"we are here0.5 file is:"<<fname<<std::endl; 

      std::ifstream inFile;
      inFile.open(file,std::ios::in);
      if (!inFile)
        {
          std::cout << fname <<" file not found\n";
          inFile.close();

          std::string fname2="/nfshome0/ecaldev/francesca/null_file.txt";
          inFile.open((char*)fname2.c_str(),std::ios::in);
          

          
        }
      if(bufsize==0){


        inFile.seekg( 0,std::ios::end ); 
        bufsize = inFile.tellg(); 
        std::cout <<" bufsize ="<<bufsize<< std::endl;
        // set file pointer to start again 
        inFile.seekg( 0,std::ios::beg ); 
        
      }

      char *buffer = new char[bufsize + 1];


      std::cout<<"we are here1"<<std::endl; 
      unsigned int size;
      Stream *strm=clob.getStream();
      std::cout<<"we are here2"<<std::endl; 
      //    while(inFile)
      //        {
      int buf=0;
      memset (buffer, buf, bufsize + 1);
      inFile.read(buffer,bufsize);
      std::cout<<"we are here2.5"<<std::endl; 
      
      strm->writeBuffer(buffer,strlen(buffer));
      std::cout<<"we are here2.6"<<std::endl; 

      //}
      std::cout<<"we are here3"<<std::endl; 
      strcpy(buffer," ");
      size=strlen(buffer);
      strm->writeLastBuffer(buffer,size);
      clob.closeStream(strm);
      inFile.close();
      std::cout<<"we are here4"<<std::endl; 
      delete[] buffer;


  }catch (SQLException &e) {
    throw(std::runtime_error("populateClob():  "+e.getMessage()));
  }

  std::cout << "Populating the Clob - Success" << std::endl;
}
virtual void IODConfig::prepareWrite ( ) throw (std::runtime_error) [protected, pure virtual]
unsigned char* IODConfig::readClob ( Clob clob,
int  size 
) throw (std::runtime_error) [inline, protected]

Definition at line 160 of file IODConfig.h.

References gather_cfg::cout, alignCSCRings::e, i, and findQualityFiles::size.

{

  try{
    Stream *instream = clob.getStream (1,0);
    unsigned char *buffer= new unsigned char[size]; 
    int buf=0;
    memset (buffer, buf, size);
    
    instream->readBuffer ((char*)buffer, size);
    std::cout << "remember to delete the char* at the end of the program ";
       for (int i = 0; i < size; ++i)
       std::cout << (char) buffer[i];
     std::cout << std::endl;
    

    clob.closeStream (instream);

    return  buffer;

  }catch (SQLException &e) {
    throw(std::runtime_error("readClob():  "+e.getMessage()));
  }

}
void IODConfig::setConfigTag ( std::string  x) [inline]
void IODConfig::setPrefetchRowCount ( int  ncount) throw (std::runtime_error) [inline, protected]

Definition at line 64 of file IODConfig.h.

References m_readStmt.

  {
    m_readStmt->setPrefetchRowCount(ncount);
  }
void IODConfig::terminateReadStatement ( ) throw (std::runtime_error) [inline, protected]

Definition at line 70 of file IODConfig.h.

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

  {
    if (m_readStmt != NULL) {
      m_conn->terminateStatement(m_readStmt);
    } else {
      std::cout << "Warning from IDataItem: statement was aleady closed"<< std::endl;
    }
  }
void IODConfig::terminateWriteStatement ( ) throw (std::runtime_error) [inline, protected]

Definition at line 47 of file IODConfig.h.

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

  {
    if (m_writeStmt != NULL) {
      m_conn->terminateStatement(m_writeStmt);
    } else {
      std::cout << "Warning from IDataItem: statement was aleady closed"<< std::endl;
    }
  }

Member Data Documentation

Definition at line 27 of file IODConfig.h.

Referenced by getConfigTag(), and setConfigTag().

Definition at line 37 of file IODConfig.h.

Referenced by createReadStatement(), setPrefetchRowCount(), and terminateReadStatement().

Definition at line 36 of file IODConfig.h.

Referenced by checkPrepare(), and terminateWriteStatement().