Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

eformat::Header< TPointer > Class Template Reference

#include <Header.h>

Inheritance diagram for eformat::Header< TPointer >:

eformat::FullEventFragment< TPointer > eformat::FullEventFragment< TPointer > eformat::ROBFragment< TPointer > eformat::ROBFragment< TPointer > eformat::ROSFragment< TPointer > eformat::ROSFragment< TPointer > eformat::SubDetectorFragment< TPointer > eformat::SubDetectorFragment< TPointer > List of all members.

Public Member Functions

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

Private Attributes

TPointer m_start
 my start word

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.


Constructor & Destructor Documentation

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:
it The exact position where this header should start.
match The word that this header should match.
00225   : m_start(it)
00226 {
00227   ERS_DEBUG_3("Building header 0x%x from iterator", match);
00228   if (marker() != match) {
00229     throw EFORMAT_WRONG_MARKER(marker(), match);
00230   }
00231   ERS_DEBUG_1("Initialized header with source identifier = %s",
00232               eformat::helper::SourceIdentifier(match).human().c_str());
00233 }

template<class TPointer>
eformat::Header< TPointer >::Header  )  [inline]
 

Builds an empty, otherwise useless Header

00056 : m_start() {}

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

Copy constructor

Parameters:
other The other header to construct from
00063 : m_start(other.m_start) {}

template<class TPointer>
virtual eformat::Header< TPointer >::~Header  )  [inline, virtual]
 

Destructor virtualisation

00068 {}

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:
it The exact position where this header should start.
match The word that this header should match.

template<class TPointer>
eformat::Header< TPointer >::Header  )  [inline]
 

Builds an empty, otherwise useless Header

00056 : m_start() {}

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

Copy constructor

Parameters:
other The other header to construct from
00063 : m_start(other.m_start) {}

template<class TPointer>
virtual eformat::Header< TPointer >::~Header  )  [inline, virtual]
 

Destructor virtualisation

00068 {}


Member Function Documentation

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

Reassign this header

Parameters:
it The exact position where this header should start.
match The word that this header should match.

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

Reassign this header

Parameters:
it The exact position where this header should start.
match The word that this header should match.
00237 {
00238   ERS_DEBUG_3("Rebuilding header 0x%x from iterator", match);
00239   m_start = it;
00240   if (marker() != match) {
00241     throw EFORMAT_WRONG_MARKER(marker(), match);
00242   }
00243   ERS_DEBUG_1("Re-initialized header with source identifier = %s",
00244               eformat::helper::SourceIdentifier(match).human().c_str());
00245   return *this;
00246 }

