CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
stor::DbFileHandler Class Reference

#include <DbFileHandler.h>

Public Member Functions

void configure (const unsigned int runNumber, const DiskWritingParams &)
 
 DbFileHandler ()
 
const DiskWritingParamsgetDiskWritingParams () const
 
void write (const std::string &)
 
void writeOld (const utils::TimePoint_t &, const std::string &)
 
 ~DbFileHandler ()
 

Private Member Functions

void addReportHeader (std::ostream &, const utils::TimePoint_t &) const
 
 DbFileHandler (DbFileHandler const &)
 
void openFile (std::ofstream &, const utils::TimePoint_t &) const
 
DbFileHandleroperator= (DbFileHandler const &)
 

Private Attributes

DiskWritingParams dwParams_
 
unsigned int runNumber_
 

Detailed Description

Handle the file used to pass information into SM database

Author:
mommsen
Revision:
1.6
Date:
2012/04/04 12:16:26

Definition at line 26 of file DbFileHandler.h.

Constructor & Destructor Documentation

stor::DbFileHandler::DbFileHandler ( )

Definition at line 12 of file DbFileHandler.cc.

12  :
13  runNumber_(0)
14  {}
unsigned int runNumber_
Definition: DbFileHandler.h:68
stor::DbFileHandler::~DbFileHandler ( )
inline

Definition at line 32 of file DbFileHandler.h.

32 {};
stor::DbFileHandler::DbFileHandler ( DbFileHandler const &  )
private

Member Function Documentation

void stor::DbFileHandler::addReportHeader ( std::ostream &  msg,
const utils::TimePoint_t timestamp 
) const
private

Definition at line 77 of file DbFileHandler.cc.

References sistrip::runNumber_, and stor::utils::secondsSinceEpoch().

Referenced by write().

81  {
82  msg << "Timestamp:" << utils::secondsSinceEpoch(timestamp)
83  << "\trun:" << runNumber_
84  << "\thost:" << dwParams_.hostName_
85  << "\tinstance:" << dwParams_.smInstanceString_
86  << "\t";
87  }
unsigned int runNumber_
Definition: DbFileHandler.h:68
std::string smInstanceString_
Definition: Configuration.h:51
long secondsSinceEpoch(TimePoint_t const &)
Definition: Utils.h:152
DiskWritingParams dwParams_
Definition: DbFileHandler.h:67
void stor::DbFileHandler::configure ( const unsigned int  runNumber,
const DiskWritingParams params 
)

Configure the db file writer

Definition at line 40 of file DbFileHandler.cc.

References dwParams_, convertSQLiteXML::runNumber, runNumber_, and write().

41  {
42  dwParams_ = params;
44 
45  write("BoR");
46  }
unsigned int runNumber_
Definition: DbFileHandler.h:68
DiskWritingParams dwParams_
Definition: DbFileHandler.h:67
void write(const std::string &)
const DiskWritingParams& stor::DbFileHandler::getDiskWritingParams ( ) const
inline

Return the DiskWritingParams used to configure the DbFileHandler

Definition at line 53 of file DbFileHandler.h.

References dwParams_.

54  { return dwParams_; }
DiskWritingParams dwParams_
Definition: DbFileHandler.h:67
void stor::DbFileHandler::openFile ( std::ofstream &  outputFile,
const utils::TimePoint_t timestamp 
) const
private

Definition at line 50 of file DbFileHandler.cc.

References stor::utils::checkDirectory(), stor::utils::dateStamp(), lumiQueryAPI::msg, and dbtoconf::out.

Referenced by Vispa.Main.Application.Application::_readCommandLineAttributes(), Vispa.Main.Application.Application::doubleClickOnFile(), Vispa.Main.Application.Application::openFileDialog(), Vispa.Main.Application.Application::openRecentFileSlot(), write(), and writeOld().

54  {
56 
57  std::ostringstream dbfilename;
58  dbfilename
60  << "/"
62  << "-" << dwParams_.hostName_
64  << ".log";
65 
66  outputFile.open( dbfilename.str().c_str(), std::ios_base::ate | std::ios_base::out | std::ios_base::app );
67  if (! outputFile.is_open() )
68  {
69  std::ostringstream msg;
70  msg << "Failed to open db log file " << dbfilename.str();
71  XCEPT_RAISE(stor::exception::DiskWriting, msg.str());
72  }
73  }
std::string dateStamp(TimePoint_t)
Definition: Utils.cc:60
std::string smInstanceString_
Definition: Configuration.h:51
DiskWritingParams dwParams_
Definition: DbFileHandler.h:67
void checkDirectory(const std::string &)
Definition: Utils.cc:80
tuple out
Definition: dbtoconf.py:99
DbFileHandler& stor::DbFileHandler::operator= ( DbFileHandler const &  )
private
void stor::DbFileHandler::write ( const std::string &  str)

Write the string into the db file and prefix it with the report header. Close the file after each write.

Definition at line 27 of file DbFileHandler.cc.

References addReportHeader(), stor::utils::getCurrentTime(), openFile(), download_sqlite_cfg::outputFile, and cond::timestamp.

Referenced by configure(), and pkg.AbstractPkg::generate().

28  {
30 
31  std::ofstream outputFile;
32  openFile(outputFile, timestamp);
33  addReportHeader(outputFile, timestamp);
34  outputFile << str.c_str();
35  outputFile << std::endl;
36  outputFile.close();
37  }
TimePoint_t getCurrentTime()
Definition: Utils.h:158
void addReportHeader(std::ostream &, const utils::TimePoint_t &) const
boost::posix_time::ptime TimePoint_t
Definition: Utils.h:35
void openFile(std::ofstream &, const utils::TimePoint_t &) const
void stor::DbFileHandler::writeOld ( const utils::TimePoint_t timestamp,
const std::string &  str 
)

Write the string into the db file. Close the file after each write.

Definition at line 17 of file DbFileHandler.cc.

References openFile(), and download_sqlite_cfg::outputFile.

18  {
19  std::ofstream outputFile;
20  openFile(outputFile, timestamp);
21  outputFile << str.c_str();
22  outputFile << std::endl;
23  outputFile.close();
24  }
void openFile(std::ofstream &, const utils::TimePoint_t &) const

Member Data Documentation

DiskWritingParams stor::DbFileHandler::dwParams_
private

Definition at line 67 of file DbFileHandler.h.

Referenced by configure(), and getDiskWritingParams().

unsigned int stor::DbFileHandler::runNumber_
private

Definition at line 68 of file DbFileHandler.h.

Referenced by configure().