/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Event/eformat/eformat-00-00-04/eformat/ROBFragment.h

Go to the documentation of this file.
00001 //Dear emacs, this is -*- c++ -*-
00002 
00014 #ifndef EFORMAT_ROBFRAGMENT_H
00015 #define EFORMAT_ROBFRAGMENT_H
00016 
00017 #include "eformat/Header.h"
00018 #include "eformat/HeaderMarker.h"
00019 #include "eformat/SizeCheckIssue.h"
00020 #include "eformat/WrongMarkerIssue.h"
00021 #include "eformat/BadVersionIssue.h"
00022 
00023 namespace eformat {
00024 
00029   template <class TPointer>
00030   class ROBFragment : public eformat::Header<TPointer> {
00031 
00032   public: //interface
00033 
00040     ROBFragment (const TPointer& it);
00041 
00047     ROBFragment (const ROBFragment& other) 
00048       : Header<TPointer>(other), m_start(other.m_start) {}
00049 
00053     ROBFragment () : Header<TPointer>(), m_start() {}
00054 
00058     virtual ~ROBFragment() {}
00059 
00065     ROBFragment& operator= (const ROBFragment& other)
00066     { Header<TPointer>::operator=(other); m_start=other.m_start; return *this; }
00067 
00073     ROBFragment& assign (const TPointer& it);
00074 
00078     virtual bool check () const;
00079 
00083     inline bool check_tree () const { check(); return true; }
00084 
00088     inline uint32_t rod_marker() const { return m_start[0]; }
00089 
00093     inline uint32_t rod_fragment_size_word() const 
00094     { return this->payload_size_word(); }
00095 
00100     inline uint32_t rod_header_size_word() const { return m_start[1]; }
00101 
00105     inline uint32_t rod_trailer_size_word() const { return 3; }
00106 
00110     inline uint32_t rod_version() const { return m_start[2]; }
00111 
00115     inline uint32_t rod_source_id() const { return m_start[3]; }
00116 
00120     inline uint32_t rod_run_no() const { return m_start[4]; }
00121 
00125     inline uint32_t rod_lvl1_id() const { return m_start[5]; }
00126 
00130     inline uint32_t rod_bc_id() const { return m_start[6]; }
00131 
00135     inline uint32_t rod_lvl1_trigger_type() const { return m_start[7]; }
00136 
00140     inline uint32_t rod_detev_type() const { return m_start[8]; }
00141 
00145     inline uint32_t rod_nstatus () const
00146     { return m_start[this->payload_size_word()-3]; }
00147     
00154     void rod_status (TPointer& it) const;
00155 
00159     inline uint32_t rod_ndata () const 
00160     { return m_start[this->payload_size_word()-2]; }
00161 
00167     void rod_data (TPointer& it) const;
00168 
00174     inline uint32_t rod_status_position () const 
00175     { return m_start[this->payload_size_word()-1]; }
00176 
00177   private: //static stuff
00178 
00179     static const uint32_t NSPECIFIC;
00180 
00181   private: //representation
00182 
00183     TPointer m_start; 
00184 
00185   };
00186 
00187 }
00188 
00189 template <class TPointer>
00190 const uint32_t eformat::ROBFragment<TPointer>::NSPECIFIC = 0;
00191 
00192 template <class TPointer>
00193 eformat::ROBFragment<TPointer>::ROBFragment (const TPointer& it)
00194   : eformat::Header<TPointer>(it, eformat::ROB),
00195     m_start()
00196 {
00197   ERS_DEBUG_3("Building ROBFragment from pointer");
00198   specific_header(m_start);
00199   ERS_DEBUG_1("Initialized header with source identifier = %s",
00200               eformat::helper::SourceIdentifier(source_id()).human().c_str());
00201   ERS_DEBUG_3("Building underlying RODFragment");
00202   if (rod_marker() != eformat::ROD) 
00203     throw EFORMAT_WRONG_MARKER(rod_marker(), eformat::ROD);
00204   ERS_DEBUG_1("Initialized ROD header with source identifier = %s",
00205               eformat::helper::SourceIdentifier(rod_source_id()).human().c_str());
00206 }
00207 
00208 template <class TPointer> eformat::ROBFragment<TPointer>&
00209 eformat::ROBFragment<TPointer>::assign (const TPointer& it)
00210 {
00211   ERS_DEBUG_3("Re-building ROBFragment from pointer");
00212   eformat::Header<TPointer>::assign(it, eformat::ROB);
00213   specific_header(m_start);
00214   ERS_DEBUG_1("Initialized header with source identifier = %s",
00215               eformat::helper::SourceIdentifier(source_id()).human().c_str());
00216   ERS_DEBUG_3("Re-building underlying RODFragment");
00217   if (rod_marker() != eformat::ROD) 
00218     throw EFORMAT_WRONG_MARKER(rod_marker(), eformat::ROD);
00219   ERS_DEBUG_1("Reinitialized header with source identifier = %s",
00220               eformat::helper::SourceIdentifier(rod_source_id()).human().c_str());
00221   return *this;
00222 }
00223 
00224 template <class TPointer>
00225 bool eformat::ROBFragment<TPointer>::check () const
00226 {
00227   //ROB checking
00228   ERS_DEBUG_2("Checking for consistency of ROBFragment [%s]",
00229               eformat::helper::SourceIdentifier(source_id()).human().c_str());
00230   eformat::Header<TPointer>::check(); //< first do a generic check
00231   if (eformat::Header<TPointer>::nspecific() != NSPECIFIC)
00232     throw EFORMAT_SIZE_CHECK(NSPECIFIC, this->nspecific());
00233 
00234   //ROD checking
00235   ERS_DEBUG_2("Checking for consistency of RODFragment [%s]",
00236               eformat::helper::SourceIdentifier(rod_source_id()).human().c_str());
00237   if ( rod_version() >> 16 != eformat::MAJOR_DEFAULT_VERSION )
00238     throw EFORMAT_BAD_VERSION(rod_version() >> 16,
00239                               eformat::MAJOR_DEFAULT_VERSION);
00240   if ( rod_header_size_word() != 9 )
00241     throw EFORMAT_SIZE_CHECK(9, rod_header_size_word());
00242   if ( rod_fragment_size_word() != 12 + rod_nstatus() + rod_ndata() )
00243     throw EFORMAT_SIZE_CHECK(rod_fragment_size_word(), 
00244                              (12 + rod_nstatus() + rod_ndata()));
00245   return true;
00246 }
00247 
00248 template <class TPointer>
00249 void eformat::ROBFragment<TPointer>::rod_status (TPointer& it) const
00250 {
00251   it = m_start;
00252   it += 9;
00253   if (rod_status_position()) it += rod_ndata();
00254 }
00255 
00256 template <class TPointer> 
00257 void eformat::ROBFragment<TPointer>::rod_data (TPointer& it) const
00258 {
00259   it = m_start;
00260   it += 9;
00261   if (!rod_status_position()) it += rod_nstatus();
00262 }
00263 
00264 #endif /* EFORMAT_ROBFRAGMENT_H */

Generated on Tue Nov 29 22:58:25 2016 for BOSS_7.0.2 by  doxygen 1.4.7