| The Gaudi Framework v32r1 (f65d50dc)

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"
6 #include "GaudiKernel/EventContext.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 )
32 , controlFlowState( original.controlFlowState )
33 , entryPoint( nodeName )
34 , parentSlot( &original ) {
35 algsStates.reset();
36 };
37
39 void reset( EventContext* theeventContext ) {
40 eventContext.reset( theeventContext );
41 algsStates.reset();
42 controlFlowState.assign( controlFlowState.size(), -1 );
43 complete = false;
44 entryPoint.clear();
45 parentSlot = nullptr;
46 subSlotsByNode.clear();
47 allSubSlots.clear();
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
73 std::unique_ptr<EventContext> eventContext;
75 AlgsExecutionStates algsStates;
77 std::vector<int> controlFlowState;
79 bool complete = false;
80
82
84 std::string entryPoint;
86 EventSlot* parentSlot = nullptr;
88 std::unordered_map<std::string, std::vector<unsigned int>> subSlotsByNode;
90 std::vector<EventSlot> allSubSlots;
91 };
92
93 #endif /* EVENTSLOT_H_ */
EventSlot::entryPoint
std::string entryPoint
Event Views bookkeeping (TODO: optimize view bookkeeping)
Definition: EventSlot.h:84
SmartIF< IMessageSvc >
EventSlot
Class representing an event slot.
Definition: EventSlot.h:14
std::forward_as_tuple
T forward_as_tuple(T... args)
EventSlot::disableSubSlots
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
EventSlot::addSubSlot
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
EventContext.h
std
STL namespace.
EventSlot::controlFlowState
std::vector< int > controlFlowState
State of the control flow.
Definition: EventSlot.h:77
std::unordered_map::end
T end(T... args)
EventSlot::allSubSlots
std::vector< EventSlot > allSubSlots
Actual sub-slot instances.
Definition: EventSlot.h:90
Gaudi::Functional::details::details2::push_back
void push_back(Container &c, const Value &v, std::true_type)
Definition: FunctionalDetails.h:184
EventContext
This class represents an entry point to all the event specific data.
Definition: EventContext.h:24
std::string
STL class.
AlgsExecutionStates
The AlgsExecutionStates encodes the state machine for the execution of algorithms within a single eve...
Definition: AlgsExecutionStates.h:26
EventContext::setSubSlot
void setSubSlot(const ContextID_t subslot)
Definition: EventContext.h:65
EventSlot::EventSlot
EventSlot(unsigned int numberOfAlgorithms, unsigned int numberOfControlFlowNodes, SmartIF< IMessageSvc > MS)
Construct a slot.
Definition: EventSlot.h:16
std::unique_ptr::reset
T reset(T... args)
EventSlot::operator=
EventSlot & operator=(const EventSlot &)=delete
Assignment operator.
EventSlot::EventSlot
EventSlot(EventSlot &original, std::unique_ptr< EventContext > theeventContext, const std::string &nodeName)
Construct a (sub)slot, nested to 'original' parent slot, with CF states copied from the parent.
Definition: EventSlot.h:29
std::string::clear
T clear(T... args)
std::move
T move(T... args)
std::unordered_map::find
T find(T... args)
std::vector::size
T size(T... args)
std::vector::assign
T assign(T... args)
std::vector< int >
std::unique_ptr< EventContext >
AlgsExecutionStates::reset
void reset()
Definition: AlgsExecutionStates.h:44
std::unordered_map::emplace
T emplace(T... args)
EventSlot::parentSlot
EventSlot * parentSlot
Pointer to parent slot (null for top level)
Definition: EventSlot.h:86
EventSlot::complete
bool complete
Flags completion of the event.
Definition: EventSlot.h:79
AlgsExecutionStates.h
EventSlot::reset
void reset(EventContext *theeventContext)
Reset all resources in order to reuse the slot (thread-unsafe)
Definition: EventSlot.h:39
EventSlot::subSlotsByNode
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
EventSlot::eventContext
std::unique_ptr< EventContext > eventContext
Cache for the eventContext.
Definition: EventSlot.h:73
EventSlot::algsStates
AlgsExecutionStates algsStates
Vector of algorithms states.
Definition: EventSlot.h:75
std::unordered_map
STL class.
std::vector::emplace_back
T emplace_back(T... args)