CMS 3D CMS Logo

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

ODScanConfig Class Reference

#include <ODScanConfig.h>

Inheritance diagram for ODScanConfig:
IODConfig IDBObject

List of all members.

Public Member Functions

int getFromVal () const
int getId () const
std::string getScanType () const
int getStep () const
std::string getTable ()
int getToVal () const
int getTypeId () const
 ODScanConfig ()
void setFromVal (int x)
void setId (int id)
void setParameters (std::map< std::string, std::string > my_keys_map)
void setScanType (std::string x)
void setStep (int x)
void setToVal (int x)
void setTypeId (int x)
 ~ODScanConfig ()

Private Member Functions

void clear ()
void fetchData (ODScanConfig *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_from_val
int m_ID
int m_step
int m_to_val
std::string m_type
int m_type_id

Friends

class EcalCondDBInterface

Detailed Description

Definition at line 9 of file ODScanConfig.h.


Constructor & Destructor Documentation

ODScanConfig::ODScanConfig ( )

Definition at line 11 of file ODScanConfig.cc.

References hitfit::clear(), and NULL.

ODScanConfig::~ODScanConfig ( )

Definition at line 24 of file ODScanConfig.cc.

{
}

Member Function Documentation

void ODScanConfig::clear ( void  ) [private]

Definition at line 28 of file ODScanConfig.cc.

                        {

  m_type_id=0;
  m_type="";
  m_from_val=0;
  m_to_val=0;
  m_step=0;

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

Definition at line 131 of file ODScanConfig.cc.

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

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

  try {

    m_readStmt->setSQL("SELECT * "
                       "FROM ECAL_SCAN_DAT "
                       " where (scan_id = :1  or scan_tag=:2 )" );
     m_readStmt->setInt(1, result->getId());
    m_readStmt->setString(2, result->getConfigTag());

    ResultSet* rset = m_readStmt->executeQuery();

    rset->next();

    // id 1 is the scan_id 
    result->setId(rset->getInt(1));
    result->setConfigTag(rset->getString(2));
    result->setTypeId(           rset->getInt(3) );
    result->setScanType(        rset->getString(4) );
    result->setFromVal(            rset->getInt(5) );
    result->setToVal(              rset->getInt(6) );
    result->setStep(              rset->getInt(7) );

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

Definition at line 166 of file ODScanConfig.cc.

References alignCSCRings::e.

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

  this->checkConnection();

  try {
    Statement* stmt = m_conn->createStatement();
    stmt->setSQL("SELECT scan_id FROM ecal_scan_dat "
                 "WHERE scan_tag=:scan_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("ODScanConfig::fetchID:  "+e.getMessage()));
  }

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

Definition at line 38 of file ODScanConfig.cc.

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

                                                       {

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

    m_readStmt = m_conn->createStatement(); 
    m_readStmt->setSQL("select ecal_scan_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("ODScanConfig::fetchNextId():  "+e.getMessage()));
  }

}
int ODScanConfig::getFromVal ( ) const [inline]

Definition at line 28 of file ODScanConfig.h.

References m_from_val.

{ return m_from_val; }
int ODScanConfig::getId ( ) const [inline]

Definition at line 19 of file ODScanConfig.h.

References m_ID.

{ return m_ID; }
std::string ODScanConfig::getScanType ( ) const [inline]

Definition at line 25 of file ODScanConfig.h.

References m_type.

{ return m_type; }
int ODScanConfig::getStep ( ) const [inline]

Definition at line 34 of file ODScanConfig.h.

References m_step.

{ return m_step ; }
std::string ODScanConfig::getTable ( ) [inline, virtual]

Implements IODConfig.

Definition at line 16 of file ODScanConfig.h.

{ return "ECAL_Scan_DAT"; }
int ODScanConfig::getToVal ( ) const [inline]

Definition at line 31 of file ODScanConfig.h.

References m_to_val.

{ return m_to_val; }
int ODScanConfig::getTypeId ( ) const [inline]

Definition at line 22 of file ODScanConfig.h.

References m_type_id.

{ return m_type_id; }
void ODScanConfig::prepareWrite ( ) throw (std::runtime_error) [private, virtual]

Implements IODConfig.

Definition at line 79 of file ODScanConfig.cc.

References alignCSCRings::e.

{
  this->checkConnection();
  int next_id=fetchNextId();

  try {
    m_writeStmt = m_conn->createStatement();
    m_writeStmt->setSQL("INSERT INTO ECAL_scan_dat ( scan_id, scan_tag ,"
                        "   type_id, scan_type , FROM_VAL , TO_VAL, STEP )"
                        " VALUES ( :1, :2, :3, :4, :5, :6, :7)");
    m_writeStmt->setInt(1, next_id);
    m_ID=next_id;

  } catch (SQLException &e) {
    throw(std::runtime_error("ODScanConfig::prepareWrite():  "+e.getMessage()));
  }
}
void ODScanConfig::setFromVal ( int  x) [inline]

Definition at line 27 of file ODScanConfig.h.

References m_from_val, and x.

{ m_from_val = x; }
void ODScanConfig::setId ( int  id) [inline]

Definition at line 18 of file ODScanConfig.h.

References errorMatrix2Lands_multiChannel::id, and m_ID.

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

Definition at line 24 of file ODScanConfig.h.

References m_type, and x.

{ m_type = x; }
void ODScanConfig::setStep ( int  x) [inline]

Definition at line 33 of file ODScanConfig.h.

References m_step, and x.

{ m_step = x; }
void ODScanConfig::setToVal ( int  x) [inline]

Definition at line 30 of file ODScanConfig.h.

References m_to_val, and x.

{ m_to_val = x; }
void ODScanConfig::setTypeId ( int  x) [inline]

Definition at line 21 of file ODScanConfig.h.

References m_type_id, and x.

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

Definition at line 98 of file ODScanConfig.cc.

References alignCSCRings::e.

{
  this->checkConnection();
  this->checkPrepare();

  try {

    // number 1 is the id 
    m_writeStmt->setString(2, this->getConfigTag());

    m_writeStmt->setInt(3, this->getTypeId());
    m_writeStmt->setString(4,  this->getScanType() );
    m_writeStmt->setInt(5, this->getFromVal() );
    m_writeStmt->setInt(6, this->getToVal() );
    m_writeStmt->setInt(7, this->getStep() );
 
    m_writeStmt->executeUpdate();


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

}

Friends And Related Function Documentation

friend class EcalCondDBInterface [friend]

Reimplemented from IDBObject.

Definition at line 11 of file ODScanConfig.h.


Member Data Documentation

int ODScanConfig::m_from_val [private]

Definition at line 51 of file ODScanConfig.h.

Referenced by getFromVal(), and setFromVal().

int ODScanConfig::m_ID [private]

Definition at line 47 of file ODScanConfig.h.

Referenced by getId(), and setId().

int ODScanConfig::m_step [private]

Definition at line 53 of file ODScanConfig.h.

Referenced by getStep(), and setStep().

int ODScanConfig::m_to_val [private]

Definition at line 52 of file ODScanConfig.h.

Referenced by getToVal(), and setToVal().

std::string ODScanConfig::m_type [private]

Definition at line 50 of file ODScanConfig.h.

Referenced by getScanType(), and setScanType().

int ODScanConfig::m_type_id [private]

Definition at line 49 of file ODScanConfig.h.

Referenced by getTypeId(), and setTypeId().