ATLAS Offline Software
Classes | Public Member Functions | Protected Types | Protected Attributes | List of all members
dqi::MiniConfigTreeNode Class Reference

A node of a tree structure holding a configuration, where each node may be given attributes, and a node inherits the attributes of parent nodes if those attributes are not redefined. More...

#include <MiniConfigTreeNode.h>

Inheritance diagram for dqi::MiniConfigTreeNode:
Collaboration diagram for dqi::MiniConfigTreeNode:

Classes

class  Visitor
 
class  Writer
 

Public Member Functions

 MiniConfigTreeNode (std::string name_, MiniConfigTreeNode *parent_)
 
virtual ~MiniConfigTreeNode ()
 
virtual const char * GetName () const
 
virtual std::string GetPathName () const
 
virtual MiniConfigTreeNodeGetNewDaughter (std::string name_)
 Returns a daughter of this node, creating one if necessary. More...
 
virtual MiniConfigTreeNodeGetDaughter (std::string name_) const
 
virtual const MiniConfigTreeNodeGetParent () const
 
virtual MiniConfigTreeNodeGetParent ()
 
virtual std::map< std::string, dqi::MiniConfigTreeNode * > GetDaughters () const
 
virtual const MiniConfigTreeNodeGetNode (std::string name_) const
 This function takes the full path name of a subnode (in UNIX directory style) and returns the corresponding subnode of this node, traversing the entire subtree until it is found. More...
 
virtual void SetAttribute (std::string attName, std::string attValue, bool isAttribKeyword=false)
 
virtual std::string GetAttribute (std::string attName, bool calledFromDaughter=false) const
 
virtual std::string GetAttributeLocal (std::string attName) const
 
virtual void GetAttributeNames (std::set< std::string > &attSet, bool calledFromDaughter=false) const
 
virtual void GetAttributeNamesLocal (std::set< std::string > &attSet) const
 
virtual void Accept (Visitor &visitor) const
 
virtual void Accept (Writer &writer)
 
virtual void SetAttribKeywordPropagateDown (bool propagateDown)
 
virtual bool GetAttribKeywordPropagateDown () const
 

Protected Types

typedef std::map< std::string, MiniConfigTreeNode * > NodeMap_t
 
typedef NodeMap_t::const_iterator NodeIter_t
 
typedef std::map< std::string, std::pair< std::string, bool > > AttMap_t
 
typedef AttMap_t::const_iterator AttIter_t
 

Protected Attributes

const std::string m_name
 
MiniConfigTreeNodem_parent
 
NodeMap_t m_daughters
 
AttMap_t m_attributes
 
bool m_propagateDown
 

Detailed Description

A node of a tree structure holding a configuration, where each node may be given attributes, and a node inherits the attributes of parent nodes if those attributes are not redefined.

Author
Michael Wilson, CERN, March 2007

Definition at line 25 of file MiniConfigTreeNode.h.

Member Typedef Documentation

◆ AttIter_t

typedef AttMap_t::const_iterator dqi::MiniConfigTreeNode::AttIter_t
protected

Definition at line 98 of file MiniConfigTreeNode.h.

◆ AttMap_t

typedef std::map<std::string,std::pair<std::string,bool> > dqi::MiniConfigTreeNode::AttMap_t
protected

Definition at line 97 of file MiniConfigTreeNode.h.

◆ NodeIter_t

typedef NodeMap_t::const_iterator dqi::MiniConfigTreeNode::NodeIter_t
protected

Definition at line 95 of file MiniConfigTreeNode.h.

◆ NodeMap_t

typedef std::map<std::string,MiniConfigTreeNode*> dqi::MiniConfigTreeNode::NodeMap_t
protected

Definition at line 94 of file MiniConfigTreeNode.h.

Constructor & Destructor Documentation

◆ MiniConfigTreeNode()

dqi::MiniConfigTreeNode::MiniConfigTreeNode ( std::string  name_,
MiniConfigTreeNode parent_ 
)

Definition at line 25 of file MiniConfigTreeNode.cxx.

