#include <CalibTracker/SiStripRunSummary/interface/SerializeBase.h>
Public Member Functions | |
FlagTxt * | getFlag () |
Get pointer to last read Flag if there is any available. | |
template<class T> | |
T * | read (std::istream &roIn) |
Generic method for reading FlagTxt from stream. | |
SerializeBase () | |
bool | write (std::ostream &roOut, const FlagTxt &roFLAGTXT) const |
Generic method for saving any FlagTxt anchestor in output stream that may be ostringstream, ofstream, etc. | |
virtual | ~SerializeBase () |
Private Member Functions | |
virtual void | readFlag (FlagTxt *poFlagTxt, std::istream &roIn)=0 |
Perform actual flag read. | |
virtual void | writeFlag (std::ostream &roOut, const FlagTxt &roFLAGTXT) const =0 |
Perform actual flag wtore operation. | |
Private Attributes | |
FlagTxt * | poFlagTxt_ |
Definition at line 22 of file SerializeBase.h.
SerializeBase::SerializeBase | ( | ) |
Definition at line 13 of file SerializeBase.cc.
References poFlagTxt_.
00013 { 00014 poFlagTxt_ = 0; 00015 }
SerializeBase::~SerializeBase | ( | ) | [virtual] |
Definition at line 17 of file SerializeBase.cc.
References poFlagTxt_.
00017 { 00018 if( poFlagTxt_) { 00019 delete poFlagTxt_; 00020 } 00021 }
FlagTxt* SerializeBase::getFlag | ( | ) | [inline] |
Get pointer to last read Flag if there is any available.
Definition at line 73 of file SerializeBase.h.
References poFlagTxt_.
00073 { return poFlagTxt_; }
T * SerializeBase::read | ( | std::istream & | roIn | ) | [inline] |
Generic method for reading FlagTxt from stream.
Class T should be the Flags class to be read. In given case different Trees can be read with the same manager SerializeTxt, e.g.:
DQMFlagTxt *poFlag = oSerializeTxt.read<DQMFlagTxt>( oIn); TIBFlagTxt *poFlag = oSerializeTxt.read<TIBFlagTxt>( oIn);
of course it is assumed that stream contains given flag stored. Trying to read incorrect flag would lead to exception that is caught by manager and NULL pointer is returned.
roIn | Input stream containing saved Tree |
Definition at line 103 of file SerializeBase.h.
References poFlagTxt_, and readFlag().
Referenced by FiletoBIN(), FiletoTXT(), StrtoBIN(), and StrtoTXT().
00103 { 00104 if( poFlagTxt_) { 00105 delete poFlagTxt_; 00106 poFlagTxt_ = 0; 00107 } 00108 00109 // [Note: Object will be deleted by SerializeTxt (!)] 00110 T *poT = new T(); 00111 00112 // Check if this is actually child class of FlagTxt 00113 if( FlagTxt *poFlagTxt = dynamic_cast<FlagTxt *>( poT)) { 00114 00115 // Attempt to read flag from tree 00116 try { 00117 readFlag( poFlagTxt, roIn); 00118 00119 poFlagTxt_ = poFlagTxt; 00120 } catch( ...) { 00121 // Failed: maybe stream contains other flag saved - not T? 00122 delete poT; 00123 poT = 0; 00124 } 00125 } else { 00126 // Not a child 00127 delete poT; 00128 poT = 0; 00129 } 00130 00131 return poT; 00132 }
virtual void SerializeBase::readFlag | ( | FlagTxt * | poFlagTxt, | |
std::istream & | roIn | |||
) | [private, pure virtual] |
Perform actual flag read.
Used by template read method to overcome compilation problems with include of boost/archive/text_i(o)archive.hpp from header [should be included only once from cpp]. Should be implemented by anchestors.
poFlagTxt | Pointer to FlagTxt anchestor to be saved in output stream | |
roIn | Output stream where flag will be saved |
Implemented in SerializeTxt, and SerializeBin.
Referenced by read().
Generic method for saving any FlagTxt anchestor in output stream that may be ostringstream, ofstream, etc.
Type will be handled by boost::serialization library automatially.
roOut | Output stream where flag will be saved | |
roFLAGTXT | Flag reference to be saved |
Definition at line 23 of file SerializeBase.cc.
References writeFlag().
Referenced by SiStripRunSummaryWrite::algoEndJob(), BINtoFile(), BINtoStr(), TXTtoFile(), and TXTtoStr().
00025 { 00026 bool bResult = false; 00027 00028 try { 00029 writeFlag( roOut, roFLAGTXT); 00030 00031 bResult = true; 00032 } catch( ...) { 00033 // Failed to write Flag into output stream 00034 } 00035 00036 return bResult; 00037 }
virtual void SerializeBase::writeFlag | ( | std::ostream & | roOut, | |
const FlagTxt & | roFLAGTXT | |||
) | const [private, pure virtual] |
Perform actual flag wtore operation.
Method should be implemented by anchestor.
roOut | Output stream where flags tree will be saved | |
roFLAGTXT | Reference to flag to be stored |
Implemented in SerializeTxt, and SerializeBin.
Referenced by write().
FlagTxt* SerializeBase::poFlagTxt_ [private] |
Definition at line 100 of file SerializeBase.h.
Referenced by getFlag(), read(), SerializeBase(), and ~SerializeBase().