template<class TPointer>
virtual bool eformat::Header< TPointer >::check  )  const [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 >.

template<class TPointer>
bool eformat::Header< TPointer >::check  )  const [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 >.

00250 {
00251   ERS_DEBUG_2("Checking for consistency of fragment of type %s [%s]",
00252               eformat::marker2string(marker()).c_str(),
00253               eformat::helper::SourceIdentifier(source_id()).human().c_str());
00254   if ( version() >> 16 != eformat::MAJOR_DEFAULT_VERSION )
00255     throw EFORMAT_BAD_VERSION(version() >> 16, eformat::MAJOR_DEFAULT_VERSION);
00256   if ( header_size_word() != (7 + nstatus() + nspecific()) )
00257     throw EFORMAT_SIZE_CHECK(header_size_word(),
00258                              (7 + nstatus() + nspecific()));
00259   return true;
00260 }

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:
p A preallocated pointer you should provide.
n The fragment position, starting at zero, of the child fragment you would like to get.

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:
p A preallocated pointer you should provide.
n The fragment position, starting at zero, of the child fragment you would like to get.
00273 {
00274   ERS_DEBUG_2("User asked for child %ud of fragment type %s [%s]", n,
00275               eformat::marker2string(marker()).c_str(),
00276               eformat::helper::SourceIdentifier(source_id()).human().c_str());
00277   TPointer next;
00278   payload(next);
00279   for (size_t i=0; i<n; ++i) next += next[1];
00280   ERS_DEBUG_3("Set user object");
00281   p = next;
00282 }

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:
p A preallocated pointer you should provide.
n The fragment position, starting at zero, of the child fragment you would like to get.

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:
p A preallocated pointer you should provide.
n The fragment position, starting at zero, of the child fragment you would like to get.
00286 {
00287   uint32_t total = nchildren();
00288   if (n >= total) throw EFORMAT_NO_SUCH_CHILD(n, total);
00289   child(p, n);
00290 }

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:
p A pointer to a set of preallocated TPointer's to set to the position of the children of this fragment.
max The maximum number of children, p can point to.
Returns:
The number of children found on this fragment

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:
p A pointer to a set of preallocated TPointer's to set to the position of the children of this fragment.
max The maximum number of children, p can point to.
Returns:
The number of children found on this fragment
00294 {
00295   ERS_DEBUG_2("Retrieving all children...");
00296   TPointer payload_start;
00297   payload(payload_start);
00298   try {
00299     return find_fragments(child_marker(static_cast<HeaderMarker>(marker())),
00300                           payload_start, payload_size_word(), p, max);
00301   }
00302   catch (WrongMarkerIssue& ex) {
00303     //This normally means the fragment size is wrong...
00304     throw EFORMAT_WRONG_SIZE(fragment_size_word());
00305   }
00306   return 0;
00307 }

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

Sets the pointer to one-past my end position

Parameters:
it The pointer to set
00144     { it = m_start; it += fragment_size_word(); }

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

Sets the pointer to one-past my end position

Parameters:
it The pointer to set
00144     { it = m_start; it += 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.

00100 { return m_start[1]; }

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

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

00100 { return m_start[1]; }

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.

00106 { return m_start[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.

00106 { return m_start[2]; }

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

Returns the fragment type.

00095 { return m_start[0]; }

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

Returns the fragment type.

00095 { return m_start[0]; }

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

Returns the number of children available.

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

Returns the number of children available.

00264 {
00265   ERS_DEBUG_2("User asked for number of children of fragment type %s [%s]",
00266               eformat::marker2string(marker()).c_str(),
00267               eformat::helper::SourceIdentifier(source_id()).human().c_str());
00268   return children(0,0);
00269 }

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

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

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

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

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

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

template<class TPointer>
uint32_t eformat::Header< TPointer >::nstatus void   )  const [inline]
 

Returns the number of status words available

00121 { return m_start[5]; }

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

Returns the number of status words available

00121 { return m_start[5]; }

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

Assigment operator

Parameters:
other The other header to assign from
00076     { m_start = other.m_start; return *this; }

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

Assigment operator

Parameters:
other The other header to assign from
00076     { m_start = other.m_start; return *this; }

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

Sets the pointer to where the payload starts

Parameters:
it The pointer to set
00136     { it = m_start; it+= header_size_word(); }

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

Sets the pointer to where the payload starts

Parameters:
it The pointer to set
00136     { it = m_start; it+= header_size_word(); }

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

Returns the payload size

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

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

Returns the payload size

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

template<class TPointer>
uint32_t eformat::Header< TPointer >::source_id void   )  const [inline]
 

Returns the full source identifier.

00116 { return m_start[4]; }

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

Returns the full source identifier.

00116 { return m_start[4]; }

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:
it An updateable iterator you should provide.
00173     { it = m_start; it += 7 + nstatus(); }

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:
it An updateable iterator you should provide.
00173     { it = m_start; it += 7 + nstatus(); }

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

Sets the pointer to my start

Parameters:
it The pointer to set
00128 { it = m_start; }

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

Sets the pointer to my start

Parameters:
it The pointer to set
00128 { it = m_start; }

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:
it An updateable iterator you should provide.
00157 { it = m_start; it += 6; }

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:
it An updateable iterator you should provide.
00157 { it = m_start; it += 6; }

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

Returns the formatting version.

00111 { return m_start[3]; }

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

Returns the formatting version.

00111 { return m_start[3]; }


Member Data Documentation

template<class TPointer>
TPointer eformat::Header< TPointer >::m_start [private]
 

my start word

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


The documentation for this class was generated from the following files:
Generated on Wed Feb 2 19:17:42 2011 for BOSS6.5.5 by  doxygen 1.3.9.1