27  : m_name(std::move(name_))
28  , m_parent(parent_)
29  , m_propagateDown(true)
30 {
31 }

◆ ~MiniConfigTreeNode()

dqi::MiniConfigTreeNode::~MiniConfigTreeNode ( )
virtual

Definition at line 34 of file MiniConfigTreeNode.cxx.

36 {
37  NodeIter_t daugEnd = m_daughters.end();
38  for( NodeIter_t i = m_daughters.begin(); i != daugEnd; ++i ) {
39  MiniConfigTreeNode* inode = i->second;
40  delete inode;
41  }
42 }

Member Function Documentation

◆ Accept() [1/2]

void dqi::MiniConfigTreeNode::Accept ( Visitor visitor) const
virtual

Definition at line 207 of file MiniConfigTreeNode.cxx.

209 {
210  visitor.Visit(this);
211  NodeIter_t daugEnd = m_daughters.end();
212  for( NodeIter_t i = m_daughters.begin(); i != daugEnd; ++i ) {
213  MiniConfigTreeNode* node = i->second;
214  node->Accept(visitor);
215  }
216 }

◆ Accept() [2/2]

void dqi::MiniConfigTreeNode::Accept ( Writer writer)
virtual

Definition at line 219 of file MiniConfigTreeNode.cxx.

221 {
222  writer.Write(this);
223  NodeIter_t daugEnd = m_daughters.end();
224  for( NodeIter_t i = m_daughters.begin(); i != daugEnd; ++i ) {
225  MiniConfigTreeNode* node = i->second;
226  node->Accept(writer);
227  }
228 }

◆ GetAttribKeywordPropagateDown()

bool dqi::MiniConfigTreeNode::GetAttribKeywordPropagateDown ( ) const
virtual

Definition at line 238 of file MiniConfigTreeNode.cxx.

240 {
241  return this->m_propagateDown;
242 }

◆ GetAttribute()

std::string dqi::MiniConfigTreeNode::GetAttribute ( std::string  attName,
bool  calledFromDaughter = false 
) const
virtual

Definition at line 147 of file MiniConfigTreeNode.cxx.

149 {
150  AttIter_t i = m_attributes.find( attName );
151  if( i == m_attributes.end() ) {
152  if( m_parent != 0 )
153  return m_parent->GetAttribute( attName, true );
154  else
155  return std::string("");
156  }
157  if (calledFromDaughter && ! m_propagateDown && i->second.second) {
158  return std::string("");
159  }
160  return i->second.first;
161 }

◆ GetAttributeLocal()

std::string dqi::MiniConfigTreeNode::GetAttributeLocal ( std::string  attName) const
virtual

Definition at line 166 of file MiniConfigTreeNode.cxx.

168 {
169  AttIter_t i = m_attributes.find( attName );
170  if( i == m_attributes.end() ) {
171  return std::string("");
172  }
173  return i->second.first;
174 }

◆ GetAttributeNames()

void dqi::MiniConfigTreeNode::GetAttributeNames ( std::set< std::string > &  attSet,
bool  calledFromDaughter = false 
) const
virtual

Definition at line 178 of file MiniConfigTreeNode.cxx.

180 {
181  if( m_parent !=0 ) {
182  m_parent->GetAttributeNames( attSet, true );
183  }
184  AttIter_t attEnd = m_attributes.end();
185  for( AttIter_t i = m_attributes.begin(); i != attEnd; ++i ) {
186  if (calledFromDaughter && ! m_propagateDown && i->second.second) {
187  } else {
188  std::set<std::string>::value_type setVal( i->first );
189  attSet.insert( setVal );
190  }
191  }
192 }

◆ GetAttributeNamesLocal()

void dqi::MiniConfigTreeNode::GetAttributeNamesLocal ( std::set< std::string > &  attSet) const
virtual

Definition at line 196 of file MiniConfigTreeNode.cxx.

198 {
199  AttIter_t attEnd = m_attributes.end();
200  for( AttIter_t i = m_attributes.begin(); i != attEnd; ++i ) {
201  std::set<std::string>::value_type setVal( i->first );
202  attSet.insert( setVal );
203  }
204 }

