The Gaudi Framework  v33r0 (d5ea422b)
EventSlot.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 #ifndef EVENTSLOT_H_
12 #define EVENTSLOT_H_
13 
14 // Framework includes
15 #include "AlgsExecutionStates.h"
17 
18 #include <string>
19 #include <tuple>
20 #include <unordered_map>
21 #include <vector>
22 
24 struct EventSlot {
26  EventSlot( unsigned int numberOfAlgorithms, unsigned int numberOfControlFlowNodes, SmartIF<IMessageSvc> MS )
27  : algsStates( numberOfAlgorithms, MS ), controlFlowState( numberOfControlFlowNodes, -1 ){};
28 
30  EventSlot( const EventSlot& ) = delete;
32  EventSlot& operator=( const EventSlot& ) = delete;
34  EventSlot( EventSlot&& ) = default;
36  EventSlot& operator=( EventSlot&& ) = default;
37 
39  EventSlot( EventSlot& original, std::unique_ptr<EventContext> theeventContext, const std::string& nodeName )
40  : eventContext( std::move( theeventContext ) )
41  , algsStates( original.algsStates )
43  , entryPoint( nodeName )
44  , parentSlot( &original ) {
45  algsStates.reset();
46  };
47 
49  void reset( EventContext* theeventContext ) {
50  eventContext.reset( theeventContext );
51  algsStates.reset();
53  complete = false;
54  entryPoint.clear();
55  parentSlot = nullptr;
58  };
59 
61  void addSubSlot( std::unique_ptr<EventContext> viewContext, const std::string& nodeName ) {
62  unsigned int lastIndex = allSubSlots.size();
63 
64  auto search = subSlotsByNode.find( nodeName );
65  if ( search != subSlotsByNode.end() )
66  subSlotsByNode[nodeName].push_back( lastIndex );
67  else
68  subSlotsByNode.emplace( std::piecewise_construct, std::forward_as_tuple( nodeName ),
69  std::forward_as_tuple( 1, lastIndex ) );
70 
71  // Make new slot and nest it into the top slot
72  viewContext->setSubSlot( lastIndex );
73  allSubSlots.emplace_back( *this, std::move( viewContext ), nodeName );
74  }
75 
78  void disableSubSlots( const std::string& nodeName ) {
79  subSlotsByNode.emplace( std::piecewise_construct, std::forward_as_tuple( nodeName ), std::forward_as_tuple() );
80  }
81 
89  bool complete = false;
90 
92 
96  EventSlot* parentSlot = nullptr;
101 };
102 
103 #endif /* EVENTSLOT_H_ */
std::string entryPoint
Event Views bookkeeping (TODO: optimize view bookkeeping)
Definition: EventSlot.h:94
Class representing an event slot.
Definition: EventSlot.h:24
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:78
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:61
STL namespace.
std::vector< int > controlFlowState
State of the control flow.
Definition: EventSlot.h:87
T end(T... args)
std::vector< EventSlot > allSubSlots
Actual sub-slot instances.
Definition: EventSlot.h:100
This class represents an entry point to all the event specific data.
Definition: EventContext.h:34
STL class.
void push_back(Container &c, const Value &v, std::true_type)
The AlgsExecutionStates encodes the state machine for the execution of algorithms within a single eve...
void setSubSlot(const ContextID_t subslot)
Definition: EventContext.h:75
EventSlot(unsigned int numberOfAlgorithms, unsigned int numberOfControlFlowNodes, SmartIF< IMessageSvc > MS)
Construct a slot.
Definition: EventSlot.h:26
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 'original' parent slot, with CF states copied from the parent.
Definition: EventSlot.h:39
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:96
bool complete
Flags completion of the event.
Definition: EventSlot.h:89
void reset(EventContext *theeventContext)
Reset all resources in order to reuse the slot (thread-unsafe)
Definition: EventSlot.h:49
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:98
std::unique_ptr< EventContext > eventContext
Cache for the eventContext.
Definition: EventSlot.h:83
AlgsExecutionStates algsStates
Vector of algorithms states.
Definition: EventSlot.h:85
T emplace_back(T... args)