The Gaudi Framework  v29r2 (7a580596)
concurrency::recursive_CF::ControlFlowGraph Class Reference

#include <src/ControlFlowGraph.h>

Inheritance diagram for concurrency::recursive_CF::ControlFlowGraph:
Collaboration diagram for concurrency::recursive_CF::ControlFlowGraph:

Public Member Functions

 ControlFlowGraph (const std::string &name, SmartIF< ISvcLocator > svc)
 Constructor. More...
 
 ~ControlFlowGraph () override
 Destructor. More...
 
void initialize (const std::unordered_map< std::string, unsigned int > &algname_index_map)
 Initialize graph. More...
 
void addHeadNode (const std::string &headName, bool modeConcurrent, bool modePromptDecision, bool modeOR, bool allPass)
 Add a node, which has no parents. More...
 
DecisionNodegetHeadNode () const
 Get head node. More...
 
StatusCode addAlgorithmNode (Algorithm *daughterAlgo, const std::string &parentName, bool inverted, bool allPass)
 Add algorithm node. More...
 
StatusCode addDecisionHubNode (Algorithm *daughterAlgo, const std::string &parentName, bool modeConcurrent, bool modePromptDecision, bool modeOR, bool allPass)
 Add a node, which aggregates decisions of direct daughter nodes. More...
 
unsigned int getControlFlowNodeCounter () const
 Get total number of graph nodes. More...
 
void updateEventState (AlgsExecutionStates &states, std::vector< int > &node_decisions) const
 Start revision of states and decisions. More...
 
void printState (std::stringstream &output, AlgsExecutionStates &states, const std::vector< int > &node_decisions, const unsigned int &recursionLevel) const
 Print a string representing the control flow state. More...
 
const std::stringname () const override
 Retrieve name of the service. More...
 
SmartIF< ISvcLocator > & serviceLocator () const override
 Retrieve pointer to service locator. More...
 
std::string dumpControlFlow () const
 Print out control flow of Algorithms and Sequences. More...
 
void dumpControlFlow (std::ostringstream &, ControlFlowNode *, const int &) const
 
- Public Member Functions inherited from CommonMessagingBase
virtual ~CommonMessagingBase ()=default
 Virtual destructor. More...
 
const SmartIF< IMessageSvc > & msgSvc () const
 The standard message service. More...
 
MsgStreammsgStream () const
 Return an uninitialized MsgStream. More...
 
MsgStreammsgStream (const MSG::Level level) const
 Predefined configurable message stream for the efficient printouts. More...
 
MsgStreamalways () const
 shortcut for the method msgStream(MSG::ALWAYS) More...
 
MsgStreamfatal () const
 shortcut for the method msgStream(MSG::FATAL) More...
 
MsgStreamerr () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamerror () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamwarning () const
 shortcut for the method msgStream(MSG::WARNING) More...
 
MsgStreaminfo () const
 shortcut for the method msgStream(MSG::INFO) More...
 
MsgStreamdebug () const
 shortcut for the method msgStream(MSG::DEBUG) More...
 
MsgStreamverbose () const
 shortcut for the method msgStream(MSG::VERBOSE) More...
 
MsgStreammsg () const
 shortcut for the method msgStream(MSG::INFO) More...
 
MSG::Level msgLevel () const
 get the cached level (originally extracted from the embedded MsgStream) More...
 
MSG::Level outputLevel () const __attribute__((deprecated))
 Backward compatibility function for getting the output level. More...
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream More...
 

Private Attributes

DecisionNodem_headNode {nullptr}
 the head node of the control flow graph; may want to have multiple ones once supporting trigger paths More...
 
AlgoNodesMap m_algoNameToAlgoNodeMap
 Index: map of algorithm's name to AlgorithmNode. More...
 
DecisionHubsMap m_decisionNameToDecisionHubMap
 Index: map of decision's name to DecisionHub. More...
 
unsigned int m_nodeCounter {0}
 Total number of nodes in the graph. More...
 
unsigned int m_algoCounter {0}
 Total number of algorithm nodes in the graph. More...
 
SmartIF< ISvcLocatorm_svcLocator
 Service locator (needed to access the MessageSvc) More...
 
const std::string m_name
 

Additional Inherited Members

- Public Types inherited from CommonMessaging< IControlFlowGraph >
using base_class = CommonMessaging
 
- Protected Member Functions inherited from CommonMessaging< IControlFlowGraph >
MSG::Level setUpMessaging ()
 Set up local caches. More...
 
