eformat::write::ROSFragment Class Reference

forward More...

#include <ROSFragment.h>

List of all members.

Public Member Functions

 ROSFragment (uint32_t source_id, uint32_t run_no, uint32_t lvl1_id, uint32_t bc_id)
 ROSFragment (uint32_t *ros)
 ROSFragment (eformat::write::node_t *ros)
 ROSFragment ()
 ROSFragment (const ROSFragment &other)
virtual ~ROSFragment ()
ROSFragmentoperator= (const ROSFragment &other)
void status (uint32_t n, const uint32_t *status)
uint32_t nstatus (void) const
const uint32_t * status (void) const
void minor_version (uint16_t v)
uint16_t minor_version (void) const
void source_id (uint32_t s)
uint32_t source_id (void) const
void run_no (uint32_t s)
uint32_t run_no (void) const
void lvl1_id (uint32_t s)
uint32_t lvl1_id (void) const
void bc_id (uint32_t s)
uint32_t bc_id (void) const
uint32_t meta_size_word (void) const
uint32_t size_word (void) const
void append (eformat::write::ROBFragment *rob)
const ROBFragmentfirst_child (void) const
void size_change (uint32_t o, uint32_t n)
const SubDetectorFragmentparent (void) const
void parent (eformat::write::SubDetectorFragment *sd)
const ROSFragmentnext (void) const
void next (const ROSFragment *n)
uint32_t page_count (void) const
const eformat::write::node_tbind (void)
const eformat::write::node_textra (void)

Private Attributes

uint32_t m_header [10]
 The ROS Header.
eformat::write::node_t m_node [3]
 Node representation.
eformat::write::SubDetectorFragmentm_parent
 my parent
eformat::write::ROBFragmentm_child
 my ROB children
eformat::write::ROBFragmentm_last
 my last ROB child
const eformat::write::ROSFragmentm_next
 Next sibling.
eformat::write::node_t m_extra
 Extra pages I may have.
uint32_t m_extra_count
 How many extra pages I have.


Detailed Description

forward

Defines a helper class to aid the creation of ROS fragments.

Definition at line 27 of file ROSFragment.h.


Constructor & Destructor Documentation

eformat::write::ROSFragment::ROSFragment ( uint32_t  source_id,
uint32_t  run_no,
uint32_t  lvl1_id,
uint32_t  bc_id 
)

Builds a new ROS fragment from scratch

Parameters:
source_id The source identifier to be using for this ROS
run_no The run number for this ROS
lvl1_id The LVL1 identifier for this ROS
bc_id The bunch crossing identifier for this ROS

Definition at line 20 of file ROSFragment.cxx.

References eformat::DEFAULT_STATUS, eformat::DEFAULT_VERSION, ERS_DEBUG_3, eformat::ROS, and eformat::write::set().

00021   : m_parent(0),
00022     m_child(0),
00023     m_last(0),
00024     m_next(0),
00025     m_extra_count(0)
00026 {
00027   m_header[0] = eformat::ROS; //marker
00028   m_header[1] = 11; //this header size + status size
00029   m_header[2] = 11; //this header size + status size
00030   m_header[3] = eformat::DEFAULT_VERSION; //format version
00031   m_header[4] = source_id;
00032   m_header[5] = 1; //number of status
00033   m_header[6] = 3; //number of fragment specific
00034   m_header[7] = run_no;
00035   m_header[8] = lvl1_id;
00036   m_header[9] = bc_id;
00037 
00038   //now initialize pages
00039   set(m_node[0], m_header, 6, &m_node[1]);
00040   set(m_node[1], &eformat::DEFAULT_STATUS, 1, &m_node[2]);
00041   set(m_node[2], &m_header[6], 4, 0);
00042   ERS_DEBUG_3("%s Source Id. = 0x%x., LVL1 Id. = %d, Run Number = %d", 
00043               "Built (write) ros fragment from scratch, with", 
00044               ROSFragment::source_id(), ROSFragment::lvl1_id(), 
00045               ROSFragment::run_no());
00046 }

eformat::write::ROSFragment::ROSFragment ( uint32_t *  ros  ) 

