00001 //Dear emacs, this is -*- c++ -*- 00002 00013 #ifndef EFORMAT_ROSFRAGMENT_H 00014 #define EFORMAT_ROSFRAGMENT_H 00015 00016 #include "eformat/Header.h" 00017 #include "eformat/HeaderMarker.h" 00018 #include "eformat/ROBFragment.h" 00019 #include "eformat/SizeCheckIssue.h" 00020 00021 namespace eformat { 00022 00027 template <class TPointer> 00028 class ROSFragment : public eformat::Header<TPointer> { 00029 00030 public: //interface 00031 00038 ROSFragment (const TPointer& it); 00039 00043 ROSFragment () : Header<TPointer>(), m_start() {} 00044 00050 ROSFragment (const ROSFragment& other) 00051 : Header<TPointer>(other), m_start(other.m_start) {} 00052 00056 virtual ~ROSFragment() {} 00057 00063 ROSFragment& operator= (const ROSFragment& other) 00064 { Header<TPointer>::operator=(other); m_start=other.m_start; return *this; } 00065 00071 ROSFragment& assign (const TPointer& it); 00072 00076 virtual bool check () const; 00077 00081 bool check_tree () const; 00082 00086 inline uint32_t run_no() const { return m_start[0]; } 00087 00091 inline uint32_t lvl1_id() const { return m_start[1]; } 00092 00096 inline uint32_t bc_id() const { return m_start[2]; } 00097 00098 private: //static stuff 00099 00100 static const uint32_t NSPECIFIC; 00101 00102 private: //representation 00103 00104 TPointer m_start; 00105 00106 }; 00107 00108 } 00109 00110 template <class TPointer> 00111 const uint32_t eformat::ROSFragment<TPointer>::NSPECIFIC = 3; 00112 00113 template <class TPointer> 00114 eformat::ROSFragment<TPointer>::ROSFragment (const TPointer& it) 00115 : eformat::Header<TPointer>(it, eformat::ROS), 00116 m_start() 00117 { 00118 specific_header(m_start); 00119 } 00120 00121 template <class TPointer> eformat::ROSFragment<TPointer>& 00122 eformat::ROSFragment<TPointer>::assign (const TPointer& it) 00123 { 00124 ERS_DEBUG_3("Re-building ROSFragment from pointer"); 00125 eformat::Header<TPointer>::assign(it, eformat::ROS); 00126 specific_header(m_start); 00127 ERS_DEBUG_1("Initialized header with source identifier = %s", 00128 eformat::helper::SourceIdentifier(source_id()).human().c_str()); 00129 return *this; 00130 } 00131 00132 template <class TPointer> 00133 bool eformat::ROSFragment<TPointer>::check () const 00134 { 00135 ERS_DEBUG_2("Checking for consistency of ROSFragment"); 00136 eformat::Header<TPointer>::check(); //< first do a generic check 00137 if (eformat::Header<TPointer>::nspecific() != NSPECIFIC) 00138 throw EFORMAT_SIZE_CHECK(NSPECIFIC, this->nspecific()); 00139 return true; 00140 } 00141 00142 template <class TPointer> 00143 bool eformat::ROSFragment<TPointer>::check_tree () const 00144 { 00145 ERS_DEBUG_2("Checking recursively for consistency of ROSFragment"); 00146 check(); // check myself 00147 uint32_t total = this->nchildren(); 00148 for (size_t i=0; i<total; ++i) { 00149 TPointer fp; 00150 child(fp, i); 00151 eformat::ROBFragment<TPointer> f(fp); 00152 f.check_tree(); 00153 } 00154 return true; 00155 } 00156 00157 #endif /* EFORMAT_ROSFRAGMENT_H */