MSG::Level resetMessaging ()
 Reinitialize internal states. More...
 
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream. More...
 

Detailed Description

Definition at line 144 of file ControlFlowGraph.h.

Constructor & Destructor Documentation

concurrency::recursive_CF::ControlFlowGraph::ControlFlowGraph ( const std::string name,
SmartIF< ISvcLocator svc 
)
inline

Constructor.

Definition at line 148 of file ControlFlowGraph.h.

148  : m_svcLocator( svc ), m_name( name )
149  {
150  setUpMessaging();
151  }
MSG::Level setUpMessaging()
Set up local caches.
SmartIF< ISvcLocator > m_svcLocator
Service locator (needed to access the MessageSvc)
concurrency::recursive_CF::ControlFlowGraph::~ControlFlowGraph ( )
inlineoverride

Destructor.

Definition at line 153 of file ControlFlowGraph.h.

154  {
155  if ( m_headNode != 0 ) delete m_headNode;
156  }
DecisionNode * m_headNode
the head node of the control flow graph; may want to have multiple ones once supporting trigger paths...

Member Function Documentation

StatusCode concurrency::recursive_CF::ControlFlowGraph::addAlgorithmNode ( Algorithm daughterAlgo,
const std::string parentName,
bool  inverted,
bool  allPass 
)

Add algorithm node.

Definition at line 146 of file ControlFlowGraph.cpp.

148  {
149 
151 
152  auto& algoName = algo->name();
153 
154  auto itP = m_decisionNameToDecisionHubMap.find( parentName );
156  if ( itP != m_decisionNameToDecisionHubMap.end() ) {
157  parentNode = itP->second;
158  auto itA = m_algoNameToAlgoNodeMap.find( algoName );
160  if ( itA != m_algoNameToAlgoNodeMap.end() ) {
161  algoNode = itA->second;
162  } else {
163  algoNode = new concurrency::recursive_CF::AlgorithmNode( *this, algo, m_nodeCounter, m_algoCounter, inverted,
164  allPass );
165  ++m_nodeCounter;
166  ++m_algoCounter;
167  m_algoNameToAlgoNodeMap[algoName] = algoNode;
168  if ( msgLevel( MSG::VERBOSE ) ) verbose() << "AlgoNode " << algoName << " added @ " << algoNode << endmsg;
169  }
170 
171  parentNode->addDaughterNode( algoNode );
172  } else {
173  sc = StatusCode::FAILURE;
174  error() << "Decision hub node " << parentName << ", requested to be parent, is not registered." << endmsg;
175  }
176 
177  return sc;
178  }
void addDaughterNode(ControlFlowNode *node)
Add a daughter node.
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
T find(T...args)
unsigned int m_algoCounter
Total number of algorithm nodes in the graph.
AlgoNodesMap m_algoNameToAlgoNodeMap
Index: map of algorithm&#39;s name to AlgorithmNode.
DecisionHubsMap m_decisionNameToDecisionHubMap
Index: map of decision&#39;s name to DecisionHub.
MSG::Level msgLevel() const
get the cached level (originally extracted from the embedded MsgStream)
unsigned int m_nodeCounter
Total number of nodes in the graph.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
StatusCode concurrency::recursive_CF::ControlFlowGraph::addDecisionHubNode ( Algorithm daughterAlgo,
const std::string parentName,
bool  modeConcurrent,
bool  modePromptDecision,
bool  modeOR,
bool  allPass 
)

Add a node, which aggregates decisions of direct daughter nodes.

Definition at line 181 of file ControlFlowGraph.cpp.

