The Gaudi Framework  master (37c0b60a)
Chrono.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2024 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 #ifndef GAUDIKERNEL_CHRONO_H
12 #define GAUDIKERNEL_CHRONO_H
13 // ============================================================================
14 // Include files
15 // ============================================================================
16 // STD& STL
17 // ============================================================================
18 #include <string>
19 // ============================================================================
20 // GaudiKernel
21 // ============================================================================
23 #include <GaudiKernel/IChronoSvc.h>
24 #include <GaudiKernel/Kernel.h>
25 // ============================================================================
36 public:
37  // =========================================================================
59  Chrono( IChronoSvc* svc = nullptr, // the service
60  const std::string& tag = "CHRONO::UNNAMED" ) // the unique tag/name
61  {
62  if ( svc ) { m_chrono = svc->chronoStart( tag ); }
63  }
64 
65  // =========================================================================
69  Chrono( Chrono&& rhs ) {
70  m_chrono = rhs.m_chrono;
71  rhs.m_chrono = nullptr;
72  }
73 
74  // =========================================================================
96  Chrono( const std::string& tag, // the unique tag/name
97  IChronoSvc* svc ) // the service
98  {
99  if ( svc ) { m_chrono = svc->chronoStart( tag ); }
100  }
101  // =========================================================================
122  Chrono( ChronoEntity* c ) : m_chrono( c ) {
123  if ( m_chrono ) { m_chrono->start(); }
124  }
125  // =========================================================================
146  Chrono( ChronoEntity& c ) : m_chrono( &c ) { m_chrono->start(); }
147  // =========================================================================
150  if ( m_chrono ) { m_chrono->stop(); }
151  }
152  // =========================================================================
153 private:
154  // =========================================================================
156  Chrono( const Chrono& ) = delete;
157  Chrono& operator=( const Chrono& ) = delete;
158  // =========================================================================
159 private:
160  // ==========================================================================
162  ChronoEntity* m_chrono = nullptr; // The actual chronometer
163  // ==========================================================================
164 };
165 // ============================================================================
166 // The END
167 // ============================================================================
168 #endif // GAUDIKERNEL_CHRONO_H
Chrono::Chrono
Chrono(ChronoEntity *c)
Constructor from Chrono Object/Entity.
Definition: Chrono.h:122
Chrono::Chrono
Chrono(Chrono &&rhs)
Move Constructor.
Definition: Chrono.h:69
Chrono::operator=
Chrono & operator=(const Chrono &)=delete
std::string
STL class.
ChronoEntity
Definition: ChronoEntity.h:31
Chrono::Chrono
Chrono(const Chrono &)=delete
delete the copy constructor and assignment operators
gaudirun.c
c
Definition: gaudirun.py:525
Chrono::~Chrono
~Chrono()
Destructor , stop the chrono.
Definition: Chrono.h:149
Chrono::Chrono
Chrono(ChronoEntity &c)
Constructor from Chrono Object/Entity.
Definition: Chrono.h:146
Chrono
Definition: Chrono.h:35
IChronoSvc
Definition: IChronoSvc.h:41
ChronoEntity.h
Kernel.h
IChronoSvc::chronoStart
virtual ChronoEntity * chronoStart(const ChronoTag &t)=0
start chrono, tagged by its name
Chrono::Chrono
Chrono(const std::string &tag, IChronoSvc *svc)
Constructor from Chrono Service and the tag.
Definition: Chrono.h:96
IChronoSvc.h
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:81
Chrono::Chrono
Chrono(IChronoSvc *svc=nullptr, const std::string &tag="CHRONO::UNNAMED")
Constructor from Chrono Service and the tag.
Definition: Chrono.h:59