Report problems to ATLAS LXR Team (with time and IP address indicated)

The LXR Cross Referencer

source navigation ]
diff markup ]
identifier search ]
general search ]
 
 
Architecture: linux ]
Version: head ] [ nightly ] [ GaudiDev ]
  Links to LXR source navigation pages for stable releases [ 12.*.* ]   [ 13.*.* ]   [ 14.*.* ]   [ 15.*.* ] 

001 // $Id: GaudiCommon.h,v 1.18 2008/10/27 19:22:20 marcocle Exp $
002 // ============================================================================
003 #ifndef GAUDIALG_GAUDICOMMON_H
004 #define GAUDIALG_GAUDICOMMON_H 1
005 // ============================================================================
006 // Include files
007 // ============================================================================
008 // from STL
009 // ============================================================================
010 #include <string>
011 #include <vector>
012 #include <map>
013 #include <algorithm>
014 // ============================================================================
015 // GaudiKernel
016 // ============================================================================
017 #include "GaudiKernel/StatusCode.h"
018 #include "GaudiKernel/IMessageSvc.h"
019 #include "GaudiKernel/IToolSvc.h"
020 #include "GaudiKernel/IAlgTool.h"
021 #include "GaudiKernel/IAlgContextSvc.h"
022 #include "GaudiKernel/IDataProviderSvc.h"
023 #include "GaudiKernel/SmartDataPtr.h"
024 #include "GaudiKernel/System.h"
025 #include "GaudiKernel/GaudiException.h"
026 #include "GaudiKernel/IChronoStatSvc.h"
027 #include "GaudiKernel/StatEntity.h"
028 #include "GaudiKernel/IUpdateManagerSvc.h"
029 #include "GaudiKernel/TransientFastContainer.h"
030 // ============================================================================
031 // forward declarations
032 // ============================================================================
033 class Algorithm ; // GaudiKernel
034 class AlgTool   ; // GaudiKernel
035 namespace Gaudi { namespace Utils { template <class TYPE> struct GetData ; } }
036 // ============================================================================
037 /*  @file GaudiCommon.h
038  *
039  *  Header file for class : GaudiCommon
040  *
041  *  @author Chris Jones   Christopher.Rob.Jones@cern.ch
042  *  @author Vanya BELYAEV Ivan.Belyaev@itep.ru
043  *  @date   2005-08-08
044  */
045 // ============================================================================
046 /** @class GaudiCommon GaudiCommon.h GaudiAlg/GaudiCommon.h
047  *
048  *  Implements the common functionality between GaudiTools and GaudiAlgorithms
049  *
050  *  @author Chris Jones   Christopher.Rob.Jones@cern.ch
051  *  @author Vanya BELYAEV Ivan.Belyaev@itep.ru
052  *  @date   2005-08-10
053  */
054 // ============================================================================
055 template < class PBASE >
056 class GaudiCommon : public PBASE
057 {
058 protected: // definitions
059   /** Simple definition to be used with the new useRootInTES argument get<TYPE>
060    *  and put methods. If used with cause the RootInTES option to be IGNORED.
061    *
062    *  Useful to aid with code readablity. e.g.
063    *  @code
064    *  // Get data, ignoring the setting of rootInTES()
065    *  MyData * data = get<MyData>( "/Event/MyData", IgnoreRootInTES );
066    *  @endcode
067    */
068   static const bool IgnoreRootInTES = false;
069   /** Simple definition to be used with the new useRootInTES argument get<TYPE>
070    *  and put methods. If used with cause the RootInTES option to be USED
071    *
072    *  Useful to aid with code readablity. e.g.
073    *  @code
074    *  // Get data, using the setting of rootInTES()
075    *  MyData * data = get<MyData>( "/Event/MyData", UseRootInTES );
076    *  // note the default setting is true, so this is equivalent to
077    *  MyData * data = get<MyData>( "/Event/MyData" );
078    *  @endcode
079    */
080   static const bool UseRootInTES = true;
081 protected: // few actual data types
082   /// the actual type of general counters
083   typedef std::map<std::string,StatEntity>   Statistics ;
084   /// the actual type error/warning counter
085   typedef std::map<std::string,unsigned int> Counter      ;
086   /// storage for active tools
087   typedef std::vector<IAlgTool*>             AlgTools     ;
088   /// Service pointer and name
089   typedef std::pair<IInterface*,std::string> ServiceEntry ;
090   /// storage for active services
091   typedef std::vector<ServiceEntry>          Services     ;
092 public:
093   /** @brief Templated access to the data in Gaudi Transient Store
094    *
095    *  Quick and safe access to the data in Gaudi transient store.
096    *  The method located the data at given address and perform the
097    *  debug printout about located data
098    *
099    *  @code
100    *
101    *  // Will access MCHits from the given location
102    *  MCHits* hits = get<MCHits>( evtSvc () , "MC/Hits" );
103    *
104    *  @endcode
105    *
106    *  @attention The method respects the setting of the job option
107    *             RootInTES by prepending the value of this to the
108    *             data location that is passed.
109    *             The default setting for RootInTES is "" so has no effect.
110    *             This behaviour can be suppressed by passing the arguement
111    *             useRootInTES = false
112    *
113    *  @see IDataProviderSvc
114    *  @see SmartDataPtr
115    *
116    *  @exception      GaudiException for Invalid Data Provider Service
117    *  @exception      GaudiException for invalid/unavailable data
118    *
119    *  @param svc      Pointer to data service (data provider)
120    *  @param location data location/address in Gaudi Transient Store
121    *  @param useRootInTES Flag to turn on(TRUE) off(FALSE) the use of
122    *                      the RootInTES location property
123    *
124    *  @return pointer to the data object
125    */
126   template < class TYPE >
127   typename Gaudi::Utils::GetData<TYPE>::return_type
128   get ( IDataProviderSvc*  svc         ,
129         const std::string& location    ,
130         const bool useRootInTES = true ) const ;
131   /** @brief Check the existence of a data object or container
132    *         in the Gaudi Transient Event Store
133    *
134    *  @code
135    *
136    *  bool a1 = exist<DataObject>( evtSvc() , "/Event/MyObject" ) ;
137    *  bool a2 = exist<MyHits>    ( evtSvc() , "/Event/MyHits" ) ;
138    *
139    *  @endcode
140    *
141    *  @attention The method respects the setting of the job option
142    *             RootInTES by prepending the value of this to the
143    *             data location that is passed.
144    *             The default setting for RootInTES is "" so has no effect.
145    *             This behaviour can be suppressed by passing the arguement
146    *             useRootInTES = false
147    *
148    *  @param  svc      Pointer to data provider service
149    *  @param  location Address in Gaudi Transient Store
150    *  @param useRootInTES Flag to turn on(TRUE) off(FALSE) the use of
151    *                      the RootInTES location property
152    *
153    *  @return          Boolean indicating status of the request
154    *  @retval true     Data object or container exists and implements a proper interface
155    *  @retval true     Failed to locate the data object or container
156    */
157   template < class TYPE >
158   bool  exist    ( IDataProviderSvc*  svc      ,
159                    const std::string& location ,
160                    const bool useRootInTES = true ) const ;
161   /** @brief Get the existing data object from Gaudi Event Transient store.
162    *        Alternatively, create new object and register it in TES
163    *        and return if object does not exist.
164    *
165    *  @code
166    *
167    *  MyHits* hits = getOrCreate<MyHits,MyHits>( evtSvc() , "/Event/MyHits" ) ;
168    *
169    *  @endcode
170    *
171    *  @attention The method respects the setting of the job option
172    *             RootInTES by prepending the value of this to the
173    *             data location that is passed.
174    *             The default setting for RootInTES is "" so has no effect.
175    *             This behaviour can be suppressed by passing the arguement
176    *             useRootInTES = false
177    *
178    *  @exception GaudiException for Invalid Data Provider Service
179    *  @exception GaudiException for invalid/unavailable  data
180    *
181    *  @param  svc      Pointer to data provider service
182    *  @param  location  Location in Gaudi Transient Event Store
183    *  @param useRootInTES Flag to turn on(TRUE) off(FALSE) the use of
184    *                      the RootInTES location property
185    *
186    *  @return A valid pointer to the data object
187    */
188   template < class TYPE , class TYPE2 >
189   TYPE* getOrCreate ( IDataProviderSvc* svc ,
190                       const std::string& location ,
191                       const bool useRootInTES = true ) const  ;
192   /** @brief Register a data object or container into Gaudi Event Transient Store
193    *
194    *  @see IDataProviderSvc
195    *
196    *  @attention The method respects the setting of the job option
197    *             RootInTES by prepending the value of this to the
198    *             data location that is passed.
199    *             The default setting for RootInTES is "" so has no effect.
200    *             This behaviour can be suppressed by passing the arguement
201    *             useRootInTES = false
202    *
203    *  @param svc        Pointer to data provider service
204    *  @param object     Data object or container to be registered
205    *  @param location   Location in Gaudi Event Transient Store ("/Event" could be omitted )
206    *  @param useRootInTES Flag to turn on(TRUE) off(FALSE) the use of
207    *                      the RootInTES location property
208    *
209    *  @exception        GaudiException for invalid event data service
210    *  @exception        GaudiException for invalid object
211    *  @exception        GaudiException for error result from event data service
212    *
213    *  @return StatusCode
214    *  @retval StatusCode::SUCCESS Data was successfully placed in the TES.
215    *  @retval StatusCode::FAILURE Failed to store data in the TES.
216    */
217   DataObject* put ( IDataProviderSvc*  svc ,
218              DataObject*        object   ,
219              const std::string& location  ,
220              const bool useRootInTES = true ) const ;
221   /** Useful method for the easy location of tools.
222    *
223    *  @code
224    *
225    *  IMyTool* myTool =
226    *      tool<IMyTool>( "MyToolType", "MyToolName", this );
227    *
228    *  @endcode
229    *
230    *  @attention The tools located with this method
231    *             will be released automatically
232    *
233    *  @see IToolSvc
234    *  @see IAlgTool
235    *
236    *  @exception GaudiException for invalid Tool Service
237    *  @exception GaudiException for error from Tool Service
238    *  @exception GaudiException for invalid tool
239    *
240    *  @param type   Tool type
241    *  @param name   Tool name
242    *  @param parent Tool parent
243    *  @param create Flag for creation of nonexisting tools
244    *  @return       A pointer to the tool
245    */
246   template < class TOOL >
247   TOOL* tool ( const std::string& type           ,
248                const std::string& name           ,
249                const IInterface*  parent  = 0    ,
250                bool               create  = true ) const ;
251   /** A useful method for the easy location of tools.
252    *
253    *  @code
254    *
255    *  IMyTool* myTool = tool<IMyTool>( "PublicToolType" );
256    *
257    *  @endcode
258    *
259    *  @attention The tools located with this method
260    *             will be released automatically
261    *
262    *  @see IToolSvc
263    *  @see IAlgTool
264    *
265    *  @exception    GaudiException for invalid Tool Service
266    *  @exception    GaudiException for error from Tool Service
267    *  @exception    GaudiException for invalid tool
268    *  @param type   Tool type, could be of "Type/Name" format
269    *  @param parent Tool parent
270    *  @param create Flag for creation of nonexisting tools
271    *  @return       A pointer to the tool
272    */
273   template < class TOOL >
274   TOOL* tool ( const std::string& type          ,
275                const IInterface*  parent = 0    ,
276                bool               create = true ) const ;
277   /** A useful method for the easy location of services
278    *
279    *  @code
280    *
281    *  IMyService* mySvc = svc<IMyService>( "MyServiceType" );
282    *
283    *  @endcode
284    *
285    *  @attention The services located with this method
286    *             will be released automatically
287    *
288    *  @see IService
289    *  @see ISevcLocator
290    *  @see Service
291    *
292    *  @exception GaudiException for error in Algorithms::service
293    *  @exception GaudiException for invalid service
294    *
295    *  @param name   service type name
296    *  @param create Flag for creation of non-existing services
297    *  @return       A pointer to the service
298    */
299   template < class SERVICE >
300   SERVICE* svc ( const std::string& name           ,
301                  const bool         create = true ) const ;
302   /// Short-cut to locate the Update Manager Service.
303   inline IUpdateManagerSvc * updMgrSvc() const;
304   /// Short-cut to locate the Fast Containers Service.
305   inline IDataProviderSvc * fastContainersSvc() const;
306 public:
307   /** Print the error message and return with the given StatusCode.
308    *
309    *  Also performs statistical analysis of the error messages and
310    *  suppression after the defined number of error instances.
311    *
312    *  @code
313    *
314    *   if( a < 0 ) { return Error("a is negative!") ;}
315    *   if( b < 0 ) { return Error("b is illegal!" , StatusCode(25) );
316    *   if( c < 0 )
317    *      { return Error("c is negative" , StatusCode(35) , 50 );
318    *
319    *  @endcode
320    *
321    *  @see MsgStream
322    *  @see IMessageSvc
323    *  @see StatusCode
324    *
325    *  @param msg    Error message
326    *  @param st     StatusCode to return
327    *  @param mx     Maximum number of printouts for this message
328    *  @return       StatusCode
329    */
330   StatusCode Error
331   ( const std::string& msg ,
332     const StatusCode   st  = StatusCode::FAILURE ,
333     const size_t       mx  = 10                  ) const ;
334   /** Print the warning message and return with the given StatusCode.
335    *
336    *  Also performs statistical analysis of the error messages and
337    *  suppression after the defined number of error instances.
338    *
339    *  @code
340    *
341    *   if( a < 0 ) { return Warning("a is negative!") ;}
342    *   if( b < 0 ) { return Warning("b is illegal!" , StatusCode(25) );
343    *   if( c < 0 )
344    *      { return Warning("c is negative" , StatusCode(35) , 50 );
345    *
346    *  @endcode
347    *
348    *  @see MsgStream
349    *  @see IMessageSvc
350    *  @see StatusCode
351    *
352    *  @param msg    Warning message
353    *  @param st     StatusCode to return
354    *  @param mx     Maximum number of printouts for this message
355    *  @return       The given StatusCode
356    */
357   StatusCode Warning
358   ( const std::string& msg ,
359     const StatusCode   st  = StatusCode::FAILURE ,
360     const size_t       mx  = 10                  ) const ;
361   /** Print the message and return with the given StatusCode.
362    *
363    *  @see MsgStream
364    *  @see IMessageSvc
365    *  @see StatusCode
366    *
367    *  @param msg    Message to print
368    *  @param st     StatusCode to return
369    *  @param lev    Printout level for the given message
370    *  @return       The given StatusCode
371    */
372   StatusCode Print
373   ( const std::string& msg ,
374     const StatusCode   st  = StatusCode::SUCCESS ,
375     const MSG::Level   lev = MSG::INFO           ) const ;
376   /** Assertion - throw exception if the given condition is not fulfilled
377    *
378    *  @see GaudiException
379    *
380    *  @exception          Exception for invalid condition
381    *  @param ok           Condition which should be "true"
382    *  @param message      Message to be associated with the exception
383    *  @param sc           StatusCode to be returned (artificial)
384    *  @return             StatusCode
385    */
386   inline StatusCode Assert
387   ( const bool         ok                            ,
388     const std::string& message = ""                  ,
389     const StatusCode   sc      = StatusCode(StatusCode::FAILURE, true) ) const;
390   /** Assertion - throw exception if the given condition is not fulfilled
391    *
392    *  @see GaudiException
393    *
394    *  @exception          Exception for invalid condition
395    *  @param ok           Condition which should be "true"
396    *  @param message      Message to be associated with the exception
397    *  @param sc           StatusCode to be returned (artificial)
398    *  @return             StatusCode
399    */
400   inline StatusCode Assert
401   ( const bool         ok                            ,
402     const char*        message                       ,
403     const StatusCode   sc      = StatusCode(StatusCode::FAILURE, true) ) const;
404   /** Create and (re)-throw a given GaudiException
405    *
406    *  @see GaudiException
407    *
408    *  @exception    CaudiException always thrown!
409    *  @param msg    Exception message
410    *  @param exc    (previous) exception of type GaudiException
411    *  @param sc     StatusCode
412    *  @return       StatusCode (fictive)
413    */
414   StatusCode Exception
415   ( const std::string    & msg                        ,
416     const GaudiException & exc                        ,
417     const StatusCode       sc  = StatusCode(StatusCode::FAILURE, true) ) const ;
418   /** Create and (re)-throw a given exception
419    *
420    *  @see GaudiException
421    *
422    *  @exception    std::exception always thrown!
423    *  @param msg    Exception message
424    *  @param exc    (previous) exception of type std::exception
425    *  @param sc     StatusCode
426    *  @return       StatusCode (fictive)
427    */
428   StatusCode Exception
429   ( const std::string    & msg                        ,
430     const std::exception & exc                        ,
431     const StatusCode       sc  = StatusCode(StatusCode::FAILURE, true) ) const ;
432   /** Create and throw an exception with the given message
433    *
434    *  @see GaudiException
435    *
436    *  @exception    GaudiException always thrown!
437    *  @param msg    Exception message
438    *  @param sc     StatusCode
439    *  @return       StatusCode (fictive)
440    */
441   StatusCode Exception
442   ( const std::string& msg = "no message"        ,
443     const StatusCode   sc  = StatusCode(StatusCode::FAILURE, true) ) const ;
444 public: // predefined streams
445   /** Predefined configurable message stream for the efficient printouts
446    *
447    *  @code
448    *
449    *  if ( a < 0 ) { msgStream( MSG::ERROR ) << "a = " << endreq ; }
450    *
451    *  @endcode
452    *
453    *  @return Reference to the predefined stream
454    */
455   inline MsgStream& msgStream ( const MSG::Level level ) const ;
456   /// shortcut for the method msgStream ( MSG::ALWAYS )
457   inline MsgStream&  always () const { return msgStream ( MSG::  ALWAYS ) ; }
458   /// shortcut for the method msgStream ( MSG::FATAL   )
459   inline MsgStream&   fatal () const { return msgStream ( MSG::   FATAL ) ; }
460   /// shortcut for the method msgStream ( MSG::ERROR   )
461   inline MsgStream&     err () const { return msgStream ( MSG::   ERROR ) ; }
462   /// shortcut for the method msgStream ( MSG::ERROR   )
463   inline MsgStream&   error () const { return msgStream ( MSG::   ERROR ) ; }
464   /// shortcut for the method msgStream ( MSG::WARNING )
465   inline MsgStream& warning () const { return msgStream ( MSG:: WARNING ) ; }
466   /// shortcut for the method msgStream ( MSG::INFO    )
467   inline MsgStream&    info () const { return msgStream ( MSG::    INFO ) ; }
468   /// shortcut for the method msgStream ( MSG::DEBUG   )
469   inline MsgStream&   debug () const { return msgStream ( MSG::   DEBUG ) ; }
470   /// shortcut for the method msgStream ( MSG::VERBOSE )
471   inline MsgStream& verbose () const { return msgStream ( MSG:: VERBOSE ) ; }
472   /// shortcut for the method msgStream ( MSG::INFO    )
473   inline MsgStream&     msg () const { return msgStream ( MSG::    INFO ) ; }
474 public:
475   /// accessor to all counters
476   inline const Statistics& counters() const { return m_counters ; }
477   /** accessor to certain counter by name
478    *
479    *  @code
480    *
481    *  if ( OK ) { ++counter("OK") ; }
482    *
483    *  // additive counter ('Flag')
484    *  counter("#Tracks") += tracks->size() ;
485    *
486    *  // multiplicative counter  ('Weight')
487    *  counter("ProbTot") *= probability ;
488    *
489    *  @endcode
490    *
491    *  @see StatEntuty
492    *  @param tag counter name
493    *  @return the counter itself
494    */
495   inline StatEntity& counter( const std::string& tag ) const { return m_counters[tag] ; }
496 public:
497   /** @brief The current message service output level
498    *  @return The current message level
499    */
500   inline MSG::Level msgLevel() const { return m_msgLevel ; }
501   /** @brief Test the output level
502    *  @param level The message level to test against
503    *  @return boolean Indicting if messages at given level will be printed
504    *  @retval true Messages at level "level" will be printed
505    *  @retval true Messages at level "level" will NOT be printed
506    */
507   inline bool msgLevel( const MSG::Level level ) const { return msgLevel() <= level ; }
508   /** @brief Reset (delete) the current message stream object.
509    *  Useful for example to force a new object following a
510    *  change in the message level settings
511    */
512   void resetMsgStream() const;
513   /// Insert the actual C++ type of the algorithm/tool in the messages ?
514   inline bool typePrint     () const { return m_typePrint    ; }
515   /// Print properties at initalization ?
516   inline bool propsPrint    () const { return m_propsPrint   ; }
517   /// Print statistical counters at finalization ?
518   inline bool statPrint     () const { return m_statPrint    ; }
519   /// Print error counters at finalization ?
520   inline bool errorsPrint   () const { return m_errorsPrint  ; }
521 private:
522   /** @brief Handle method for changes in the Messaging levels.
523    *  Called whenever the property "OutputLevel" changes to perform
524    *  all necessary actions locally.
525    *  @param theProp Reference to the Property that has changed
526    */
527   void msgLevelHandler ( Property& theProp );
528 public:
529   /** perform the actual printout of statistical counters
530    *  @param  level The message level to print at
531    *  @return number of active statistical counters
532    */
533   long printStat   ( const MSG::Level level = MSG::ALWAYS ) const ;
534   /** perform the actual printout of error counters
535    *  @param  level The message level to print at
536    *  @return number of error counters
537    */
538   long printErrors ( const MSG::Level level = MSG::ALWAYS ) const ;
539   /** perform the actual printout of properties
540    *  @param  level The message level to print at
541    *  @return number of properties
542    */
543   long printProps ( const MSG::Level level = MSG::ALWAYS ) const ;
544   /** register the current instance to the UpdateManagerSvc as a consumer for a condition.
545    *  @param condition  the path inside the Transient Detector Store to the condition object.
546    *  @param mf         optional pointer to the member function to call when the condition object
547    *                    is updated. If the pointer is omitted the user must explicitely provide
548    *                    the class name to the method.
549    *  @code
550    *  StatusCode MyAlg::initialize(){
551    *     // ...
552    *     registerCondition("/dd/Conditions/Readout/MyDet/MyCond",&MyAlg::i_CallBack);
553    *     registerCondition<MyAlg>("/dd/Conditions/Readout/MyDet/MyOtherCond");
554    *     // ...
555    *     return StatusCode.SUCCESS;
556    *  }
557    *  @endcode
558    */
559   template <class CallerClass>
560   inline void registerCondition(const std::string &condition, StatusCode (CallerClass::*mf)() = NULL) {
561     updMgrSvc()->registerCondition(dynamic_cast<CallerClass*>(this),condition,mf);
562   }
563   /** register the current instance to the UpdateManagerSvc as a consumer for a condition.
564    *  This version of the method allow the user to specify where to put a copy of the pointer
565    *  to the condition object.
566    *  @param condition    the path inside the Transient Detector Store to the condition object.
567    *  @param condPtrDest  pointer to fill with the location of the condition object.
568    *                      Note: the pointer can be safely used only in the execute method or in the
569    *                      member function triggered by the update.
570    *  @param mf           optional pointer to the member function to call when the condition object
571    *                      is updated. If the pointer is omitted the user must explicitely provide
572    *                      the class name to the method.
573    *  @code
574    *  class MyAlg: public GaudiAlgorithm {
575    *     // ...
576    *  public:
577    *     virtual StatusCode i_CallBack();
578    *  private:
579    *     Condition *m_MyCond;
580    *     SpecialCondition *m_MyOtherCond;
581    *     // ...
582    *  };
583    *
584    *  StatusCode MyAlg::initialize(){
585    *     // ...
586    *     registerCondition("/dd/Conditions/Readout/MyDet/MyCond",m_MyCond,&MyAlg::i_CallBack);
587    *     registerCondition<MyAlg>("/dd/Conditions/Readout/MyDet/MyOtherCond",m_MyOtherCond);
588    *     // ...
589    *     return StatusCode.SUCCESS;
590    *  }
591    *  @endcode
592    */
593   template <class CallerClass, class CondType>
594   inline void registerCondition(const std::string &condition, CondType *&condPtrDest,
595                                 StatusCode (CallerClass::*mf)() = NULL) {
596     updMgrSvc()->registerCondition(dynamic_cast<CallerClass*>(this),condition,mf,condPtrDest);
597   }
598   /// just to avoid conflicts with the version using a pointer to a template class.
599   template <class CallerClass>
600   inline void registerCondition(char *condition, StatusCode (CallerClass::*mf)() = NULL) {
601     updMgrSvc()->registerCondition(dynamic_cast<CallerClass*>(this),std::string(condition),mf);
602   }
603   /** register the current instance to the UpdateManagerSvc as a consumer for a condition.
604    *  @param condition  the path inside the Transient Detector Store to the condition object.
605    *  @param mf         optional pointer to the member function to call when the condition object
606    *                    is updated. If the pointer is omitted the user must explicitely provide
607    *                    the class name to the method.
608    *  @code
609    *  StatusCode MyAlg::initialize(){
610    *     // ...
611    *     registerCondition("/dd/Conditions/Readout/MyDet/MyCond",&MyAlg::i_CallBack);
612    *     registerCondition<MyAlg>("/dd/Conditions/Readout/MyDet/MyOtherCond");
613    *     // ...
614    *     return StatusCode.SUCCESS;
615    *  }
616    *  @endcode
617    */
618   template <class CallerClass,class TargetClass>
619   inline void registerCondition(TargetClass *condition, StatusCode (CallerClass::*mf)() = NULL) {
620     updMgrSvc()->registerCondition(dynamic_cast<CallerClass*>(this),condition,mf);
621   }
622   /** asks the UpdateManagerSvc to perform an update of the instance (if needed) without waiting the
623    *  next BeginEvent incident.
624    *  It is useful if the instance can be instantiated after a BeginEvent incident, and used before
625    *  the next one (for example with tools).
626    *  @code
627    *  StatusCode MyTool::initialize(){
628    *    // ...
629    *    return runUpdate();
630    *  }
631    *  @endcode
632    */
633   inline StatusCode runUpdate() { return updMgrSvc()->update(this); }
634   /// Return a new TransientFastContainer for objects of type T.
635   /// The container is created if it is not in the transient store.
636   /// If a container with the same name but a different type
637   template <class T>
638   TransientFastContainer<T> * getFastContainer
639   ( const std::string &location,
640     typename TransientFastContainer<T>::size_type initial=0);
641 public:
642   /// Algorithm constructor
643   GaudiCommon ( const std::string & name,
644                 ISvcLocator * pSvcLocator );
645   /// Tool constructor
646   GaudiCommon ( const std::string& type   ,
647                 const std::string& name   ,
648                 const IInterface*  parent );
649 public:
650   /** standard initialization method
651    *  @return status code
652    */
653   virtual StatusCode initialize ();
654   /** standard finalization method
655    *  @return status code
656    */
657   virtual StatusCode finalize   ();
658 protected:
659   /// Destructor
660   virtual ~GaudiCommon( );
661 private :
662   // default constructor is disabled
663   GaudiCommon() ;
664   // copy    constructor is disabled
665   GaudiCommon           ( const GaudiCommon& ) ;
666   // assignement operator is disabled
667   GaudiCommon& operator=( const GaudiCommon& ) ;
668 protected:
669   /// manual forced (and 'safe') release of the tool
670   StatusCode releaseTool ( const IAlgTool*   tool ) const ;
671   /// manual forced (and 'safe') release of the service
672   StatusCode releaseSvc  ( const IInterface* svc  ) const ;
673 public:
674   /** Manual forced (and 'safe') release of the active tool or service
675    *
676    *  @code
677    *
678    *  IMyTool* mytool = tool<IMyTool>( .... ) ;
679    *  mytool->spendCPUtime() ;
680    *  release ( mytool ) ;
681    *
682    *  IMySvc* msvc = svc<IMySvc>( .... ) ;
683    *  msvc->spendCPUtime() ;
684    *  release ( msvc ) ;
685    *
686    *  @endcode
687    *
688    *  @param interface  Interface pointer to the interface to be released
689    *  @return           StatusCode
690    *  @retval           StatusCode::SUCCESS Tool or service was successfully released
691    *  @retval           StatusCode::FAILURE Error releasing too or service
692    */
693   StatusCode release ( const IInterface* interface ) const ;
694 public:
695   /// Returns the "context" string. Used to indentify different processing states.
696   inline const std::string & context() const { return m_context; }
697   /** @brief Returns the "rootInTES" string.
698    *  Used as the directory root in the TES for which all data access refers to (both saving and retrieving).
699    */
700   inline const std::string & rootInTES() const { return m_rootInTES; }
701   /// Returns the "globalTimeOffset" double.
702   inline double globalTimeOffset() const { return m_globalTimeOffset; }
703 private:
704   /// Add the given tool to the list of acquired tools
705   void addToToolList    ( IAlgTool * tool ) const;
706   /// Add the given service to the list of acquired services
707   void addToServiceList ( IInterface * svc,
708                           const std::string & name ) const;
709   /// Constructor initializations
710   void initGaudiCommonConstructor( const IInterface * parent = 0 );
711   /// Returns the full correct event location given the rootInTes settings
712   const std::string fullTESLocation( const std::string & location,
713                                      const bool useRootInTES ) const;
714 private:
715   /// The message level
716   MSG::Level         m_msgLevel    ;
717 private:
718   /// The predefined message stream
719   mutable MsgStream* m_msgStream   ;
720   /// List of active  tools
721   mutable AlgTools   m_tools       ;
722   /// List of active  services
723   mutable Services   m_services    ;
724   // ==========================================================================
725   /// Counter of errors
726   mutable Counter    m_errors      ;
727   /// counter of warnings
728   mutable Counter    m_warnings    ;
729   /// Counter of exceptions
730   mutable Counter    m_exceptions  ;
731   /// General counters
732   mutable Statistics m_counters    ;
733   // ==========================================================================
734   /// Pointer to the Update Manager Service instance
735   mutable IUpdateManagerSvc* m_updMgrSvc;
736   /// Pointer to the service providing transient fast containers
737   mutable IDataProviderSvc* m_fastContainersSvc;
738   // ==========================================================================
739   /// insert  the actual C++ type of the algoritm in the messages?
740   bool        m_typePrint     ;
741   /// print properties at initalization?
742   bool        m_propsPrint    ;
743   /// print counters at finalization ?
744   bool        m_statPrint     ;
745   /// print warning and error counters at finalization ?
746   bool        m_errorsPrint   ;
747   // ==========================================================================
748   /// The context string
749   std::string m_context;
750   /// The rootInTES string
751   std::string m_rootInTES;
752   /// The rootOnTES string.
753   /// Note, this job option is OBSOLETE, but retained temporarily to allow easy migration.
754   /// Please update your code to use RootInTES instead. This option will be removed at some point.
755   std::string m_rootOnTES;
756   /// The globalTimeOffset value
757   double m_globalTimeOffset;
758   // ==========================================================================
759   // the header row
760   std::string    m_header  ; ///< the header row
761   // format for regular statistical printout rows
762   std::string    m_format1 ; ///< format for regular statistical printout rows
763   // format for "efficiency" statistical printout rows
764   std::string    m_format2 ; ///< format for "efficiency" statistical printout rows
765   // flag to use the special "efficiency" format
766   bool           m_useEffFormat ; ///< flag to use the special "efficiency" format
767 } ;
768 // ============================================================================
769 #include "GaudiAlg/GaudiCommonImp.h"
770 // ============================================================================
771 
772 // ============================================================================
773 // The END
774 // ============================================================================
775 #endif // GAUDIALG_GAUDICOMMON_H
776 // ============================================================================
777 

source navigation ] diff markup ] identifier search ] general search ]

Due to the LXR bug, the updates fail sometimes to remove references to deleted files. The Saturday's full rebuilds fix these problems
This page was automatically generated by the LXR engine. Valid HTML 4.01!