◆ GetDaughter()

MiniConfigTreeNode * dqi::MiniConfigTreeNode::GetDaughter ( std::string  name_) const
virtual

Definition at line 88 of file MiniConfigTreeNode.cxx.

90 {
91  NodeIter_t i = m_daughters.find( name_ );
92  if( i != m_daughters.end() ) {
93  return i->second;
94  }
95  return 0;
96 }

◆ GetDaughters()

std::map< std::string, MiniConfigTreeNode * > dqi::MiniConfigTreeNode::GetDaughters ( ) const
virtual

Definition at line 100 of file MiniConfigTreeNode.cxx.

102 {
103  return m_daughters;
104 }

◆ GetName()

const char * dqi::MiniConfigTreeNode::GetName ( ) const
virtual

Definition at line 46 of file MiniConfigTreeNode.cxx.

48 {
49  return m_name.c_str();
50 }

◆ GetNewDaughter()

MiniConfigTreeNode * dqi::MiniConfigTreeNode::GetNewDaughter ( std::string  name_)
virtual

Returns a daughter of this node, creating one if necessary.

This method only returns daughters, not granddaughters.

Definition at line 71 of file MiniConfigTreeNode.cxx.

73 {
74  NodeIter_t i = m_daughters.find( name_ );
75  if( i != m_daughters.end() ) {
76  return i->second;
77  }
78 
79  MiniConfigTreeNode* node = new MiniConfigTreeNode( name_, this );
80  node->SetAttribKeywordPropagateDown(this->m_propagateDown);
81  NodeMap_t::value_type nodeVal( name_, node );
82  m_daughters.insert( nodeVal );
83  return node;
84 }

◆ GetNode()

const MiniConfigTreeNode * dqi::MiniConfigTreeNode::GetNode ( std::string  name_) const
virtual

This function takes the full path name of a subnode (in UNIX directory style) and returns the corresponding subnode of this node, traversing the entire subtree until it is found.

If the bottom of the tree is reached before the full path has been used, the last node found is returned. If any part of the path is invalid before reaching the end of the tree, 0 is returned.

Definition at line 107 of file MiniConfigTreeNode.cxx.

109 {
110  if( m_daughters.size() == 0 ) {
111  return this;
112  }
113 
114  std::string::size_type k = name_.find_first_of('/');
115  if( k != std::string::npos ) {
116  std::string dName( name_, 0, k );
117  std::string pName( name_, k+1, std::string::npos );
118  if( dName != "" ) {
119  NodeIter_t i = m_daughters.find( dName );
120  if( i == m_daughters.end() ) {
121  return this;
122  }
123  MiniConfigTreeNode* node = i->second;
124  return node->GetNode( pName );
125  }
126  return GetNode( pName );
127  }
128 
129  NodeIter_t i = m_daughters.find( name_ );
130  if( i == m_daughters.end() ) {
131  return this;
132  }
133  return i->second;
134 }

◆ GetParent() [1/2]

virtual MiniConfigTreeNode* dqi::MiniConfigTreeNode::GetParent ( )
inlinevirtual

Definition at line 59 of file MiniConfigTreeNode.h.

59 { return m_parent; }

◆ GetParent() [2/2]

virtual const MiniConfigTreeNode* dqi::MiniConfigTreeNode::GetParent ( ) const
inlinevirtual

Definition at line 58 of file MiniConfigTreeNode.h.

58 { return m_parent; }

◆ GetPathName()

std::string dqi::MiniConfigTreeNode::GetPathName ( ) const
virtual

Definition at line 54 of file MiniConfigTreeNode.cxx.

56 {
57  std::string path;
58  if( m_parent != 0 ) {
59  std::string parentPath( m_parent->GetPathName() );
60  if( !parentPath.empty() ) {
61  path += parentPath;
62  path += std::string("/");
63  }
64  path += m_name;
65  }
66  return path;
67 }

◆ SetAttribKeywordPropagateDown()

