Cat
Options.h
Go to the documentation of this file.
1 //$Id $
2 //------------------------------------------------------------------------------
3 //
4 // Package : Options
5 //
6 // Description:
7 //
8 // Author(s) : F. Machefert -
9 // Date : 7 June 2004
10 //
11 //------------------------------------------------------------------------------
12 #ifndef CONFIG_H
13 #define CONFIG_H
14 
15 // Include files
16 #include <fstream>
17 #include <iostream>
18 #include <string>
19 
20 #include "MsgSvc.h"
21 #include "Tools.h"
22 
23 class Element;
24 
25 class Options {
26 public:
27  Options();
28  ~Options();
29 
36  }
37 
43  return m_logOutputLevel;
44  }
45 
50  void setPrintFreq (unsigned long printFreq) {
52  }
53 
58  unsigned long printFreq () {
59  return m_printFreq;
60  }
61 
66  void setPlotFreq (unsigned long plotFreq) {
68  }
69 
74  unsigned long plotFreq () {
75  return m_plotFreq;
76  }
77 
78 
85  }
86 
91  bool stopOnError () {
92  return m_stopOnError;
93  }
94 
99  void setRunNumber (unsigned long runNumber) {
101  }
102 
107  unsigned long runNumber () {
108  return m_runNumber;
109  }
110 
117  }
118 
124  return m_runNumberManagement;
125  }
126 
127  void setCurrentPath (std::string currentPath) {
129  }
130 
135  std::string currentPath () {
136  return m_currentPath;
137  }
138 
143  void setStoragePath (std::string storagePath) {
145  }
146 
151  std::string storagePath () {
152  return m_storagePath;
153  }
154 
159  std::string storageFullPath () {
160  std::string path = m_storagePath;
161  path.append("/");
162  path.append(m_storageDir);
163  path.append("_");
164  path.append(itos(m_runNumber));
165  return path;
166  }
167 
172  void setStorageDir (std::string filename){
173  m_storageDir = filename;
174  }
175 
180  std::string storageDir (){
181  return m_storageDir;
182  }
183 
188  void setStorageFile (std::string filename=std::string("")){
189  if (std::string("")==filename) {
191  return;
192  }
193  m_storageFile = filename;
194  }
195 
200  std::string storageFile (){
201  return m_storageFile;
202  }
203 
208  std::string storageFileFullName (){
209  std::string file = storageFullPath();
210  file.append("/");
211  file.append(m_storageFile);
212  return file;
213  }
214 
219  std::string dataFileFullName (){
220  std::string file = storageFullPath();
221  file.append("/");
222  file.append(m_storageFile);
223  file.append(".root");
224  // std::cout << " OPTIONS ->" << file << " " << storageFullPath()<< " " << m_storageFile << std::endl;
225  return file;
226  }
227 
232  std::string dataFile ();
233 
238  std::string logFile ();
239 
246  }
247 
252  bool dataStorage () {
253  return m_dataStorage;
254  }
255 
260  void setLogStorage (bool logStorage) {
262  }
263 
268  bool logStorage () {
269  return m_logStorage;
270  }
271 
276  void setLogDefFile (std::string defFile) {
278  m_logDefStream = new std::ofstream( defFile.c_str() );
279  }
280 
285  std::string logDefFile () {
286  return m_logDefFile;
287  }
288 
293  void setDefFile (std::string def) {
294  m_defFile = def;
295  }
296 
301  std::string defFile () {
302  return m_defFile;
303  }
304 
309  void setNEvt (unsigned long nEvt) {
310  m_nEvt = nEvt;
311  }
312 
317  unsigned long nEvt () {
318  return m_nEvt;
319  }
320 
325  void setNEvtMax (int nEvtMax) {
326  m_nEvtMax = nEvtMax;
327  }
328 
333  int nEvtMax () {
334  return m_nEvtMax;
335  }
336 
341  void setTimeMax (unsigned long timeMax) {
342  m_timeMax = timeMax;
343  }
344 
349  unsigned long timeMax () {
350  return m_timeMax;
351  }
352 
357  void setNErrors (unsigned long nErrors) {
358  m_nErrors = nErrors;
359  }
360 
365  unsigned long nErrors () {
366  return m_nErrors;
367  }
368 
372  void incRunNumber();
373 
377  void incNEvt() {
378  setNEvt ( nEvt() + 1 );
379  }
380 
384  void incNErrors() {
385  setNErrors ( nErrors() + 1 );
386  }
387 
392  std::ofstream* stream () {
393  return m_stream;
394  }
395 
400  void setStream ( std::string file=std::string("") ) {
401  if (file.compare("")==0 ) {
402  if (m_stream == m_logStream && 0!=m_logStream ) {
403  m_logStream->close();
404  delete m_logStream;
405  m_logStream = 0;
406  }
408  }
409  else {
410  if ( !logStorage () ) {
411  setStorageFile ( file );
412  }
413  else {
414  if ( 0!=m_logStream) {
415  m_logStream->close();
416  delete m_logStream;
417  m_logStream=0;
418  }
419  setStorageFile(file);
420  std::string name = storageFileFullName();
421  name.append(".log");
422  m_logStream = new std::ofstream( name.c_str() );
424  }
425  }
426  }
427 
432  void print();
433 
434 private:
436  MsgSvc::MsgLevel m_logOutputLevel; //< Output level threshold
437 
438  std::string m_currentPath; //< Current path of the application
439  bool m_dataStorage; //< Data Storage boolean
440  bool m_logStorage; //< Log Storage boolean
441  std::string m_storageDir; //< data & log directory name for storage
442  std::string m_storageFile; //< data & log file name for storage
443  std::string m_storageDefault; //< data & log default file name for storage
444  std::string m_storagePath; //< data & log file path for storage
445  std::string m_defFile; //< Definition file
447  unsigned long m_nEvt; //< number of events processed
448  unsigned long m_nErrors; //< number of errors in present process
449  unsigned long m_printFreq; //< Evt Number Output Frequency
450  unsigned long m_plotFreq; //< Evt Number Plot Frequency
451  int m_nEvtMax; //< number of events to process (negative val=seconds)
452  int m_timeMax; //< time to process
453  unsigned long m_runNumber; //< Current Run Number
454 
455  bool m_runNumberManagement; //< Run Number Automatically Managed
456  bool m_batch; //< batch mode
457 
458  std::ofstream *m_stream; // current log file output stream
459  std::ofstream *m_logStream; // log file output stream
460  std::ofstream *m_logDefStream; // default log file output stream
461  std::string m_logDefFile; //< default log file name for storage
462 };
463 
464 #endif
std::string itos(int)
Definition: Tools.cpp:46
bool m_runNumberManagement
Definition: Options.h:455
void incNErrors()
Definition: Options.h:384
std::ofstream * m_logStream
Definition: Options.h:459
unsigned long nEvt()
Definition: Options.h:317
void setPlotFreq(unsigned long plotFreq)
Definition: Options.h:66
void setStorageDir(std::string filename)
Definition: Options.h:172
bool m_dataStorage
Definition: Options.h:439
std::string m_storageDir
Definition: Options.h:441
void setStopOnError(bool stopOnError)
Definition: Options.h:83
void setNEvt(unsigned long nEvt)
Definition: Options.h:309
unsigned long timeMax()
Definition: Options.h:349
bool m_logStorage
Definition: Options.h:440
~Options()
Definition: Options.cpp:63
int nEvtMax()
Definition: Options.h:333
void incRunNumber()
Definition: Options.cpp:74
std::string dataFileFullName()
Definition: Options.h:219
bool runNumberManagement()
Definition: Options.h:123
void setCurrentPath(std::string currentPath)
Definition: Options.h:127
std::ofstream * m_logDefStream
Definition: Options.h:460
unsigned long m_nEvt
Definition: Options.h:447
std::string m_storagePath
Definition: Options.h:444
bool stopOnError()
Definition: Options.h:91
void setLogDefFile(std::string defFile)
Definition: Options.h:276
MsgSvc::MsgLevel m_logOutputLevel
Definition: Options.h:436
void setLogOutputLevel(MsgSvc::MsgLevel logOutputLevel)
Definition: Options.h:34
std::string storagePath()
Definition: Options.h:151
unsigned long runNumber()
Definition: Options.h:107
unsigned long m_plotFreq
Definition: Options.h:450
unsigned long nErrors()
Definition: Options.h:365
std::string m_defFile
Definition: Options.h:445
unsigned long plotFreq()
Definition: Options.h:74
std::string currentPath()
Definition: Options.h:135
std::ofstream * stream()
Definition: Options.h:392
unsigned long m_runNumber
Definition: Options.h:453
void setRunNumberManagement(bool runNumberManagement)
Definition: Options.h:115
std::string m_logDefFile
Definition: Options.h:461
int m_nEvtMax
Definition: Options.h:451
void setStoragePath(std::string storagePath)
Definition: Options.h:143
bool dataStorage()
Definition: Options.h:252
std::string m_currentPath
Definition: Options.h:438
std::string defFile()
Definition: Options.h:301
std::string m_storageDefault
Definition: Options.h:443
std::string m_storageFile
Definition: Options.h:442
void setNEvtMax(int nEvtMax)
Definition: Options.h:325
MsgSvc::MsgLevel logOutputLevel()
Definition: Options.h:42
void setLogStorage(bool logStorage)
Definition: Options.h:260
Options()
Definition: Options.cpp:19
void setPrintFreq(unsigned long printFreq)
Definition: Options.h:50
bool m_batch
Definition: Options.h:456
std::string logFile()
Definition: Options.cpp:95
std::string logDefFile()
Definition: Options.h:285
bool logStorage()
Definition: Options.h:268
std::string storageFile()
Definition: Options.h:200
void setNErrors(unsigned long nErrors)
Definition: Options.h:357
MsgLevel
Definition: MsgSvc.h:24
unsigned long printFreq()
Definition: Options.h:58
void setStorageFile(std::string filename=std::string(""))
Definition: Options.h:188
void print()
Definition: Options.cpp:107
std::string storageFullPath()
Definition: Options.h:159
void setRunNumber(unsigned long runNumber)
Definition: Options.h:99
void setDataStorage(bool dataStorage)
Definition: Options.h:244
void setStream(std::string file=std::string(""))
Definition: Options.h:400
unsigned long m_printFreq
Definition: Options.h:449
int m_timeMax
Definition: Options.h:452
MsgSvc m_log
Definition: Options.h:435
void setDefFile(std::string def)
Definition: Options.h:293
std::ofstream * m_stream
Definition: Options.h:458
void setTimeMax(unsigned long timeMax)
Definition: Options.h:341
std::string dataFile()
Definition: Options.cpp:83
unsigned long m_nErrors
Definition: Options.h:448
std::string storageDir()
Definition: Options.h:180
Definition: MsgSvc.h:21
std::string storageFileFullName()
Definition: Options.h:208
void incNEvt()
Definition: Options.h:377
bool m_stopOnError
Definition: Options.h:446