Builds a new ROS fragment from an existing ROS fragment in contiguous memory.

Parameters:
ros The existing ROS fragment

Definition at line 48 of file ROSFragment.cxx.

References ERS_DEBUG_3, lvl1_id(), m_extra, m_extra_count, m_node, run_no(), eformat::write::set(), and source_id().

00049   : m_parent(0),
00050     m_child(0),
00051     m_last(0),
00052     m_next(0),
00053     m_extra_count(0)
00054 {
00055   //now initialize pages
00056   set(m_node[0], ros, 6, &m_node[1]);
00057   set(m_node[1], &ros[6], ros[5], &m_node[2]);
00058   set(m_node[2], &ros[6+ros[5]], 4, &m_extra);
00059   eformat::write::set(m_extra, &ros[10+ros[5]], ros[1]-ros[2]);
00060   ++m_extra_count;
00061   ERS_DEBUG_3("%s Source Id. = 0x%x., LVL1 Id. = %d, Run Number = %d", 
00062               "Built (write) ros fragment from contiguous memory, with", 
00063               source_id(), lvl1_id(), run_no());
00064 }

eformat::write::ROSFragment::ROSFragment ( eformat::write::node_t ros  ) 

Builds a new ROS fragment from an existing ROS fragment in non-contiguous memory. The top-level fragment header is expected to be on a contiguous area of memory, together with the first word of the first child fragment (i.e. the ROB header marker). The following data can be spread around.

Parameters:
ros The existing ROS fragment, as a list of nodes, pre-concatenated by the caller.

Definition at line 66 of file ROSFragment.cxx.

References eformat::write::node_t::base, eformat::write::count(), ERS_DEBUG_3, lvl1_id(), m_extra, m_extra_count, m_node, eformat::write::node_t::next, run_no(), eformat::write::set(), eformat::write::node_t::size_word, and source_id().

00067   : m_parent(0),
00068     m_child(0),
00069     m_last(0),
00070     m_next(0),
00071     m_extra_count(0)
00072 {
00073   //now initialize pages
00074   set(m_node[0], ros->base, 6, &m_node[1]);
00075   set(m_node[1], &ros->base[6], ros->base[5], &m_node[2]);
00076   set(m_node[2], &ros->base[6+ros->base[5]], 4, &m_extra);
00077   eformat::write::set(m_extra, &ros->base[10+ros->base[5]],
00078                       ros->size_word - ros->base[2], ros->next);
00079   m_extra_count += eformat::write::count(m_extra);
00080   ERS_DEBUG_3("%s Source Id. = 0x%x., LVL1 Id. = %d, Run Number = %d", 
00081               "Built (write) ros fragment from paged memory, with", 
00082               source_id(), lvl1_id(), run_no());
00083 }

eformat::write::ROSFragment::ROSFragment (  ) 

Builds a new empty ROS fragment, otherwise invalid. This is useful for array builds and standard containers.

Definition at line 85 of file ROSFragment.cxx.

References eformat::DEFAULT_STATUS, eformat::DEFAULT_VERSION, ERS_DEBUG_3, lvl1_id(), m_header, m_node, eformat::ROS, run_no(), eformat::write::set(), and source_id().

00086   : m_parent(0),
00087     m_child(0),
00088     m_last(0),
00089     m_next(0),
00090     m_extra_count(0)
00091 {
00092   m_header[0] = eformat::ROS; //marker
00093   m_header[1] = 11; //this header size + status size
00094   m_header[2] = 11; //this header size + status size
00095   m_header[3] = eformat::DEFAULT_VERSION; //format version
00096   m_header[4] = 0; //source identifier
00097   m_header[5] = 1; //number of status
00098   m_header[6] = 3; //number of fragment specific
00099   m_header[7] = 0; //run number
00100   m_header[8] = 0; //LVL1 identifier
00101   m_header[9] = 0; //bunch crossing identifier
00102 
00103   //now initialize pages
00104   set(m_node[0], m_header, 6, &m_node[1]);
00105   set(m_node[1], &eformat::DEFAULT_STATUS, 1, &m_node[2]);
00106   set(m_node[2], &m_header[6], 4, 0);
00107   ERS_DEBUG_3("%s Source Id. = 0x%x., LVL1 Id. = %d, Run Number = %d", 
00108               "Built empty (write) ros fragment from scratch, with", 
00109               ROSFragment::source_id(), ROSFragment::lvl1_id(), 
00110               ROSFragment::run_no());
00111 }

