Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  master (01b473db)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
EventSlot.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2025 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 #pragma once
12 
13 // Framework includes
14 #include "AlgsExecutionStates.h"
16 
17 #include <string>
18 #include <tuple>
19 #include <unordered_map>
20 #include <vector>
21 
23 struct EventSlot {
25  EventSlot( unsigned int numberOfAlgorithms, unsigned int numberOfControlFlowNodes, SmartIF<IMessageSvc> MS )
26  : algsStates( numberOfAlgorithms, MS ), controlFlowState( numberOfControlFlowNodes, -1 ) {}
27 
29  EventSlot( const EventSlot& ) = delete;
31  EventSlot& operator=( const EventSlot& ) = delete;
33  EventSlot( EventSlot&& ) = default;
35  EventSlot& operator=( EventSlot&& ) = default;
36 
38  EventSlot( EventSlot& original, std::unique_ptr<EventContext> theeventContext, const std::string& nodeName )
39  : eventContext( std::move( theeventContext ) )
40  , algsStates( original.algsStates )
42  , entryPoint( nodeName )
43  , parentSlot( &original ) {
44  algsStates.reset();
45  }
46 
48  void reset( EventContext* theeventContext ) {
49  eventContext.reset( theeventContext );
50  algsStates.reset();
51  controlFlowState.assign( controlFlowState.size(), -1 );
52  complete = false;
53  entryPoint.clear();
54  parentSlot = nullptr;
55  subSlotsByNode.clear();
56  allSubSlots.clear();
57  }
58 
60  void addSubSlot( std::unique_ptr<EventContext> viewContext, const std::string& nodeName ) {
61  unsigned int lastIndex = allSubSlots.size();
62 
63  auto search = subSlotsByNode.find( nodeName );
64  if ( search != subSlotsByNode.end() )
65  subSlotsByNode[nodeName].push_back( lastIndex );
66  else
67  subSlotsByNode.emplace( std::piecewise_construct, std::forward_as_tuple( nodeName ),
68  std::forward_as_tuple( 1, lastIndex ) );
69 
70  // Make new slot and nest it into the top slot
71  viewContext->setSubSlot( lastIndex );
72  allSubSlots.emplace_back( *this, std::move( viewContext ), nodeName );
73  }
74 
77  void disableSubSlots( const std::string& nodeName ) {
78  subSlotsByNode.emplace( std::piecewise_construct, std::forward_as_tuple( nodeName ), std::forward_as_tuple() );
79  }
80 
82  std::unique_ptr<EventContext> eventContext;
86  std::vector<int> controlFlowState;
88  bool complete = false;
89 
91 
93  std::string entryPoint;
95  EventSlot* parentSlot = nullptr;
97  std::unordered_map<std::string, std::vector<unsigned int>> subSlotsByNode;
99  std::vector<EventSlot> allSubSlots;
100 };
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:38
EventSlot::eventContext
std::unique_ptr< EventContext > eventContext
Cache for the eventContext.
Definition: EventSlot.h:82
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:97
GaudiPartProp.decorators.std
std
Definition: decorators.py:32
EventContext::setSubSlot
void setSubSlot(const ContextID_t subslot)
Definition: EventContext.h:75
EventSlot
Class representing an event slot.
Definition: EventSlot.h:23
AlgsExecutionStates
Definition: AlgsExecutionStates.h:37
AlgsExecutionStates.h
EventSlot::entryPoint
std::string entryPoint
Event Views bookkeeping (TODO: optimize view bookkeeping)
Definition: EventSlot.h:93
EventSlot::complete
bool complete
Flags completion of the event.
Definition: EventSlot.h:88
EventSlot::EventSlot
EventSlot(const EventSlot &)=delete
Copy constructor.
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:60
EventSlot::parentSlot
EventSlot * parentSlot
Pointer to parent slot (null for top level)
Definition: EventSlot.h:95
EventSlot::EventSlot
EventSlot(EventSlot &&)=default
Move constructor.
EventSlot::EventSlot
EventSlot(unsigned int numberOfAlgorithms, unsigned int numberOfControlFlowNodes, SmartIF< IMessageSvc > MS)
Construct a slot.
Definition: EventSlot.h:25
EventSlot::reset
void reset(EventContext *theeventContext)
Reset all resources in order to reuse the slot (thread-unsafe)
Definition: EventSlot.h:48
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:77
EventSlot::allSubSlots
std::vector< EventSlot > allSubSlots
Actual sub-slot instances.
Definition: EventSlot.h:99
SmartIF< IMessageSvc >
AlgsExecutionStates::reset
void reset()
Definition: AlgsExecutionStates.h:62
EventSlot::operator=
EventSlot & operator=(const EventSlot &)=delete
Assignment operator.
EventContext.h
EventContext
Definition: EventContext.h:34
EventSlot::controlFlowState
std::vector< int > controlFlowState
State of the control flow.
Definition: EventSlot.h:86
EventSlot::algsStates
AlgsExecutionStates algsStates
Vector of algorithms states.
Definition: EventSlot.h:84
EventSlot::operator=
EventSlot & operator=(EventSlot &&)=default
Move assignment.