BOSS 7.0.2
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
 
 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 Event/eformat/eformat-00-00-04/eformat/Header.h.

Constructor & Destructor Documentation

◆ Header() [1/6]

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 Event/eformat/eformat-00-00-04/eformat/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 EFORMAT_WRONG_MARKER(current, expected)
char * c_str(Index i)
Definition: EvtCyclic3.cc:252

◆ Header() [2/6]

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

Builds an empty, otherwise useless Header

Definition at line 56 of file Event/eformat/eformat-00-00-04/eformat/Header.h.

56: m_start() {}

◆ Header() [3/6]

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 Event/eformat/eformat-00-00-04/eformat/Header.h.

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

◆ ~Header() [1/2]

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

Destructor virtualisation

Definition at line 68 of file Event/eformat/eformat-00-00-04/eformat/Header.h.

68{}

◆ Header() [4/6]

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.

◆ Header() [5/6]

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

Builds an empty, otherwise useless Header

Definition at line 56 of file InstallArea/include/eformat/eformat/Header.h.

56: m_start() {}

◆ Header() [6/6]

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 InstallArea/include/eformat/eformat/Header.h.

63: m_start(other.m_start) {}

◆ ~Header() [2/2]

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

Destructor virtualisation

Definition at line 68 of file InstallArea/include/eformat/eformat/Header.h.

68{}

Member Function Documentation

◆ assign() [1/2]

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 Event/eformat/eformat-00-00-04/eformat/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().

◆ assign() [2/2]

template<class TPointer >
Header & 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.

◆ check() [1/2]

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 >, eformat::SubDetectorFragment< TPointer >, eformat::FullEventFragment< TPointer >, eformat::ROBFragment< TPointer >, eformat::ROSFragment< TPointer >, and eformat::SubDetectorFragment< TPointer >.

Definition at line 249 of file Event/eformat/eformat-00-00-04/eformat/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)
std::string marker2string(const eformat::HeaderMarker &e)

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

◆ check() [2/2]

◆ child() [1/2]

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 Event/eformat/eformat-00-00-04/eformat/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
Index next(Index i)
Definition: EvtCyclic3.cc:107

◆ child() [2/2]

template<class TPointer >
virtual 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.

◆ child_check() [1/2]

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 Event/eformat/eformat-00-00-04/eformat/Header.h.

286{
287 uint32_t total = nchildren();
288 if (n >= total) throw EFORMAT_NO_SUCH_CHILD(n, total);
289 child(p, n);
290}
virtual void child(TPointer &p, size_t n) const

◆ child_check() [2/2]

template<class TPointer >
virtual 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.

◆ children() [1/2]

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 Event/eformat/eformat-00-00-04/eformat/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}
size_t find_fragments(eformat::HeaderMarker marker, TPointer block_start, size_t block_size, TPointer *frag=0, size_t max_count=0)
HeaderMarker child_marker(HeaderMarker e)

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

◆ children() [2/2]

template<class TPointer >
virtual 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

◆ end() [1/2]

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 Event/eformat/eformat-00-00-04/eformat/Header.h.

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

◆ end() [2/2]

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 InstallArea/include/eformat/eformat/Header.h.

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

◆ fragment_size_word() [1/2]

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 Event/eformat/eformat-00-00-04/eformat/Header.h.

100{ return m_start[1]; }

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

◆ fragment_size_word() [2/2]

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 InstallArea/include/eformat/eformat/Header.h.

100{ return m_start[1]; }

◆ header_size_word() [1/2]

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 Event/eformat/eformat-00-00-04/eformat/Header.h.

106{ return m_start[2]; }

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

◆ header_size_word() [2/2]

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 InstallArea/include/eformat/eformat/Header.h.

106{ return m_start[2]; }

◆ marker() [1/2]

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

Returns the fragment type.

Definition at line 95 of file Event/eformat/eformat-00-00-04/eformat/Header.h.

95{ return m_start[0]; }

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

◆ marker() [2/2]

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

Returns the fragment type.

Definition at line 95 of file InstallArea/include/eformat/eformat/Header.h.

95{ return m_start[0]; }

◆ nchildren() [1/2]

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

Returns the number of children available.

Definition at line 263 of file Event/eformat/eformat-00-00-04/eformat/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

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

◆ nchildren() [2/2]

template<class TPointer >
virtual uint32_t eformat::Header< TPointer >::nchildren ( ) const
virtual

Returns the number of children available.

◆ nspecific() [1/2]

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 Event/eformat/eformat-00-00-04/eformat/Header.h.

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

Referenced by RawDataInputSvc::nextEvent().

◆ nspecific() [2/2]

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 InstallArea/include/eformat/eformat/Header.h.

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

◆ nstatus() [1/2]

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

Returns the number of status words available

Definition at line 121 of file Event/eformat/eformat-00-00-04/eformat/Header.h.

121{ return m_start[5]; }

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

◆ nstatus() [2/2]

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

Returns the number of status words available

Definition at line 121 of file InstallArea/include/eformat/eformat/Header.h.

121{ return m_start[5]; }

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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 InstallArea/include/eformat/eformat/Header.h.

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

◆ payload() [1/2]

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 Event/eformat/eformat-00-00-04/eformat/Header.h.

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

◆ payload() [2/2]

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 InstallArea/include/eformat/eformat/Header.h.

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

◆ payload_size_word() [1/2]

◆ payload_size_word() [2/2]

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

Returns the payload size

Definition at line 149 of file InstallArea/include/eformat/eformat/Header.h.

150 { return fragment_size_word() - header_size_word(); }

◆ source_id() [1/2]

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

Returns the full source identifier.

Definition at line 116 of file Event/eformat/eformat-00-00-04/eformat/Header.h.

116{ return m_start[4]; }

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

◆ source_id() [2/2]

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

Returns the full source identifier.

Definition at line 116 of file InstallArea/include/eformat/eformat/Header.h.

116{ return m_start[4]; }

◆ specific_header() [1/2]

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 Event/eformat/eformat-00-00-04/eformat/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().

◆ specific_header() [2/2]

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 InstallArea/include/eformat/eformat/Header.h.

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

◆ start() [1/2]

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 Event/eformat/eformat-00-00-04/eformat/Header.h.

128{ it = m_start; }

◆ start() [2/2]

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 InstallArea/include/eformat/eformat/Header.h.

128{ it = m_start; }

◆ status() [1/2]

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 Event/eformat/eformat-00-00-04/eformat/Header.h.

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

◆ status() [2/2]

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 InstallArea/include/eformat/eformat/Header.h.

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

◆ version() [1/2]

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

Returns the formatting version.

Definition at line 111 of file Event/eformat/eformat-00-00-04/eformat/Header.h.

111{ return m_start[3]; }

◆ version() [2/2]

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

Returns the formatting version.

Definition at line 111 of file InstallArea/include/eformat/eformat/Header.h.

111{ return m_start[3]; }

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