CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes | Friends

ODSRPConfig Class Reference

#include <ODSRPConfig.h>

Inheritance diagram for ODSRPConfig:
IODConfig IDBObject

List of all members.

Public Member Functions

int getAutomaticMasks () const
int getAutomaticSrpSelect () const
std::string getConfigFile () const
int getDebugMode () const
int getDummyMode () const
int getId () const
std::string getPatternDirectory () const
int getSRP0BunchAdjustPosition () const
unsigned char * getSRPClob () const
unsigned int getSRPClobSize () const
std::string getTable ()
 ODSRPConfig ()
void setAutomaticMasks (int x)
void setAutomaticSrpSelect (int x)
void setConfigFile (std::string x)
void setDebugMode (int x)
void setDummyMode (int x)
void setId (int id)
void setParameters (std::map< std::string, std::string > my_keys_map)
void setPatternDirectory (std::string x)
void setSRP0BunchAdjustPosition (int x)
void setSRPClob (unsigned char *x)
 ~ODSRPConfig ()

Private Member Functions

void clear ()
void fetchData (ODSRPConfig *result) throw (std::runtime_error)
int fetchID () throw (std::runtime_error)
int fetchNextId () throw (std::runtime_error)
void prepareWrite () throw (std::runtime_error)
void writeDB () throw (std::runtime_error)

Private Attributes

int m_auto
int m_auto_srp
int m_bnch
int m_debug
int m_dummy
std::string m_file
int m_ID
std::string m_patdir
unsigned int m_size
unsigned char * m_srp_clob

Friends

class EcalCondDBInterface

Detailed Description

Definition at line 17 of file ODSRPConfig.h.


Constructor & Destructor Documentation

ODSRPConfig::ODSRPConfig ( )

Definition at line 13 of file ODSRPConfig.cc.

References NULL.

ODSRPConfig::~ODSRPConfig ( )

Definition at line 37 of file ODSRPConfig.cc.

{
}

Member Function Documentation

void ODSRPConfig::clear ( void  ) [private]

Definition at line 26 of file ODSRPConfig.cc.

                       {
  //  strcpy((char *)m_srp_clob, "");
 m_debug=0;
 m_dummy=0;
 m_file="";
 m_patdir="";
 m_auto=0;
 m_bnch=0;

}
void ODSRPConfig::fetchData ( ODSRPConfig result) throw (std::runtime_error) [private]

Definition at line 203 of file ODSRPConfig.cc.

References ExpressReco_HICollisions_FallBack::e, and query::result.

{
  this->checkConnection();
  //  result->clear();
  int idid=0;
  if(result->getId()==0 && (result->getConfigTag()=="") ){
    //    throw(std::runtime_error("ODSRPConfig::fetchData(): no Id defined for this ODSRPConfig "));
    idid=result->fetchID();
  }

  try {

    m_readStmt->setSQL("SELECT  * "
                       " FROM ECAL_SRP_CONFIGURATION  "
                       " where (srp_configuration_id = :1 or srp_tag=:2 )" );
    m_readStmt->setInt(1, result->getId());
    m_readStmt->setString(2, result->getConfigTag());
    ResultSet* rset = m_readStmt->executeQuery();

    rset->next();
    // 1 is the id and 2 is the config tag

    result->setId(rset->getInt(1));
    result->setConfigTag(rset->getString(2));

    result->setDebugMode(rset->getInt(3));
    result->setDummyMode(rset->getInt(4));
    result->setPatternDirectory(rset->getString(5));
    result->setAutomaticMasks(rset->getInt(6));
    result->setSRP0BunchAdjustPosition(rset->getInt(7));
    result->setConfigFile(rset->getString(8));

    Clob clob = rset->getClob(9);
    m_size = clob.length();
    Stream *instream = clob.getStream (1,0);
    unsigned char *buffer = new unsigned char[m_size];
    memset (buffer, 0, m_size);
    instream->readBuffer ((char*)buffer, m_size);
    /*
    cout << "Opening the clob in Read only mode" << endl;
    clob.open (OCCI_LOB_READONLY);
    int clobLength=clob.length ();
    cout << "Length of the clob is: " << clobLength << endl;
    unsigned char* buffer = readClob (clob, clobLength);
    clob.close ();
    cout<< "the clob buffer is:"<<endl;  
    for (int i = 0; i < clobLength; ++i)
      cout << (char) buffer[i];
    cout << endl;


    */
    result->setSRPClob(buffer );
    result->setAutomaticSrpSelect(rset->getInt(10));

  } catch (SQLException &e) {
    throw(std::runtime_error("ODSRPConfig::fetchData():  "+e.getMessage()));
  }
}
int ODSRPConfig::fetchID ( ) throw (std::runtime_error) [private]

