All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
AlgDecorators.cpp
Go to the documentation of this file.
1 // $Id: AlgDecorators.cpp,v 1.2 2005/11/08 16:31:03 mato Exp $
2 // ============================================================================
3 // Include files
4 // ============================================================================
5 // GaudiKernel
6 // ============================================================================
10 #include "GaudiKernel/IAlgTool.h"
11 #include "GaudiKernel/SmartIF.h"
12 #include "GaudiKernel/DataObject.h"
13 // ============================================================================
14 // GaudiAlg
15 // ============================================================================
17 #include "GaudiAlg/GaudiTool.h"
18 // ============================================================================
19 // GaudiPython
20 // ============================================================================
22 // ============================================================================
28 // ============================================================================
29 /* get the tool from GaudiAlgorithm
30  * @param alg GaudiAlgorithm
31  * @param type tool type
32  * @param name tool name
33  * @param parent tool parent
34  * @param create flag to create
35  * @return the tool
36  */
37 // ============================================================================
39 ( const GaudiAlgorithm* alg ,
40  const std::string& type ,
41  const std::string& name ,
42  const IInterface* parent ,
43  const bool create )
44 {
45  if ( 0 == alg ) { return 0 ; }
46  return alg -> tool<IAlgTool> ( type , name , parent , create ) ;
47 }
48 // ============================================================================
49 /* get the tool from GaudiAlgorithm
50  * @param alg GaudiAlgorithm
51  * @param typeAndName tool type/name
52  * @param parent tool parent
53  * @param create flag to create
54  * @return the tool
55  */
56 // ============================================================================
58 ( const GaudiAlgorithm* alg ,
59  const std::string& typeAndName ,
60  const IInterface* parent ,
61  const bool create )
62 {
63  if ( 0 == alg ) { return 0 ; }
64  return alg->tool<IAlgTool>( typeAndName , parent , create ) ;
65 }
66 // ============================================================================
67 /* get the service from GaudiAlgorithm
68  * @param alg GaudiAlgorithm
69  * @param name service name
70  * @param create flag to create
71  * @return the tool
72  */
73 // ============================================================================
75 ( const GaudiAlgorithm* alg ,
76  const std::string& name ,
77  const bool create )
78 {
79  if ( 0 == alg ) { return 0 ; }
80  return alg -> svc<IInterface> ( name , create ) ;
81 }
82 // ============================================================================
83 // get all counters form the algorithm
84 // ============================================================================
86 ( const GaudiAlgorithm* alg ,
87  std::vector<std::string>& names ,
89 {
90  typedef std::map<std::string,StatEntity> Stats ;
91  names.clear () ;
92  out.clear () ;
93  if ( 0 == alg ) { return 0 ; } // RETURN
94  //
95  const Stats& counters = alg->counters() ;
96  for ( Stats::const_iterator icnt = counters.begin() ;
97  counters.end() != icnt ; ++icnt )
98  {
99  names.push_back ( icnt->first ) ;
100  out .push_back ( &(icnt->second) ) ;
101  }
102  return out.size() ;
103 }
104 // ============================================================================
105 // get all counters form the tool
106 // ============================================================================
108 ( const GaudiTool* alg ,
109  std::vector<std::string>& names ,
111 {
112  typedef std::map<std::string,StatEntity> Stats ;
113  names.clear () ;
114  out.clear () ;
115  if ( 0 == alg ) { return 0 ; } // RETURN
116  //
117  const Stats& counters = alg->counters() ;
118  for ( Stats::const_iterator icnt = counters.begin() ;
119  counters.end() != icnt ; ++icnt )
120  {
121  names.push_back ( icnt->first ) ;
122  out .push_back ( &(icnt->second) ) ;
123  }
124  return out.size() ;
125 }
126 // ============================================================================
127 // get all counters form the algorithm
128 // ============================================================================
130 ( const IAlgorithm* alg ,
131  std::vector<std::string>& names ,
133 {
134  names.clear () ;
135  out.clear () ;
136  if ( 0 == alg ) { return 0 ; } // RETURN
137  //
138  return _counters_a_ ( dynamic_cast<const GaudiAlgorithm*>( alg ) , names , out ) ;
139 }
140 // ============================================================================
141 // get all counters form the tool
142 // ============================================================================
144 ( const IAlgTool* alg ,
145  std::vector<std::string>& names ,
147 {
148  names.clear () ;
149  out.clear () ;
150  if ( 0 == alg ) { return 0 ; } // RETURN
151  //
152  return _counters_t_ ( dynamic_cast<const GaudiTool*>( alg ) , names , out ) ;
153 }
154 // ============================================================================
155 // get the counter by name
156 // ============================================================================
158 ( const GaudiAlgorithm* cmp , const std::string& name )
159 {
160  if ( 0 == cmp ) { return 0 ; } // RETURN
161  return &( cmp -> counter ( name ) ) ; // RETURN
162 }
163 // ============================================================================
164 // get the counter by name
165 // ============================================================================
167 ( const GaudiTool* cmp , const std::string& name )
168 {
169  if ( 0 == cmp ) { return 0 ; } // RETURN
170  return &( cmp -> counter ( name ) ) ; // RETURN
171 }
172 // ============================================================================
173 // get the counter by name
174 // ============================================================================
176 ( const IAlgorithm* cmp , const std::string& name )
177 {
178  if ( 0 == cmp ) { return 0 ; } // RETURN
179  return _counter_a_ ( dynamic_cast<const GaudiAlgorithm*>( cmp ) , name ) ;
180 }
181 // ============================================================================
182 // get the counter by name
183 // ============================================================================
185 ( const IAlgTool* cmp , const std::string& name )
186 {
187  if ( 0 == cmp ) { return 0 ; } // RETURN
188  return _counter_t_ ( dynamic_cast<const GaudiTool*>( cmp ) , name ) ;
189 }
190 // ============================================================================
191 // get all tools
192 // ============================================================================
195 {
196  tools.clear() ;
197  if ( 0 == cmp ) { return 0 ; } // REUTRN
198  tools = cmp->tools() ;
199  return tools.size() ; // RETURN
200 }
201 // ============================================================================
202 // get all tools
203 // ============================================================================
206 {
207  tools.clear() ;
208  if ( 0 == cmp ) { return 0 ; } // REUTRN
209  tools = cmp->tools() ;
210  return tools.size() ; // RETURN
211 }
212 // ============================================================================
213 // get all tools
214 // ============================================================================
217 {
218  tools.clear() ;
219  if ( 0 == cmp ) { return 0 ; } // RETURN
220  return _tools_a_ ( dynamic_cast<const GaudiAlgorithm*> ( cmp ) , tools ) ;
221 }
222 // ============================================================================
223 // get all tools
224 // ============================================================================
227 {
228  tools.clear() ;
229  if ( 0 == cmp ) { return 0 ; } // RETURN
230  return _tools_t_ ( dynamic_cast<const GaudiTool*> ( cmp ) , tools ) ;
231 }
232 // ============================================================================
233 /* check the data in Transient Event Store
234  * @param alg GaudiAlgorithm
235  * @param location data location in TES
236  * @param useRoonInTes flag to respect RootInTes
237  * @return the data
238  */
239 // ============================================================================
241 ( const GaudiAlgorithm* alg ,
242  const std::string& location ,
243  const bool useRootInTes )
244 {
245  if ( 0 == alg ) { return false ; } // RETURN
246  return alg -> exist<DataObject> ( alg->evtSvc() , location , useRootInTes ) ;
247 }
248 // ============================================================================
249 /* get the data from Transient Event Store
250  * @param alg GaudiAlgorithm
251  * @param location data location in TES
252  * @param useRoonInTes flag to respect RootInTes
253  * @return the data
254  */
255 // ============================================================================
257 ( const GaudiAlgorithm* alg ,
258  const std::string& location ,
259  const bool useRootInTes )
260 {
261  if ( 0 == alg ) { return 0 ; } // RETURN
262  return alg->get<DataObject> ( alg->evtSvc() , location , useRootInTes ) ;
263 }
264 
265 
266 
267 // ============================================================================
268 // The END
269 // ============================================================================
270 
271 
272 
273 
static size_t _counters_a_(const GaudiAlgorithm *alg, std::vector< std::string > &names, Counters &out)
Header file for class GaudiAlgorithm.
static bool exist(const GaudiAlgorithm *alg, const std::string &location, const bool useRootInTes)
get the data from TES
static const StatEntity * _counter_t_(const GaudiTool *alg, const std::string &name)
static IInterface * svc_(const GaudiAlgorithm *alg, const std::string &name, const bool create=false)
get the service from GaudiAlgorithm
Collection of "decorators" for python algorithms.
const Statistics & counters() const
accessor to all counters
Definition: GaudiCommon.h:507
std::string names[100]
Definition: Node.cpp:19
static size_t _counters_t_(const GaudiTool *alg, std::vector< std::string > &names, Counters &out)
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
std::vector< IAlgTool * > Tools
Definition: AlgDecorators.h:53
string type
Definition: gaudirun.py:126
const AlgTools & tools() const
get the list of aquired tools
Definition: GaudiCommon.h:738
Definition of the basic interface.
Definition: IInterface.h:160
static size_t _tools_t_(const GaudiTool *, Tools &tools)
The useful base class for data processing algorithms.
Gaudi::Utils::GetData< TYPE >::return_type get(IDataProviderSvc *svc, const std::string &location, const bool useRootInTES=true) const
Templated access to the data in Gaudi Transient Store.
static size_t _tools_a_(const GaudiAlgorithm *, Tools &tools)
The IAlgorithm is the interface implemented by the Algorithm base class.
Definition: IAlgorithm.h:20
SmartIF< IDataProviderSvc > & evtSvc() const
shortcut for method eventSvc
Definition: Algorithm.h:257
std::vector< const StatEntity * > Counters
the actual type of vector of counters
Definition: AlgDecorators.h:52
static const StatEntity * _counter_a_(const GaudiAlgorithm *alg, const std::string &name)
The interface implemented by the AlgTool base class.
Definition: IAlgTool.h:23
The useful base class for tools.
Definition: GaudiTool.h:99
static DataObject * get_(const GaudiAlgorithm *alg, const std::string &location, const bool useRootInTes)
get the data from TES
The basic counter used for Monitoring purposes.
Definition: StatEntity.h:68
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:31
TOOL * tool(const std::string &type, const std::string &name, const IInterface *parent=0, bool create=true) const
Useful method for the easy location of tools.