CGEM BOSS 6.6.5.g
BESIII Offline Software System
Loading...
Searching...
No Matches
eformat::Header< TPointer > Class Template Reference

#include <Header.h>

+ Inheritance diagram for eformat::Header< TPointer >:

Public Member Functions

 Header (const TPointer &it, uint32_t match)
 
 Header ()
 
 Header (const Header &other)
 
virtual ~Header ()
 
Headeroperator= (const Header &other)
 
Headerassign (const TPointer &it, uint32_t match)
 
virtual bool check () const
 
uint32_t marker () const
 
uint32_t fragment_size_word () const
 
uint32_t header_size_word () const
 
uint32_t version () const
 
uint32_t source_id () const
 
uint32_t nstatus () const
 
void start (TPointer &it) const
 
void payload (TPointer &it) const
 
void end (TPointer &it) const
 
uint32_t payload_size_word (void) const
 
void status (TPointer &it) const
 
uint32_t nspecific () const
 
void specific_header (TPointer &it) const
 
virtual uint32_t nchildren () const
 
virtual void child (TPointer &p, size_t n) const
 
virtual void child_check (TPointer &p, size_t n) const
 
virtual uint32_t children (TPointer *p, size_t max) const
 

Detailed Description

template<class TPointer>
class eformat::Header< TPointer >

Contains the information on the Header of a fragment as described by the original note. The header is a composite entity, build from two parts:

  1. The generic part, containing the header type, size and version information;
  2. The specific part, containing data that is specific for a particular fragment.

Definition at line 40 of file Header.h.

Constructor & Destructor Documentation

◆ Header() [1/3]

template<class TPointer >
eformat::Header< TPointer >::Header ( const TPointer &  it,
uint32_t  match 
)

To build a header given the containing buffer. I need to know where the header starts in order to do that.

Parameters
itThe exact position where this header should start.
matchThe word that this header should match.

Definition at line 224 of file Header.h.