184  {
185 
187 
188  auto& decisionHubName = decisionHubAlgo->name();
189 
190  auto itP = m_decisionNameToDecisionHubMap.find( parentName );
192  if ( itP != m_decisionNameToDecisionHubMap.end() ) {
193  parentNode = itP->second;
194  auto itA = m_decisionNameToDecisionHubMap.find( decisionHubName );
196  if ( itA != m_decisionNameToDecisionHubMap.end() ) {
197  decisionHubNode = itA->second;
198  } else {
199  decisionHubNode = new concurrency::recursive_CF::DecisionNode(
200  *this, m_nodeCounter, decisionHubName, modeConcurrent, modePromptDecision, modeOR, allPass );
201  ++m_nodeCounter;
202  m_decisionNameToDecisionHubMap[decisionHubName] = decisionHubNode;
203  if ( msgLevel( MSG::VERBOSE ) )
204  verbose() << "Decision hub node " << decisionHubName << " added @ " << decisionHubNode << endmsg;
205  }
206 
207  parentNode->addDaughterNode( decisionHubNode );
208  } else {
209  sc = StatusCode::FAILURE;
210  error() << "Decision hub node " << parentName << ", requested to be parent, is not registered." << endmsg;
211  }
212 
213  return sc;
214  }
void addDaughterNode(ControlFlowNode *node)
Add a daughter node.
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
T find(T...args)
DecisionHubsMap m_decisionNameToDecisionHubMap
Index: map of decision&#39;s name to DecisionHub.
MSG::Level msgLevel() const
get the cached level (originally extracted from the embedded MsgStream)
unsigned int m_nodeCounter
Total number of nodes in the graph.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
void concurrency::recursive_CF::ControlFlowGraph::addHeadNode ( const std::string headName,
bool  modeConcurrent,
bool  modePromptDecision,
bool  modeOR,
bool  allPass 
)

Add a node, which has no parents.

Definition at line 217 of file ControlFlowGraph.cpp.

219  {
220 
221  auto itH = m_decisionNameToDecisionHubMap.find( headName );
222  if ( itH != m_decisionNameToDecisionHubMap.end() ) {
223  m_headNode = itH->second;
224  } else {
225  m_headNode = new concurrency::recursive_CF::DecisionNode( *this, m_nodeCounter, headName, modeConcurrent,
226  modePromptDecision, modeOR, allPass );
227  ++m_nodeCounter;
229  }
230  }
T find(T...args)
DecisionNode * m_headNode
the head node of the control flow graph; may want to have multiple ones once supporting trigger paths...
DecisionHubsMap m_decisionNameToDecisionHubMap
Index: map of decision&#39;s name to DecisionHub.
unsigned int m_nodeCounter
Total number of nodes in the graph.
std::string concurrency::recursive_CF::ControlFlowGraph::dumpControlFlow ( ) const

Print out control flow of Algorithms and Sequences.

Definition at line 239 of file ControlFlowGraph.cpp.

240  {
241  std::ostringstream ost;
242  dumpControlFlow( ost, m_headNode, 0 );
243  return ost.str();
244  }
std::string dumpControlFlow() const
Print out control flow of Algorithms and Sequences.
DecisionNode * m_headNode
the head node of the control flow graph; may want to have multiple ones once supporting trigger paths...
void concurrency::recursive_CF::ControlFlowGraph::dumpControlFlow ( std::ostringstream ost,
ControlFlowNode node,
const int &  indent 
) const

Definition at line 247 of file ControlFlowGraph.cpp.

248  {
249  ost << std::string( indent * 2, ' ' );
250  DecisionNode* dn = dynamic_cast<DecisionNode*>( node );
251  AlgorithmNode* an = dynamic_cast<AlgorithmNode*>( node );
252  if ( dn != 0 ) {
253  if ( node != m_headNode ) {
254  ost << node->getNodeName() << " [Seq] ";
255  ost << ( ( dn->m_modeConcurrent ) ? " [Concurrent] " : " [Sequential] " );
256  ost << ( ( dn->m_modePromptDecision ) ? " [Prompt] " : "" );
257  ost << ( ( dn->m_modeOR ) ? " [OR] " : "" );
258  ost << ( ( dn->m_allPass ) ? " [PASS] " : "" );
259  ost << "\n";
260  }
261  const std::vector<ControlFlowNode*>& dth = dn->getDaughters();
262  for ( std::vector<ControlFlowNode*>::const_iterator itr = dth.begin(); itr != dth.end(); ++itr ) {
263  dumpControlFlow( ost, *itr, indent + 1 );
264  }
265  } else if ( an != 0 ) {
266  ost << node->getNodeName() << " [Alg] ";
267  if ( an != 0 ) {
268  auto ar = an->getAlgorithm();
269  ost << " [n= " << ar->cardinality() << "]";
270  ost << ( ( !ar->isClonable() ) ? " [unclonable] " : "" );
271  }
272  ost << "\n";
273  }
274  }
std::string dumpControlFlow() const
Print out control flow of Algorithms and Sequences.
T end(T...args)
STL class.
STL class.
T begin(T...args)
DecisionNode * m_headNode
the head node of the control flow graph; may want to have multiple ones once supporting trigger paths...
unsigned int concurrency::recursive_CF::ControlFlowGraph::getControlFlowNodeCounter ( ) const
inline

