The Gaudi Framework  master (b9786168)
Loading...
Searching...
No Matches
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
23struct 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;
97 std::unordered_map<std::string, std::vector<unsigned int>> subSlotsByNode;
99 std::vector<EventSlot> allSubSlots;
100};
The AlgsExecutionStates encodes the state machine for the execution of algorithms within a single eve...
This class represents an entry point to all the event specific data.
Small smart pointer class with automatic reference counting for IInterface.
Definition SmartIF.h:28
STL namespace.
std::unique_ptr< EventContext > eventContext
Cache for the eventContext.
Definition EventSlot.h:82
std::vector< EventSlot > allSubSlots
Actual sub-slot instances.
Definition EventSlot.h:99
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 * parentSlot
Pointer to parent slot (null for top level)
Definition EventSlot.h:95
EventSlot(unsigned int numberOfAlgorithms, unsigned int numberOfControlFlowNodes, SmartIF< IMessageSvc > MS)
Construct a slot.
Definition EventSlot.h:25
bool complete
Flags completion of the event.
Definition EventSlot.h:88
std::string entryPoint
Event Views bookkeeping (TODO: optimize view bookkeeping)
Definition EventSlot.h:93
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 & operator=(EventSlot &&)=default
Move assignment.
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
void reset(EventContext *theeventContext)
Reset all resources in order to reuse the slot (thread-unsafe)
Definition EventSlot.h:48
AlgsExecutionStates algsStates
Vector of algorithms states.
Definition EventSlot.h:84
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(EventSlot &&)=default
Move constructor.
std::vector< int > controlFlowState
State of the control flow.
Definition EventSlot.h:86
EventSlot & operator=(const EventSlot &)=delete
Assignment operator.
EventSlot(const EventSlot &)=delete
Copy constructor.