Definition at line 266 of file ODSRPConfig.cc.

References ExpressReco_HICollisions_FallBack::e.

{
  // Return from memory if available
  if (m_ID!=0) {
    return m_ID;
  }

  this->checkConnection();

  try {
    Statement* stmt = m_conn->createStatement();
    stmt->setSQL("SELECT srp_configuration_id FROM ecal_srp_configuration "
                 "WHERE  srp_tag=:srp_tag "
                 );

    stmt->setString(1, getConfigTag() );

    ResultSet* rset = stmt->executeQuery();

    if (rset->next()) {
      m_ID = rset->getInt(1);
    } else {
      m_ID = 0;
    }
    m_conn->terminateStatement(stmt);
  } catch (SQLException &e) {
    throw(std::runtime_error("ODSRPConfig::fetchID:  "+e.getMessage()));
  }

    return m_ID;
}
int ODSRPConfig::fetchNextId ( ) throw (std::runtime_error) [private]

Definition at line 41 of file ODSRPConfig.cc.

References ExpressReco_HICollisions_FallBack::e, and query::result.

                                                      {

  int result=0;
  try {
    this->checkConnection();

    m_readStmt = m_conn->createStatement(); 
    m_readStmt->setSQL("select ecal_srp_config_sq.NextVal from dual");
    ResultSet* rset = m_readStmt->executeQuery();
    while (rset->next ()){
      result= rset->getInt(1);
    }
    m_conn->terminateStatement(m_readStmt);
    return result; 

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

}
int ODSRPConfig::getAutomaticMasks ( ) const [inline]

Definition at line 39 of file ODSRPConfig.h.

References m_auto.

{ return m_auto; }
int ODSRPConfig::getAutomaticSrpSelect ( ) const [inline]

Definition at line 42 of file ODSRPConfig.h.

References m_auto_srp.

{ return m_auto_srp; }
std::string ODSRPConfig::getConfigFile ( ) const [inline]

Definition at line 48 of file ODSRPConfig.h.

References m_file.

{ return m_file; }
int ODSRPConfig::getDebugMode ( ) const [inline]

Definition at line 30 of file ODSRPConfig.h.

References m_debug.

{ return m_debug; }
int ODSRPConfig::getDummyMode ( ) const [inline]

Definition at line 33 of file ODSRPConfig.h.

References m_dummy.

{ return m_dummy; }
int ODSRPConfig::getId ( ) const [inline]

Definition at line 27 of file ODSRPConfig.h.

References m_ID.

{ return m_ID; }
std::string ODSRPConfig::getPatternDirectory ( ) const [inline]

Definition at line 36 of file ODSRPConfig.h.

References m_patdir.

{ return m_patdir; }
int ODSRPConfig::getSRP0BunchAdjustPosition ( ) const [inline]

Definition at line 45 of file ODSRPConfig.h.

References m_bnch.

{ return m_bnch; }
unsigned char* ODSRPConfig::getSRPClob ( ) const [inline]

Definition at line 51 of file ODSRPConfig.h.

References m_srp_clob.

{ return m_srp_clob; }
unsigned int ODSRPConfig::getSRPClobSize ( ) const [inline]

Definition at line 52 of file ODSRPConfig.h.

References m_size.

{ return m_size; }
std::string ODSRPConfig::getTable ( ) [inline, virtual]

Implements IODConfig.

Definition at line 24 of file ODSRPConfig.h.

{ return "ECAL_SRP_CONFIGURATION"; }
void ODSRPConfig::prepareWrite ( ) throw (std::runtime_error) [private, virtual]

Implements IODConfig.

Definition at line 116 of file ODSRPConfig.cc.

References gather_cfg::cout, and ExpressReco_HICollisions_FallBack::e.

{
  this->checkConnection();

  int next_id=fetchNextId();

  try {
    m_writeStmt = m_conn->createStatement();
    m_writeStmt->setSQL("INSERT INTO ECAL_SRP_CONFIGURATION (srp_configuration_id, srp_tag, "
                        "   DEBUGMODE, DUMMYMODE, PATTERN_DIRECTORY, AUTOMATIC_MASKS,"
                        " SRP0BUNCHADJUSTPOSITION, SRP_CONFIG_FILE, SRP_CONFIGURATION,  AUTOMATICSRPSELECT  ) "
                        "VALUES (:1, :2, :3, :4, :5, :6, :7, :8, :9, :10 )");
    m_writeStmt->setInt(1, next_id);
    m_writeStmt->setString(2, getConfigTag());
    m_writeStmt->setInt(3, getDebugMode());
    m_writeStmt->setInt(4, getDummyMode());
    m_writeStmt->setString(5, getPatternDirectory());
    m_writeStmt->setInt(6, getAutomaticMasks());
    m_writeStmt->setInt(10, getAutomaticSrpSelect());
    m_writeStmt->setInt(7, getSRP0BunchAdjustPosition());
    m_writeStmt->setString(8, getConfigFile());
  
    // and now the clob
    oracle::occi::Clob clob(m_conn);
    clob.setEmpty();
    m_writeStmt->setClob(9,clob);
    m_writeStmt->executeUpdate ();
    m_ID=next_id; 

    m_conn->terminateStatement(m_writeStmt);
    std::cout<<"SRP Clob inserted into CONFIGURATION with id="<<next_id<<std::endl;

    // now we read and update it 
    m_writeStmt = m_conn->createStatement(); 
    m_writeStmt->setSQL ("SELECT srp_configuration FROM ECAL_SRP_CONFIGURATION WHERE"
                         " srp_configuration_id=:1 FOR UPDATE");

    std::cout<<"updating the clob 0"<<std::endl;

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

  std::cout<<"updating the clob 1 "<<std::endl;
  
}
void ODSRPConfig::setAutomaticMasks ( int  x) [inline]

Definition at line 38 of file ODSRPConfig.h.

References m_auto, and ExpressReco_HICollisions_FallBack::x.

{ m_auto = x; }
void ODSRPConfig::setAutomaticSrpSelect ( int  x) [inline]

Definition at line 41 of file ODSRPConfig.h.

References m_auto_srp, and ExpressReco_HICollisions_FallBack::x.

{ m_auto_srp = x; }
void ODSRPConfig::setConfigFile ( std::string  x) [inline]

Definition at line 47 of file ODSRPConfig.h.

References m_file, and ExpressReco_HICollisions_FallBack::x.

{ m_file = x; }
void ODSRPConfig::setDebugMode ( int  x) [inline]

Definition at line 29 of file ODSRPConfig.h.

References m_debug, and ExpressReco_HICollisions_FallBack::x.

{ m_debug = x; }
void ODSRPConfig::setDummyMode ( int  x) [inline]

Definition at line 32 of file ODSRPConfig.h.

References m_dummy, and ExpressReco_HICollisions_FallBack::x.

{ m_dummy= x; }
void ODSRPConfig::setId ( int  id) [inline]

Definition at line 26 of file ODSRPConfig.h.

References ExpressReco_HICollisions_FallBack::id, and m_ID.

{ m_ID = id; }
void ODSRPConfig::setParameters ( std::map< std::string, std::string >  my_keys_map)
void ODSRPConfig::setPatternDirectory ( std::string  x) [inline]

Definition at line 35 of file ODSRPConfig.h.

References m_patdir, and ExpressReco_HICollisions_FallBack::x.

{ m_patdir = x; }
void ODSRPConfig::setSRP0BunchAdjustPosition ( int  x) [inline]

Definition at line 44 of file ODSRPConfig.h.

References m_bnch, and ExpressReco_HICollisions_FallBack::x.

{ m_bnch = x; }
void ODSRPConfig::setSRPClob ( unsigned char *  x) [inline]

Definition at line 50 of file ODSRPConfig.h.

References m_srp_clob, and ExpressReco_HICollisions_FallBack::x.

{ m_srp_clob = x; }
void ODSRPConfig::writeDB ( ) throw (std::runtime_error) [private]

Definition at line 166 of file ODSRPConfig.cc.

References gather_cfg::cout, and ExpressReco_HICollisions_FallBack::e.

{

  std::cout<<"updating the clob 2"<<std::endl;

  try {
    m_writeStmt->setInt(1, m_ID);
    ResultSet* rset = m_writeStmt->executeQuery();

    while (rset->next ())
      {
        oracle::occi::Clob clob = rset->getClob (1);
        cout << "Opening the clob in read write mode" << endl;
        cout << "Populating the clob" << endl;
        populateClob (clob, getConfigFile(), m_size );
        int clobLength=clob.length ();
        cout << "Length of the clob after writing is: " << clobLength << endl;
      
      }

    m_writeStmt->executeUpdate();

    m_writeStmt->closeResultSet (rset);

  } catch (SQLException &e) {
    throw(std::runtime_error("ODSRPConfig::writeDB():  "+e.getMessage()));
  }
  // Now get the ID
  if (!this->fetchID()) {
    throw(std::runtime_error("ODSRPConfig::writeDB:  Failed to write"));
  }


}

Friends And Related Function Documentation

friend class EcalCondDBInterface [friend]

Reimplemented from IDBObject.

Definition at line 19 of file ODSRPConfig.h.


Member Data Documentation

int ODSRPConfig::m_auto [private]

Definition at line 73 of file ODSRPConfig.h.

Referenced by getAutomaticMasks(), and setAutomaticMasks().

int ODSRPConfig::m_auto_srp [private]

Definition at line 73 of file ODSRPConfig.h.

Referenced by getAutomaticSrpSelect(), and setAutomaticSrpSelect().

int ODSRPConfig::m_bnch [private]

Definition at line 74 of file ODSRPConfig.h.

Referenced by getSRP0BunchAdjustPosition(), and setSRP0BunchAdjustPosition().

int ODSRPConfig::m_debug [private]

Definition at line 69 of file ODSRPConfig.h.

Referenced by getDebugMode(), and setDebugMode().

int ODSRPConfig::m_dummy [private]

Definition at line 70 of file ODSRPConfig.h.

Referenced by getDummyMode(), and setDummyMode().

std::string ODSRPConfig::m_file [private]

Definition at line 71 of file ODSRPConfig.h.

Referenced by getConfigFile(), and setConfigFile().

int ODSRPConfig::m_ID [private]

Definition at line 67 of file ODSRPConfig.h.

Referenced by getId(), and setId().

std::string ODSRPConfig::m_patdir [private]

Definition at line 72 of file ODSRPConfig.h.

Referenced by getPatternDirectory(), and setPatternDirectory().

unsigned int ODSRPConfig::m_size [private]

Definition at line 75 of file ODSRPConfig.h.

Referenced by getSRPClobSize().

unsigned char* ODSRPConfig::m_srp_clob [private]

Definition at line 68 of file ODSRPConfig.h.

Referenced by getSRPClob(), and setSRPClob().