Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v31r0 (aeb156f0)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
EventSlot.h
Go to the documentation of this file.
1 #ifndef EVENTSLOT_H_
2 #define EVENTSLOT_H_
3 
4 // Framework includes
5 #include "AlgsExecutionStates.h"
7 
8 #include <string>
9 #include <tuple>
10 #include <unordered_map>
11 #include <vector>
12 
14 struct EventSlot {
16  EventSlot( unsigned int numberOfAlgorithms, unsigned int numberOfControlFlowNodes, SmartIF<IMessageSvc> MS )
17  : algsStates( numberOfAlgorithms, MS ), controlFlowState( numberOfControlFlowNodes, -1 ){};
18 
20  EventSlot( const EventSlot& ) = delete;
22  EventSlot& operator=( const EventSlot& ) = delete;
24  EventSlot( EventSlot&& ) = default;
26  EventSlot& operator=( EventSlot&& ) = default;
27 
29  EventSlot( EventSlot& original, std::unique_ptr<EventContext> theeventContext, const std::string& nodeName )
30  : eventContext( std::move( theeventContext ) )
31  , algsStates( original.algsStates )
33  , entryPoint( nodeName )
34  , parentSlot( &original ) {
35  algsStates.reset();
36  };
37 
39  void reset( EventContext* theeventContext ) {
40  eventContext.reset( theeventContext );
41  algsStates.reset();
43  complete = false;
44  entryPoint.clear();
45  parentSlot = nullptr;
48  };
49 
51  void addSubSlot( std::unique_ptr<EventContext> viewContext, const std::string& nodeName ) {
52  unsigned int lastIndex = allSubSlots.size();
53 
54  auto search = subSlotsByNode.find( nodeName );
55  if ( search != subSlotsByNode.end() )
56  subSlotsByNode[nodeName].push_back( lastIndex );
57  else
58  subSlotsByNode.emplace( std::piecewise_construct, std::forward_as_tuple( nodeName ),
59  std::forward_as_tuple( 1, lastIndex ) );
60 
61  // Make new slot and nest it into the top slot
62  viewContext->setSubSlot( lastIndex );
63  allSubSlots.emplace_back( *this, std::move( viewContext ), nodeName );
64  }
65 
68  void disableSubSlots( const std::string& nodeName ) {
69  subSlotsByNode.emplace( std::piecewise_construct, std::forward_as_tuple( nodeName ), std::forward_as_tuple() );
70  }
71 
79  bool complete = false;
80 
82 
86  EventSlot* parentSlot = nullptr;
91 };
92 
93 #endif /* EVENTSLOT_H_ */
std::string entryPoint
Event Views bookkeeping (TODO: optimize view bookkeeping)
Definition: EventSlot.h:84
Class representing an event slot.
Definition: EventSlot.h:14
T forward_as_tuple(T...args)
void disableSubSlots(const std::string &nodeName)
Disable event views for a given CF view node by registering an empty container Contact B...
Definition: EventSlot.h:68
void addSubSlot(std::unique_ptr< EventContext > viewContext, const std::string &nodeName)
Add a subslot to the slot (this constructs a new slot and registers it with the parent one) ...
Definition: EventSlot.h:51
STL namespace.
std::vector< int > controlFlowState
State of the control flow.
Definition: EventSlot.h:77
std::vector< EventSlot > allSubSlots
Actual sub-slot instances.
Definition: EventSlot.h:90
void push_back(Container &c, const Value &v, std::true_type)
This class represents an entry point to all the event specific data.
Definition: EventContext.h:31
STL class.
The AlgsExecutionStates encodes the state machine for the execution of algorithms within a single eve...
void setSubSlot(const ContextID_t subslot)
Definition: EventContext.h:72
EventSlot(unsigned int numberOfAlgorithms, unsigned int numberOfControlFlowNodes, SmartIF< IMessageSvc > MS)
Construct a slot.
Definition: EventSlot.h:16
T reset(T...args)
EventSlot & operator=(const EventSlot &)=delete
Assignment operator.
EventSlot(EventSlot &original, std::unique_ptr< EventContext > theeventContext, const std::string &nodeName)
Construct a (sub)slot, nested to &#39;original&#39; parent slot, with CF states copied from the parent...
Definition: EventSlot.h:29
T clear(T...args)
T move(T...args)
T find(T...args)
T size(T...args)
T assign(T...args)
T emplace(T...args)
EventSlot * parentSlot
Pointer to parent slot (null for top level)
Definition: EventSlot.h:86
bool complete
Flags completion of the event.
Definition: EventSlot.h:79
void reset(EventContext *theeventContext)
Reset all resources in order to reuse the slot (thread-unsafe)
Definition: EventSlot.h:39
std::unordered_map< std::string, std::vector< unsigned int > > subSlotsByNode
Listing of sub-slots by the node (name) they are attached to.
Definition: EventSlot.h:88
std::unique_ptr< EventContext > eventContext
Cache for the eventContext.
Definition: EventSlot.h:73
AlgsExecutionStates algsStates
Vector of algorithms states.
Definition: EventSlot.h:75
T emplace_back(T...args)