eformat::write::ROSFragment::ROSFragment ( const ROSFragment other  ) 

Copy constructor. This will only copy the meta data, not the fragment relationships and block-data (children, parent and status block) contained in the to-be-copied fragment. If you wish this fragment has the same parents, and children of the copied fragment, you have to do this operation manually, after copying. If you wish to make a copy of the status as well, do it manually and then assign it to this fragment using the status() method.

Parameters:
other The other fragment to take the meta data from.

Definition at line 114 of file ROSFragment.cxx.

References ERS_DEBUG_3, lvl1_id(), EvtCyclic3::other(), run_no(), and source_id().

00115   : m_parent(0),
00116     m_child(0),
00117     m_last(0),
00118     m_next(0),
00119     m_extra_count(0)
00120 {
00121   *this = other;
00122   ERS_DEBUG_3("%s Source Id. = 0x%x., LVL1 Id. = %d, Run Number = %d", 
00123               "Built (write) ros fragment from copy, with", 
00124               ROSFragment::source_id(), ROSFragment::lvl1_id(),
00125               ROSFragment::run_no());
00126 }

virtual eformat::write::ROSFragment::~ROSFragment (  )  [inline, virtual]

Base destructor

Definition at line 84 of file ROSFragment.h.

00084 {}


Member Function Documentation

void eformat::write::ROSFragment::append ( eformat::write::ROBFragment rob  ) 

Appends a new ROB fragment to this ROS fragment.

Warning:
This will change the page structure of the last ROB fragment inserted here, in order to concatenate the ROB fragments together. Please note that this operation is not compatible with multiple threads of operation, if you would like to share eformat::write::ROBFragment's between threads. A better strategy would be create, for every thread of operation, a proper ROBFragment instead.
Parameters:
rob The ROB fragment to be appended to myself

Definition at line 169 of file ROSFragment.cxx.

References eformat::write::node_t::base, ERS_DEBUG_3, m_child, m_last, m_node, m_parent, eformat::write::ROBFragment::next(), eformat::write::ROBFragment::parent(), eformat::write::SubDetectorFragment::size_change(), eformat::write::ROBFragment::size_word(), source_id(), and eformat::write::ROBFragment::source_id().

Referenced by Builder::append2event(), and eformat::old::convert().

00170 {
00171   ERS_DEBUG_3("%s Source Id. = 0x%x to ros fragment with Source Id. = 0x%x", 
00172               "Appending rob fragment with",
00173               rob->source_id(), source_id());
00174   rob->parent(this);
00175   uint32_t old_size = m_node[0].base[1];
00176   m_node[0].base[1] += rob->size_word();
00177 
00178   //adjust `m_last' and `m_child' to point to the new last ROB
00179   if (m_last) m_last->next(rob);
00180   else m_child = rob;
00181   m_last = rob;
00182 
00183   //propagate changes to my parent
00184   if (m_parent) m_parent->size_change(old_size, m_node[0].base[1]);
00185 }

uint32_t eformat::write::ROSFragment::bc_id ( void   )  const [inline]

Returns the bunch crossing identifier for this fragment

Definition at line 185 of file ROSFragment.h.

References eformat::write::node_t::base, and m_node.

00186       { return m_node[2].base[3]; }

void eformat::write::ROSFragment::bc_id ( uint32_t  s  )  [inline]

Changes the bunch crossing identifier in this fragment

Parameters:
s The new value to set

Definition at line 179 of file ROSFragment.h.

References eformat::write::node_t::base, and m_node.

00180       { m_node[2].base[3] = s; }

const eformat::write::node_t * eformat::write::ROSFragment::bind ( void   ) 

Returns the first node of a list of nodes that represent the fragment you have constructed. To make use of it, just browse the list as defined in node.h

Definition at line 195 of file ROSFragment.cxx.

References m_child, m_extra, m_extra_count, m_node, eformat::write::ROBFragment::next(), and eformat::write::node_t::next.

00196 {
00197   //the header is already concatenated by construction
00198   eformat::write::node_t* last = &m_node[2];
00199   if (m_extra_count) {
00200     last = &m_extra;
00201     while (last->next) last = last->next;
00202   }
00203   for (const ROBFragment* curr = m_child; curr; curr = curr->next()) {
00204     last->next = const_cast<eformat::write::node_t*>(curr->bind());
00205     while (last->next) last = last->next; //advance until end
00206   }
00207   return m_node;
00208 }

const eformat::write::node_t* eformat::write::ROSFragment::extra ( void   )  [inline]

Return the extra node of the fragment for OHFiller_write. lifei

Definition at line 281 of file ROSFragment.h.

00281 {return & m_extra;};

const ROBFragment* eformat::write::ROSFragment::first_child ( void   )  const [inline]

This returns the first child of this fragment. The system operates as a concatenated list of fragments. From this child you can get to the next.

Definition at line 222 of file ROSFragment.h.

References m_child.

Referenced by PackedRawDataCnvSvc::commitOutput().

00222 { return m_child; }

uint32_t eformat::write::ROSFragment::lvl1_id ( void   )  const [inline]

Returns the lvl1 identifier for this fragment

Definition at line 171 of file ROSFragment.h.

References eformat::write::node_t::base, and m_node.

Referenced by operator=(), and ROSFragment().

00172       { return m_node[2].base[2]; }

void eformat::write::ROSFragment::lvl1_id ( uint32_t  s  )  [inline]

Changes the lvl1 identifier in this fragment

Parameters:
s The new value to set

Definition at line 165 of file ROSFragment.h.

References eformat::write::node_t::base, and m_node.

00166       { m_node[2].base[2] = s; }

uint32_t eformat::write::ROSFragment::meta_size_word ( void   )  const [inline]

Returns the total size for the meta data (everything that does not encompass the contents of the m_data pointer in the private representation of this class) in the fragment, in words

Definition at line 193 of file ROSFragment.h.

References eformat::write::node_t::base, and m_node.

00194       { return m_node[0].base[2]; }

uint16_t eformat::write::ROSFragment::minor_version ( void   )  const [inline]

Returns the minor version number of the fragment

Definition at line 129 of file ROSFragment.h.

References eformat::write::node_t::base, and m_node.

00130       { return 0xffff & m_node[0].base[3]; }

void eformat::write::ROSFragment::minor_version ( uint16_t  v  )  [inline]

Changes the minor version number of the fragment

Parameters:
v The new minor version for this header

Definition at line 123 of file ROSFragment.h.

References eformat::write::node_t::base, eformat::DEFAULT_VERSION, and m_node.

Referenced by eformat::old::convert().

00124       { m_node[0].base[3] = eformat::DEFAULT_VERSION | v; }

void eformat::write::ROSFragment::next ( const ROSFragment n  )  [inline]

Sets the next sibling

Parameters:
n The sibling following this fragment

Definition at line 257 of file ROSFragment.h.

References m_next.

00257 { m_next = n; }

const ROSFragment* eformat::write::ROSFragment::next ( void   )  const [inline]

Returns the next sibling

Definition at line 250 of file ROSFragment.h.

References m_next.

Referenced by PackedRawDataCnvSvc::commitOutput(), and eformat::write::SubDetectorFragment::page_count().

00250 { return m_next; }

uint32_t eformat::write::ROSFragment::nstatus ( void   )  const [inline]

Returns the number of status wors in this fragment

Definition at line 111 of file ROSFragment.h.

References eformat::write::node_t::base, and m_node.

00111 { return m_node[0].base[5]; }

eformat::write::ROSFragment & eformat::write::ROSFragment::operator= ( const ROSFragment other  ) 

Assigment operator. This will only copy the meta data, not the fragment relationships and block-data (children and parent and status block) contained in the to-be-copied fragment. If you wish this fragment has the same parents, and children of the copied fragment, you have to do this operation manually, after copying. If you wish to make a copy of the status as well, do it manually and then assign it to this fragment using the status() method.

Parameters:
other The other fragment to take the meta data from.

Definition at line 129 of file ROSFragment.cxx.

References ERS_DEBUG_3, lvl1_id(), EvtCyclic3::other(), run_no(), eformat::write::set(), and source_id().

00130 {
00131   memcpy(reinterpret_cast<void*>(m_header),
00132          reinterpret_cast<const void*>(other.m_node[0].base), 
00133          6*sizeof(uint32_t));
00134   memcpy(reinterpret_cast<void*>(m_header+6),
00135          reinterpret_cast<const void*>(other.m_node[2].base),
00136          4*sizeof(uint32_t));
00137 
00138   //now initialize pages
00139   set(m_node[0], m_header, 6, &m_node[1]);
00140   set(m_node[1], other.m_node[1].base, other.m_node[1].size_word, &m_node[2]);
00141   set(m_node[2], &m_header[6], 4, 0);
00142   ERS_DEBUG_3("%s Source Id. = 0x%x., LVL1 Id. = %d, Run Number = %d", 
00143               "Copied (write) ros fragment, with", 
00144               ROSFragment::source_id(), ROSFragment::lvl1_id(),
00145               ROSFragment::run_no());
00146   return *this;
00147 }

uint32_t eformat::write::ROSFragment::page_count ( void   )  const

Returns the total number of (raw memory) pages this fragment is composed of.

Warning:
This operation navigates at a potentially large list of child page nodes (for a full ATLAS event this should be bigger than 2,000 pages when built from scratch). If you don't do your bookkeeping, avoid calling this too often.

Definition at line 187 of file ROSFragment.cxx.

References m_child, m_extra_count, and eformat::write::ROBFragment::next().

00188 {
00189   uint32_t retval = 3 + m_extra_count;
00190   for (const ROBFragment* curr = m_child; curr; curr = curr->next())
00191     retval += curr->page_count();
00192   return retval;
00193 }

void eformat::write::ROSFragment::parent ( eformat::write::SubDetectorFragment sd  )  [inline]

This sets the parent fragment

Parameters:
sd The SubDetectorFragment parent fragment of this ROS

Definition at line 244 of file ROSFragment.h.

References m_parent.

00245       { m_parent = sd; }

const SubDetectorFragment* eformat::write::ROSFragment::parent ( void   )  const [inline]

This returns the parent fragment

Definition at line 236 of file ROSFragment.h.

References m_parent.

Referenced by eformat::write::SubDetectorFragment::append().

00237       { return m_parent; }

uint32_t eformat::write::ROSFragment::run_no ( void   )  const [inline]

Returns the run number for this fragment

Definition at line 157 of file ROSFragment.h.

References eformat::write::node_t::base, and m_node.

Referenced by operator=(), and ROSFragment().

00158       { return m_node[2].base[1]; }

void eformat::write::ROSFragment::run_no ( uint32_t  s  )  [inline]

Changes the run number

Parameters:
s The new value to set

Definition at line 151 of file ROSFragment.h.

References eformat::write::node_t::base, and m_node.

00152       { m_node[2].base[1] = s; }

void eformat::write::ROSFragment::size_change ( uint32_t  o,
uint32_t  n 
)

This method is used by children of this fragment to notify fragment size changes.

Parameters:
o The old size, in 32-bit words
n The new size, in 32-bit words

Definition at line 161 of file ROSFragment.cxx.

References eformat::write::node_t::base, m_node, m_parent, and eformat::write::SubDetectorFragment::size_change().

Referenced by eformat::write::ROBFragment::rod_data(), eformat::write::ROBFragment::rod_status(), and eformat::write::ROBFragment::status().

00162 { 
00163   uint32_t old_size = m_node[0].base[1];
00164   m_node[0].base[1] -= o;
00165   m_node[0].base[1] += n;
00166   if (m_parent) m_parent->size_change(old_size, m_node[0].base[1]);
00167 }

uint32_t eformat::write::ROSFragment::size_word ( void   )  const [inline]

Returns the total size for this fragment, in words

Definition at line 199 of file ROSFragment.h.

References eformat::write::node_t::base, and m_node.

Referenced by eformat::write::SubDetectorFragment::append().

00200       { return m_node[0].base[1]; }

uint32_t eformat::write::ROSFragment::source_id ( void   )  const [inline]

Returns the source identifier for this fragment

Definition at line 143 of file ROSFragment.h.

References eformat::write::node_t::base, and m_node.

Referenced by append(), operator=(), and ROSFragment().

00144       { return m_node[0].base[4]; }

void eformat::write::ROSFragment::source_id ( uint32_t  s  )  [inline]

Changes the source identifier for this fragment

Parameters:
s The new value to set

Definition at line 137 of file ROSFragment.h.

References eformat::write::node_t::base, and m_node.

Referenced by eformat::write::SubDetectorFragment::append().

00138       { m_node[0].base[4] = s; }

const uint32_t* eformat::write::ROSFragment::status ( void   )  const [inline]

Returns a pointer to the first status word to be used by this fragment

Definition at line 116 of file ROSFragment.h.

References eformat::write::node_t::base, and m_node.

00116 { return m_node[1].base; }

void eformat::write::ROSFragment::status ( uint32_t  n,
const uint32_t *  status 
)

Changes the number of status words and the status words themselves from the fragment

Parameters:
n How many status words this fragment is supposed to have.
status A pointer to n pre-allocated words

Definition at line 149 of file ROSFragment.cxx.

References eformat::write::node_t::base, m_node, m_parent, eformat::write::SubDetectorFragment::size_change(), and eformat::write::node_t::size_word.

Referenced by Builder::append2event(), and eformat::old::convert().

00150 {
00151   if (m_parent) m_parent->size_change(m_node[0].base[1], 
00152                                       m_node[0].base[1]-m_node[0].base[5]+n);
00153   m_node[0].base[1] -= m_node[0].base[5]; //remove count from previous status
00154   m_node[0].base[2] -= m_node[0].base[5]; //remove count from previous status
00155   m_node[1].size_word = m_node[0].base[5] = n; //set new values
00156   m_node[0].base[1] += n;
00157   m_node[0].base[2] += n;
00158   m_node[1].base = const_cast<uint32_t*>(status);
00159 }


Member Data Documentation

eformat::write::ROBFragment* eformat::write::ROSFragment::m_child [private]

my ROB children

Definition at line 288 of file ROSFragment.h.

Referenced by append(), bind(), first_child(), and page_count().

eformat::write::node_t eformat::write::ROSFragment::m_extra [private]

Extra pages I may have.

Definition at line 291 of file ROSFragment.h.

Referenced by bind(), and ROSFragment().

uint32_t eformat::write::ROSFragment::m_extra_count [private]

How many extra pages I have.

Definition at line 292 of file ROSFragment.h.

Referenced by bind(), page_count(), and ROSFragment().

uint32_t eformat::write::ROSFragment::m_header[10] [private]

The ROS Header.

Definition at line 281 of file ROSFragment.h.

Referenced by ROSFragment().

eformat::write::ROBFragment* eformat::write::ROSFragment::m_last [private]

my last ROB child

Definition at line 289 of file ROSFragment.h.

Referenced by append().

const eformat::write::ROSFragment* eformat::write::ROSFragment::m_next [private]

Next sibling.

Definition at line 290 of file ROSFragment.h.

Referenced by next().

eformat::write::node_t eformat::write::ROSFragment::m_node[3] [private]

Node representation.

Definition at line 286 of file ROSFragment.h.

Referenced by append(), bc_id(), bind(), lvl1_id(), meta_size_word(), minor_version(), nstatus(), ROSFragment(), run_no(), size_change(), size_word(), source_id(), and status().

eformat::write::SubDetectorFragment* eformat::write::ROSFragment::m_parent [private]

my parent

Definition at line 287 of file ROSFragment.h.

Referenced by append(), parent(), size_change(), and status().


Generated on Tue Nov 29 23:36:30 2016 for BOSS_7.0.2 by  doxygen 1.4.7