The Gaudi Framework  master (37c0b60a)
Sequencer.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2023 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 #include <Gaudi/Property.h>
14 #include <Gaudi/Sequence.h>
15 #include <mutex>
16 
17 namespace Gaudi {
29  public:
30  using Gaudi::Sequence::Sequence;
31 
39  StatusCode initialize() override;
40 
42  StatusCode reinitialize() override;
43 
45  StatusCode start() override;
46 
48  StatusCode execute( const EventContext& ctx ) const override;
49 
51  StatusCode stop() override;
52 
54  StatusCode finalize() override;
55 
57  bool branchFilterPassed( const EventContext& ctx ) const;
58 
60  void setBranchFilterPassed( const EventContext& ctx, bool state ) const;
61 
63  StatusCode append( Gaudi::Algorithm* pAlgorithm );
64 
66  StatusCode appendToBranch( Gaudi::Algorithm* pAlgorithm );
67 
78  StatusCode createAndAppend( const std::string& type, // The concrete algorithm class of the algorithm
79  const std::string& name, // The name to be given to the algorithm
80  Gaudi::Algorithm*& pAlgorithm // Set to point to the newly created algorithm object
81  );
82 
92  StatusCode createAndAppendToBranch( const std::string& type, // The concrete algorithm class of the algorithm
93  const std::string& name, // The name to be given to the algorithm
94  Gaudi::Algorithm*& pAlgorithm // Set to point to the newly created algorithm
95  // object
96  );
97 
99  StatusCode remove( Gaudi::Algorithm* pAlgorithm );
100  StatusCode remove( const std::string& name );
101  StatusCode removeFromBranch( Gaudi::Algorithm* pAlgorithm );
102  StatusCode removeFromBranch( const std::string& name );
103 
111  const std::vector<Gaudi::Algorithm*>& branchAlgorithms() const;
112  std::vector<Gaudi::Algorithm*>& branchAlgorithms();
113 
115  StatusCode decodeMemberNames();
116 
118  StatusCode decodeBranchMemberNames();
119 
120  protected:
124  StatusCode append( Gaudi::Algorithm* pAlgorithm, std::vector<Gaudi::Algorithm*>& theAlgs );
125 
135  StatusCode createAndAppend( const std::string& type, // The concrete algorithm class of the algorithm
136  const std::string& name, // The name to be given to the algorithm
137  Gaudi::Algorithm*& pAlgorithm, // Set to point to the newly created algorithm object
139 
143  StatusCode decodeNames( Gaudi::Property<std::vector<std::string>>& theNames,
145 
150  const std::vector<bool>& theLogic, Gaudi::Algorithm*& lastAlgorithm,
151  std::size_t first = 0 ) const;
152 
156  StatusCode executeMember( Gaudi::Algorithm* theAlgorithm, const EventContext& context ) const;
157 
162  StatusCode remove( const std::string& algname, std::vector<Gaudi::Algorithm*>& theAlgs );
163 
164  // NO COPY / ASSIGNMENT ALLOWED
165  Sequencer( const Sequencer& a ) = delete;
166  Sequencer& operator=( const Sequencer& rhs ) = delete;
167 
168  public:
170  std::ostream& toControlFlowExpression( std::ostream& os ) const override;
171 
172  private:
174  "Members",
175  {},
176  [this]( auto& ) {
177  if ( this->isInitialized() )
178  this->decodeMemberNames().ignore();
179  },
180  "member names",
181  "vector<Algorithm>" };
183  "BranchMembers",
184  {},
185  [this]( auto& ) {
186  if ( this->isInitialized() )
187  this->decodeBranchMemberNames().ignore();
188  },
189  "branch member names",
190  "vector<Algorithm>" };
191 
192  Gaudi::Property<bool> m_shortCircuit{ this, "ShortCircuit", true, "stop processing as soon as possible" };
193  Gaudi::Property<bool> m_sequential{ this, "Sequential", false, "execute members one at a time" };
194  Gaudi::Property<bool> m_modeOR{ this, "ModeOR", false, "use OR logic instead of AND" };
195  Gaudi::Property<bool> m_ignoreFilter{ this, "IgnoreFilterPassed", false, "always continue" };
196  Gaudi::Property<bool> m_invert{ this, "Invert", false, "invert the logic result of the sequencer" };
197 
199  this, "VetoObjects", {}, "skip execute if one or more of these TES objects exist" };
201  this, "RequireObjects", {}, "execute only if one or more of these TES objects exist" };
202 
203  std::vector<bool> m_isInverted; // Member logic inverted list
205  std::vector<bool> m_isBranchInverted; // Branch Member logic inverted list
206 
209  };
210 } // namespace Gaudi
std::string
STL class.
std::vector< Gaudi::Algorithm * >
IOTest.start
start
Definition: IOTest.py:110
Gaudi::Sequencer::operator=
Sequencer & operator=(const Sequencer &rhs)=delete
GaudiPython.Pythonizations.ctx
ctx
Definition: Pythonizations.py:578
StatusCode
Definition: StatusCode.h:65
Gaudi::Sequencer::m_isInverted
std::vector< bool > m_isInverted
Definition: Sequencer.h:203
GaudiPython.Pythonizations.execute
execute
Definition: Pythonizations.py:578
Gaudi::Sequencer::m_branchFilterPassed
std::map< EventContext::ContextID_t, bool > m_branchFilterPassed
Definition: Sequencer.h:208
std::ostream
STL class.
Gaudi::Algorithm
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:90
Gaudi::Sequencer::Sequencer
Sequencer(const Sequencer &a)=delete
Gaudi::Sequencer::m_isBranchInverted
std::vector< bool > m_isBranchInverted
Definition: Sequencer.h:205
std::map< EventContext::ContextID_t, bool >
Gaudi
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
Definition: __init__.py:1
StatusCode::ignore
const StatusCode & ignore() const
Allow discarding a StatusCode without warning.
Definition: StatusCode.h:139
gaudirun.type
type
Definition: gaudirun.py:160
ConditionsStallTest.name
name
Definition: ConditionsStallTest.py:77
EventContext
Definition: EventContext.h:34
Sequence.h
std::mutex
STL class.
std::size_t
Gaudi::Sequence
Definition: Sequence.h:18
compareRootHistos.state
state
Definition: compareRootHistos.py:496
Gaudi::Sequencer::m_branchAlgs
std::vector< Gaudi::Algorithm * > m_branchAlgs
Definition: Sequencer.h:204
Gaudi::Sequencer
A Sequencer is essentially a list of Algorithms and is responsible for their management.
Definition: Sequencer.h:28
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:81
Gaudi::Property
Implementation of property with value of concrete type.
Definition: Property.h:37
Gaudi::Sequencer::m_branchFilterMutex
std::mutex m_branchFilterMutex
Definition: Sequencer.h:207
Property.h