Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v38r0 (2143aa4c)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
AlgDecorators.cpp
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 // ============================================================================
12 // Include files
13 // ============================================================================
14 // GaudiKernel
15 // ============================================================================
16 #include "GaudiKernel/DataObject.h"
17 #include "GaudiKernel/IAlgTool.h"
18 #include "GaudiKernel/IAlgorithm.h"
19 #include "GaudiKernel/IInterface.h"
20 #include "GaudiKernel/IProperty.h"
21 #include "GaudiKernel/SmartIF.h"
22 // ============================================================================
23 // GaudiAlg
24 // ============================================================================
26 #include "GaudiAlg/GaudiTool.h"
27 // ============================================================================
28 // GaudiPython
29 // ============================================================================
31 // ============================================================================
32 // Disable warnings on gcc
33 // ============================================================================
34 #if defined( __GNUC__ )
35 # pragma GCC diagnostic push ignored "-Wdeprecated-declarations"
36 #endif
37 // ============================================================================
43 // ============================================================================
44 /* get the tool from GaudiAlgorithm
45  * @param alg GaudiAlgorithm
46  * @param type tool type
47  * @param name tool name
48  * @param parent tool parent
49  * @param create flag to create
50  * @return the tool
51  */
52 // ============================================================================
54  const IInterface* parent, const bool create ) {
55  return alg ? alg->tool<IAlgTool>( type, name, parent, create ) : nullptr;
56 }
57 // ============================================================================
58 /* get the tool from GaudiAlgorithm
59  * @param alg GaudiAlgorithm
60  * @param typeAndName tool type/name
61  * @param parent tool parent
62  * @param create flag to create
63  * @return the tool
64  */
65 // ============================================================================
67  const IInterface* parent, const bool create ) {
68  return alg ? alg->tool<IAlgTool>( typeAndName, parent, create ) : nullptr;
69 }
70 // ============================================================================
71 /* get the service from GaudiAlgorithm
72  * @param alg GaudiAlgorithm
73  * @param name service name
74  * @param create flag to create
75  * @return the tool
76  */
77 // ============================================================================
79  return alg ? alg->svc<IInterface>( name, create ) : nullptr;
80 }
81 // ============================================================================
82 // get the counter by name
83 // ============================================================================
85  return cmp ? &( cmp->counter( name ) ) : nullptr; // RETURN
86 }
87 // ============================================================================
88 // get the counter by name
89 // ============================================================================
91  return cmp ? &( cmp->counter( name ) ) : nullptr; // RETURN
92 }
93 // ============================================================================
94 // get the counter by name
95 // ============================================================================
97  return cmp ? _counter_a_( dynamic_cast<const GaudiAlgorithm*>( cmp ), name ) : nullptr;
98 }
99 // ============================================================================
100 // get the counter by name
101 // ============================================================================
103  return cmp ? _counter_t_( dynamic_cast<const GaudiTool*>( cmp ), name ) : nullptr;
104 }
105 // ============================================================================
106 // get all tools
107 // ============================================================================
109  tools.clear();
110  if ( cmp ) tools = cmp->tools();
111  return tools.size(); // RETURN
112 }
113 // ============================================================================
114 // get all tools
115 // ============================================================================
117  tools.clear();
118  if ( cmp ) tools = cmp->tools();
119  return tools.size(); // RETURN
120 }
121 // ============================================================================
122 // get all tools
123 // ============================================================================
125  tools.clear();
126  return cmp ? _tools_a_( dynamic_cast<const GaudiAlgorithm*>( cmp ), tools ) : 0;
127 }
128 // ============================================================================
129 // get all tools
130 // ============================================================================
132  tools.clear();
133  return cmp ? _tools_t_( dynamic_cast<const GaudiTool*>( cmp ), tools ) : 0;
134 }
135 // ============================================================================
136 /* check the data in Transient Event Store
137  * @param alg GaudiAlgorithm
138  * @param location data location in TES
139  * @param useRoonInTes flag to respect RootInTes
140  * @return the data
141  */
142 // ============================================================================
144  const bool useRootInTes ) {
145  return alg ? alg->exist<DataObject>( alg->evtSvc(), location, useRootInTes ) : false;
146 }
147 // ============================================================================
148 /* get the data from Transient Event Store
149  * @param alg GaudiAlgorithm
150  * @param location data location in TES
151  * @param useRoonInTes flag to respect RootInTes
152  * @return the data
153  */
154 // ============================================================================
156  const bool useRootInTes ) {
157  return alg ? alg->get<DataObject>( alg->evtSvc(), location, useRootInTes ) : nullptr;
158 }
159 // ============================================================================
160 // Re-enable warnings on gcc
161 // ============================================================================
162 #if defined( __GNUC__ )
163 # pragma GCC diagnostic pop
164 #endif
165 
166 // ============================================================================
167 // The END
168 // ============================================================================
GaudiTool.h
GaudiPython::AlgDecorator::_tools_a_
static size_t _tools_a_(const GaudiAlgorithm *, Tools &tools)
Definition: AlgDecorators.cpp:108
std::string
STL class.
IAlgTool
Definition: IAlgTool.h:33
GaudiAlg.HistoUtils.location
location
Definition: HistoUtils.py:964
bug_34121.name
name
Definition: bug_34121.py:20
std::vector< IAlgTool * >
std::vector::size
T size(T... args)
StatEntity
backward compatible StatEntity class.
Definition: StatEntity.h:23
GaudiPython::AlgDecorator::_counter_t_
static StatEntity * _counter_t_(const GaudiTool *alg, const std::string &name)
Definition: AlgDecorators.cpp:90
std::vector::clear
T clear(T... args)
basic.alg
alg
Definition: basic.py:15
SmartIF.h
AlgDecorators.h
IInterface.h
IAlgorithm
Definition: IAlgorithm.h:38
GaudiAlgorithm
Definition: GaudiAlgorithm.h:104
GaudiPython::AlgDecorator::get_
static DataObject * get_(const GaudiAlgorithm *alg, const std::string &location, const bool useRootInTes)
get the data from TES
Definition: AlgDecorators.cpp:155
IAlgTool.h
GaudiPython::AlgDecorator::_counter_a_
static StatEntity * _counter_a_(const GaudiAlgorithm *alg, const std::string &name)
Definition: AlgDecorators.cpp:84
GaudiPython::AlgDecorator::svc_
static IInterface * svc_(const GaudiAlgorithm *alg, const std::string &name, const bool create=false)
get the service from GaudiAlgorithm
Definition: AlgDecorators.cpp:78
Gaudi::Algorithm::tools
const std::vector< IAlgTool * > & tools() const
Definition: Algorithm.cpp:617
GaudiPython::AlgDecorator::exist
static bool exist(const GaudiAlgorithm *alg, const std::string &location, const bool useRootInTes)
get the data from TES
Definition: AlgDecorators.cpp:143
gaudirun.type
type
Definition: gaudirun.py:160
DataObject.h
AlgTool::tools
const std::vector< IAlgTool * > & tools() const
Definition: AlgTool.cpp:399
GaudiAlgorithm.h
IInterface
Definition: IInterface.h:237
DataObject
Definition: DataObject.h:40
GaudiCommon::counter
StatEntity & counter(std::string_view tag) const
accessor to certain counter by name
Definition: GaudiCommon.h:491
IProperty.h
IAlgorithm.h
GaudiTool
Definition: GaudiTool.h:110
GaudiPython::AlgDecorator::tool_
static IAlgTool * tool_(const GaudiAlgorithm *alg, const std::string &type, const std::string &name, const IInterface *parent=0, const bool create=true)
get the tool from GaudiAlgorithm
Definition: AlgDecorators.cpp:53
GaudiPython::AlgDecorator::_tools_t_
static size_t _tools_t_(const GaudiTool *, Tools &tools)
Definition: AlgDecorators.cpp:116