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 ()
 
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.4.10.1
Date:
2011/03/07 11:33:04

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:62
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 76 of file DbFileHandler.cc.

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

Referenced by write().

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

Configure the db file writer

Definition at line 39 of file DbFileHandler.cc.

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

40  {
41  dwParams_ = params;
43 
44  write("BoR");
45  }
unsigned int runNumber_
Definition: DbFileHandler.h:62
DiskWritingParams dwParams_
Definition: DbFileHandler.h:61
void write(const std::string &)
void stor::DbFileHandler::openFile ( std::ofstream &  outputFile,
const utils::TimePoint_t timestamp 
) const
private

Definition at line 49 of file DbFileHandler.cc.

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

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

53  {
55 
56  std::ostringstream dbfilename;
57  dbfilename
59  << "/"
61  << "-" << dwParams_.hostName_
63  << ".log";
64 
65  outputFile.open( dbfilename.str().c_str(), std::ios_base::ate | std::ios_base::out | std::ios_base::app );
66  if (! outputFile.is_open() )
67  {
68  std::ostringstream msg;
69  msg << "Failed to open db log file " << dbfilename.str();
70  XCEPT_RAISE(stor::exception::DiskWriting, msg.str());
71  }
72  }
std::string dateStamp(TimePoint_t)
Definition: Utils.cc:60
std::string smInstanceString_
Definition: Configuration.h:51
DiskWritingParams dwParams_
Definition: DbFileHandler.h:61
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 26 of file DbFileHandler.cc.

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

Referenced by configure().

27  {
29 
30  std::ofstream outputFile;
31  openFile(outputFile, timestamp);
32  addReportHeader(outputFile, timestamp);
33  outputFile << str.c_str();
34  outputFile << std::endl;
35  outputFile.close();
36  }
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.close();
23  }
void openFile(std::ofstream &, const utils::TimePoint_t &) const

Member Data Documentation

DiskWritingParams stor::DbFileHandler::dwParams_
private

Definition at line 61 of file DbFileHandler.h.

Referenced by configure().

unsigned int stor::DbFileHandler::runNumber_
private

Definition at line 62 of file DbFileHandler.h.

Referenced by configure().