225 : m_start(it)
226{
227 ERS_DEBUG_3("Building header 0x%x from iterator", match);
228 if (marker() != match) {
229 throw EFORMAT_WRONG_MARKER(marker(), match);
230 }
231 ERS_DEBUG_1("Initialized header with source identifier = %s",
233}
#define ERS_DEBUG_1(...)
#define ERS_DEBUG_3(...)
#define EFORMAT_WRONG_MARKER(current, expected)
uint32_t marker() const
Definition: Header.h:95
char * c_str(Index i)
Definition: EvtCyclic3.cc:252

◆ Header() [2/3]

template<class TPointer >
eformat::Header< TPointer >::Header ( )
inline

Builds an empty, otherwise useless Header

Definition at line 56 of file Header.h.

56: m_start() {}

◆ Header() [3/3]

template<class TPointer >
eformat::Header< TPointer >::Header ( const Header< TPointer > &  other)
inline

Copy constructor

Parameters
otherThe other header to construct from

Definition at line 63 of file Header.h.

63: m_start(other.m_start) {}
Index other(Index i, Index j)
Definition: EvtCyclic3.cc:118

◆ ~Header()

template<class TPointer >
virtual eformat::Header< TPointer >::~Header ( )
inlinevirtual

Destructor virtualisation

Definition at line 68 of file Header.h.

68{}

Member Function Documentation

◆ assign()

template<class TPointer >
eformat::Header< TPointer > & eformat::Header< TPointer >::assign ( const TPointer &  it,
uint32_t  match 
)

Reassign this header

Parameters
itThe exact position where this header should start.
matchThe word that this header should match.

Definition at line 236 of file Header.h.

237{
238 ERS_DEBUG_3("Rebuilding header 0x%x from iterator", match);
239 m_start = it;
240 if (marker() != match) {
241 throw EFORMAT_WRONG_MARKER(marker(), match);
242 }
243 ERS_DEBUG_1("Re-initialized header with source identifier = %s",
245 return *this;
246}

Referenced by eformat::FullEventFragment< TPointer >::assign(), eformat::ROBFragment< TPointer >::assign(), eformat::ROSFragment< TPointer >::assign(), and eformat::SubDetectorFragment< TPointer >::assign().

◆ check()

template<class TPointer >
bool eformat::Header< TPointer >::check
virtual

Says if the generic part of the header is valid. This may throw exceptions.

Reimplemented in eformat::FullEventFragment< TPointer >, eformat::ROBFragment< TPointer >, eformat::ROSFragment< TPointer >, and eformat::SubDetectorFragment< TPointer >.

Definition at line 249 of file Header.h.

250{
251 ERS_DEBUG_2("Checking for consistency of fragment of type %s [%s]",
256 if ( header_size_word() != (7 + nstatus() + nspecific()) )
258 (7 + nstatus() + nspecific()));
259 return true;
260}
#define EFORMAT_BAD_VERSION(current, supported)
#define EFORMAT_SIZE_CHECK(actual, informed)
#define ERS_DEBUG_2(...)
uint32_t source_id() const
Definition: Header.h:116
uint32_t nspecific() const
Definition: Header.h:164
uint32_t nstatus() const
Definition: Header.h:121
uint32_t version() const
Definition: Header.h:111
uint32_t header_size_word() const
Definition: Header.h:106
std::string marker2string(const eformat::HeaderMarker &e)
const uint16_t MAJOR_DEFAULT_VERSION
Definition: Version.h:29

Referenced by eformat::FullEventFragment< TPointer >::check(), eformat::ROBFragment< TPointer >::check(), eformat::ROSFragment< TPointer >::check(), and eformat::SubDetectorFragment< TPointer >::check().

◆ child()

template<class TPointer >
void eformat::Header< TPointer >::child ( TPointer &  p,
size_t  n 
) const
virtual

Returns the nth child fragment. If the nth fragment doesn't exist, the behaviour is undefined.

Parameters
pA preallocated pointer you should provide.
nThe fragment position, starting at zero, of the child fragment you would like to get.

Definition at line 272 of file Header.h.

273{
274 ERS_DEBUG_2("User asked for child %ud of fragment type %s [%s]", n,
277 TPointer next;
278 payload(next);
279 for (size_t i=0; i<n; ++i) next += next[1];
280 ERS_DEBUG_3("Set user object");
281 p = next;
282}
const Int_t n
void payload(TPointer &it) const
Definition: Header.h:135
Index next(Index i)
Definition: EvtCyclic3.cc:107

◆ child_check()

template<class TPointer >
void eformat::Header< TPointer >::child_check ( TPointer &  p,
size_t  n 
) const
virtual

Returns the nth child fragment. If the nth fragment doesn't exist, an exception is thrown.

Warning
Use this method with care, it is slower than the equivalent method that doesn't check.
Parameters
pA preallocated pointer you should provide.
nThe fragment position, starting at zero, of the child fragment you would like to get.

Definition at line 285 of file Header.h.

286{
287 uint32_t total = nchildren();
288 if (n >= total) throw EFORMAT_NO_SUCH_CHILD(n, total);
289 child(p, n);
290}
#define EFORMAT_NO_SUCH_CHILD(req, total)
virtual uint32_t nchildren() const
Definition: Header.h:263
virtual void child(TPointer &p, size_t n) const
Definition: Header.h:272

◆ children()

template<class TPointer >
uint32_t eformat::Header< TPointer >::children ( TPointer *  p,
size_t  max 
) const
virtual

Returns all the children of this fragment. The input to this method is a valid set of iterators to existing, pre-allocated pointers

Parameters
pA pointer to a set of preallocated TPointer's to set to the position of the children of this fragment.
maxThe maximum number of children, p can point to.
Returns
The number of children found on this fragment

Definition at line 293 of file Header.h.

294{
295 ERS_DEBUG_2("Retrieving all children...");
296 TPointer payload_start;
297 payload(payload_start);
298 try {
299 return find_fragments(child_marker(static_cast<HeaderMarker>(marker())),
300 payload_start, payload_size_word(), p, max);
301 }
302 catch (WrongMarkerIssue& ex) {
303 //This normally means the fragment size is wrong...
305 }
306 return 0;
307}
#define EFORMAT_WRONG_SIZE(size)
uint32_t payload_size_word(void) const
Definition: Header.h:149
uint32_t fragment_size_word() const
Definition: Header.h:100
size_t find_fragments(eformat::HeaderMarker marker, TPointer block_start, size_t block_size, TPointer *frag=0, size_t max_count=0)
Definition: util.h:111
HeaderMarker child_marker(HeaderMarker e)

Referenced by components(), eformat::get_robs(), main(), and RawDataInputSvc::nextEvent().

◆ end()

template<class TPointer >
void eformat::Header< TPointer >::end ( TPointer &  it) const
inline

Sets the pointer to one-past my end position

Parameters
itThe pointer to set

Definition at line 143 of file Header.h.

144 { it = m_start; it += fragment_size_word(); }

◆ fragment_size_word()

template<class TPointer >
uint32_t eformat::Header< TPointer >::fragment_size_word ( ) const
inline

Returns the size, in words, of the current fragment.

Definition at line 100 of file Header.h.

100{ return m_start[1]; }

Referenced by eformat::Header< TPointer >::end(), EFEventLoopMgr::executeEvent(), MixerAlg::nextEvent(), and eformat::Header< TPointer >::payload_size_word().

◆ header_size_word()

template<class TPointer >
uint32_t eformat::Header< TPointer >::header_size_word ( ) const
inline

Returns the size, in words, of the current header. That does include the specific part of the header.

Definition at line 106 of file Header.h.

106{ return m_start[2]; }

Referenced by eformat::Header< TPointer >::payload(), and eformat::Header< TPointer >::payload_size_word().

◆ marker()

template<class TPointer >
uint32_t eformat::Header< TPointer >::marker ( ) const
inline

Returns the fragment type.

Definition at line 95 of file Header.h.

95{ return m_start[0]; }

Referenced by eformat::Header< TPointer >::Header().

◆ nchildren()

template<class TPointer >
uint32_t eformat::Header< TPointer >::nchildren
virtual

Returns the number of children available.

Definition at line 263 of file Header.h.

264{
265 ERS_DEBUG_2("User asked for number of children of fragment type %s [%s]",
268 return children(0,0);
269}
virtual uint32_t children(TPointer *p, size_t max) const
Definition: Header.h:293

Referenced by components(), EFEventLoopMgr::executeEvent(), and MixerAlg::nextEvent().

◆ nspecific()

template<class TPointer >
uint32_t eformat::Header< TPointer >::nspecific ( ) const
inline

Returns the number of specific words available in the specific header part

Definition at line 164 of file Header.h.

164{ return m_start[6 + nstatus()]; }

Referenced by RawDataInputSvc::nextEvent().

◆ nstatus()

template<class TPointer >
uint32_t eformat::Header< TPointer >::nstatus ( ) const
inline

Returns the number of status words available

Definition at line 121 of file Header.h.

121{ return m_start[5]; }

Referenced by eformat::Header< TPointer >::nspecific(), and eformat::Header< TPointer >::specific_header().

◆ operator=()

template<class TPointer >
Header & eformat::Header< TPointer >::operator= ( const Header< TPointer > &  other)
inline

Assigment operator

Parameters
otherThe other header to assign from

Definition at line 75 of file Header.h.

76 { m_start = other.m_start; return *this; }

Referenced by eformat::FullEventFragment< TPointer >::operator=(), eformat::ROBFragment< TPointer >::operator=(), eformat::ROSFragment< TPointer >::operator=(), and eformat::SubDetectorFragment< TPointer >::operator=().

◆ payload()

template<class TPointer >
void eformat::Header< TPointer >::payload ( TPointer &  it) const
inline

Sets the pointer to where the payload starts

Parameters
itThe pointer to set

Definition at line 135 of file Header.h.

136 { it = m_start; it+= header_size_word(); }

◆ payload_size_word()

template<class TPointer >
uint32_t eformat::Header< TPointer >::payload_size_word ( void  ) const
inline

◆ source_id()

template<class TPointer >
uint32_t eformat::Header< TPointer >::source_id ( ) const
inline

Returns the full source identifier.

Definition at line 116 of file Header.h.

116{ return m_start[4]; }

Referenced by eformat::get_robs(), RawDataInputSvc::nextEvent(), and eformat::ROBFragment< TPointer >::ROBFragment().

◆ specific_header()

template<class TPointer >
void eformat::Header< TPointer >::specific_header ( TPointer &  it) const
inline

Returns an iterator to the start of the specific header part (this does not include the number of specific header fragments)

Parameters
itAn updateable iterator you should provide.

Definition at line 172 of file Header.h.

173 { it = m_start; it += 7 + nstatus(); }

Referenced by eformat::FullEventFragment< TPointer >::FullEventFragment(), RawDataInputSvc::nextEvent(), eformat::ROBFragment< TPointer >::ROBFragment(), eformat::ROSFragment< TPointer >::ROSFragment(), and eformat::SubDetectorFragment< TPointer >::SubDetectorFragment().

◆ start()

template<class TPointer >
void eformat::Header< TPointer >::start ( TPointer &  it) const
inline

Sets the pointer to my start

Parameters
itThe pointer to set

Definition at line 128 of file Header.h.

128{ it = m_start; }

◆ status()

template<class TPointer >
void eformat::Header< TPointer >::status ( TPointer &  it) const
inline

Returns the status words, as an iterator to the status words available.

Parameters
itAn updateable iterator you should provide.

Definition at line 157 of file Header.h.

157{ it = m_start; it += 6; }

◆ version()

template<class TPointer >
uint32_t eformat::Header< TPointer >::version ( ) const
inline

Returns the formatting version.

Definition at line 111 of file Header.h.

111{ return m_start[3]; }

The documentation for this class was generated from the following file: