CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DataElement.cc
Go to the documentation of this file.
1 #include "DataElement.h"
2 
4  m_parent(0),
5  m_children(),
6  m_declaringScopeOffset(0),
7  m_offsetFunction(0){
8 }
9 
10 ora::DataElement::DataElement( size_t declaringScopeOffset,
11  Reflex::OffsetFunction offsetFunc ):
12  m_parent(0),
13  m_children(),
14  m_declaringScopeOffset(declaringScopeOffset),
15  m_offsetFunction(offsetFunc){
16 }
17 
19  for(std::vector<DataElement*>::const_iterator iEl = m_children.begin();
20  iEl != m_children.end(); ++iEl ){
21  delete *iEl;
22  }
23 }
24 
26 ora::DataElement::addChild( size_t declaringScopeOffset,
27  Reflex::OffsetFunction offsetFunction ){
28  DataElement* child = new DataElement( declaringScopeOffset, offsetFunction );
29  child->m_parent = this;
30  m_children.push_back(child);
31  return *child;
32 }
33 
34 size_t ora::DataElement::offset( const void* topLevelAddress ) const {
35  const void* address = topLevelAddress;
36  size_t offset = m_declaringScopeOffset;
37  if(m_parent){
38  size_t parentOffset = m_parent->offset( topLevelAddress );
39  offset += parentOffset;
40  address = static_cast<char*>(const_cast<void*>(topLevelAddress))+parentOffset;
41  }
42  if(m_offsetFunction){
43  offset += m_offsetFunction( const_cast<void*>(address));
44  }
45  return offset;
46 }
47 
48 void* ora::DataElement::address( const void* topLevelAddress ) const {
49  void* elementAddress = static_cast< char* >( const_cast<void*>(topLevelAddress)) + offset( topLevelAddress );
50  return elementAddress;
51 }
52 
54 {
55  return m_declaringScopeOffset;
56 }
57 
59  for(std::vector<DataElement*>::const_iterator iEl = m_children.begin();
60  iEl != m_children.end(); ++iEl ){
61  delete *iEl;
62  }
63  m_children.clear();
64 }
65 
void * address(const void *topLevelAddress) const
Definition: DataElement.cc:48
DataElement & addChild(size_t declaringScopeOffset, Reflex::OffsetFunction offsetFunction)
Definition: DataElement.cc:26
virtual ~DataElement()
Definition: DataElement.cc:18
size_t declaringScopeOffset() const
Definition: DataElement.cc:53
size_t offset(const void *topLevelAddress) const
Definition: DataElement.cc:34
unsigned int offset(bool)
const DataElement * m_parent
Definition: DataElement.h:26