Get total number of graph nodes.

Definition at line 172 of file ControlFlowGraph.h.

172 { return m_nodeCounter; }
unsigned int m_nodeCounter
Total number of nodes in the graph.
DecisionNode* concurrency::recursive_CF::ControlFlowGraph::getHeadNode ( ) const
inline

Get head node.

Definition at line 164 of file ControlFlowGraph.h.

164 { return m_headNode; };
DecisionNode * m_headNode
the head node of the control flow graph; may want to have multiple ones once supporting trigger paths...
void concurrency::recursive_CF::ControlFlowGraph::initialize ( const std::unordered_map< std::string, unsigned int > &  algname_index_map)

Initialize graph.

Definition at line 140 of file ControlFlowGraph.cpp.

141  {
142  m_headNode->initialize( algname_index_map );
143  }
void initialize(const std::unordered_map< std::string, unsigned int > &algname_index_map) override
Initialize.
DecisionNode * m_headNode
the head node of the control flow graph; may want to have multiple ones once supporting trigger paths...
const std::string& concurrency::recursive_CF::ControlFlowGraph::name ( ) const
inlineoverride

Retrieve name of the service.

Definition at line 182 of file ControlFlowGraph.h.

182 { return m_name; }
void concurrency::recursive_CF::ControlFlowGraph::printState ( std::stringstream output,
AlgsExecutionStates states,
const std::vector< int > &  node_decisions,
const unsigned int &  recursionLevel 
) const
inline

Print a string representing the control flow state.

Definition at line 176 of file ControlFlowGraph.h.

178  {
179  m_headNode->printState( output, states, node_decisions, recursionLevel );
180  }
void printState(std::stringstream &output, AlgsExecutionStates &states, const std::vector< int > &node_decisions, const unsigned int &recursionLevel) const override
Print a string representing the control flow state.
DecisionNode * m_headNode
the head node of the control flow graph; may want to have multiple ones once supporting trigger paths...
SmartIF<ISvcLocator>& concurrency::recursive_CF::ControlFlowGraph::serviceLocator ( ) const
inlineoverride

Retrieve pointer to service locator.

Definition at line 184 of file ControlFlowGraph.h.

184 { return m_svcLocator; }
SmartIF< ISvcLocator > m_svcLocator
Service locator (needed to access the MessageSvc)
void concurrency::recursive_CF::ControlFlowGraph::updateEventState ( AlgsExecutionStates states,
std::vector< int > &  node_decisions 
) const

Start revision of states and decisions.

Definition at line 233 of file ControlFlowGraph.cpp.

234  {
235  m_headNode->updateState( algo_states, node_decisions );
236  }
int updateState(AlgsExecutionStates &states, std::vector< int > &node_decisions) const override
Method to set algos to CONTROLREADY, if possible.
DecisionNode * m_headNode
the head node of the control flow graph; may want to have multiple ones once supporting trigger paths...

Member Data Documentation

unsigned int concurrency::recursive_CF::ControlFlowGraph::m_algoCounter {0}
private

Total number of algorithm nodes in the graph.

Definition at line 200 of file ControlFlowGraph.h.

AlgoNodesMap concurrency::recursive_CF::ControlFlowGraph::m_algoNameToAlgoNodeMap
private

Index: map of algorithm's name to AlgorithmNode.

Definition at line 194 of file ControlFlowGraph.h.

DecisionHubsMap concurrency::recursive_CF::ControlFlowGraph::m_decisionNameToDecisionHubMap
private

Index: map of decision's name to DecisionHub.

Definition at line 196 of file ControlFlowGraph.h.

DecisionNode* concurrency::recursive_CF::ControlFlowGraph::m_headNode {nullptr}
private

the head node of the control flow graph; may want to have multiple ones once supporting trigger paths

Definition at line 192 of file ControlFlowGraph.h.

const std::string concurrency::recursive_CF::ControlFlowGraph::m_name
private

Definition at line 203 of file ControlFlowGraph.h.

unsigned int concurrency::recursive_CF::ControlFlowGraph::m_nodeCounter {0}
private

Total number of nodes in the graph.

Definition at line 198 of file ControlFlowGraph.h.

SmartIF<ISvcLocator> concurrency::recursive_CF::ControlFlowGraph::m_svcLocator
mutableprivate

Service locator (needed to access the MessageSvc)

Definition at line 202 of file ControlFlowGraph.h.


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