void dqi::MiniConfigTreeNode::SetAttribKeywordPropagateDown ( bool  propagateDown)
virtual

Definition at line 231 of file MiniConfigTreeNode.cxx.

233 {
234  this->m_propagateDown = propagateDown;
235 }

◆ SetAttribute()

void dqi::MiniConfigTreeNode::SetAttribute ( std::string  attName,
std::string  attValue,
bool  isAttribKeyword = false 
)
virtual

Definition at line 138 of file MiniConfigTreeNode.cxx.

140 {
141  AttMap_t::value_type attMapVal( attName, AttMap_t::mapped_type(attValue, isAttribKeyword) );
142  m_attributes.insert( attMapVal );
143 }

Member Data Documentation

◆ m_attributes

AttMap_t dqi::MiniConfigTreeNode::m_attributes
protected

Definition at line 104 of file MiniConfigTreeNode.h.

◆ m_daughters

NodeMap_t dqi::MiniConfigTreeNode::m_daughters
protected

Definition at line 103 of file MiniConfigTreeNode.h.

◆ m_name

const std::string dqi::MiniConfigTreeNode::m_name
protected

Definition at line 100 of file MiniConfigTreeNode.h.

◆ m_parent

MiniConfigTreeNode* dqi::MiniConfigTreeNode::m_parent
protected

Definition at line 101 of file MiniConfigTreeNode.h.

◆ m_propagateDown

bool dqi::MiniConfigTreeNode::m_propagateDown
protected

Definition at line 106 of file MiniConfigTreeNode.h.


The documentation for this class was generated from the following files:
athena.path
path
python interpreter configuration --------------------------------------—
Definition: athena.py:126
dqi::MiniConfigTreeNode::m_propagateDown
bool m_propagateDown
Definition: MiniConfigTreeNode.h:106
dqi::MiniConfigTreeNode::GetAttribute
virtual std::string GetAttribute(std::string attName, bool calledFromDaughter=false) const
Definition: MiniConfigTreeNode.cxx:148
dqi::MiniConfigTreeNode::NodeIter_t
NodeMap_t::const_iterator NodeIter_t
Definition: MiniConfigTreeNode.h:95
dqi::MiniConfigTreeNode::AttIter_t
AttMap_t::const_iterator AttIter_t
Definition: MiniConfigTreeNode.h:98
dqi::MiniConfigTreeNode::GetAttributeNames
virtual void GetAttributeNames(std::set< std::string > &attSet, bool calledFromDaughter=false) const
Definition: MiniConfigTreeNode.cxx:179
dqi::MiniConfigTreeNode::GetPathName
virtual std::string GetPathName() const
Definition: MiniConfigTreeNode.cxx:55
lumiFormat.i
int i
Definition: lumiFormat.py:92
dqi::MiniConfigTreeNode::m_attributes
AttMap_t m_attributes
Definition: MiniConfigTreeNode.h:104
PyPoolBrowser.node
node
Definition: PyPoolBrowser.py:131
dqi::MiniConfigTreeNode::GetNode
virtual const MiniConfigTreeNode * GetNode(std::string name_) const
This function takes the full path name of a subnode (in UNIX directory style) and returns the corresp...
Definition: MiniConfigTreeNode.cxx:108
dqi::MiniConfigTreeNode::MiniConfigTreeNode
MiniConfigTreeNode(std::string name_, MiniConfigTreeNode *parent_)
Definition: MiniConfigTreeNode.cxx:26
dqi::MiniConfigTreeNode::m_daughters
NodeMap_t m_daughters
Definition: MiniConfigTreeNode.h:103
example.writer
writer
show summary of content
Definition: example.py:36
dqi::MiniConfigTreeNode::m_parent
MiniConfigTreeNode * m_parent
Definition: MiniConfigTreeNode.h:101
node
Definition: memory_hooks-stdcmalloc.h:74
fitman.k
k
Definition: fitman.py:528
dqi::MiniConfigTreeNode::m_name
const std::string m_name
Definition: MiniConfigTreeNode.h:100
inode
Definition: listroot.cxx:155