Source

mana-core-athenabasecomps / AthenaBaseComps / AthService.h

The default branch has multiple heads

Full commit
///////////////////////// -*- C++ -*- /////////////////////////////
// AthService.h 
// Header file for class AthService
// Author: S.Binet<binet@cern.ch>
/////////////////////////////////////////////////////////////////// 
#ifndef ATHENABASECOMPS_ATHSERVICE_H 
#define ATHENABASECOMPS_ATHSERVICE_H 1

// STL includes
#include <string>

// FrameWork includes
#include "GaudiKernel/Service.h"
#include "GaudiKernel/MsgStream.h"
#include "AthenaBaseComps/AthMsgStreamMacros.h"

// Forward declaration
class ISvcLocator;
template <class TYPE> class SvcFactory;

class AthService : public Service
{ 
 protected:
  friend class SvcFactory<AthService>;

  /////////////////////////////////////////////////////////////////// 
  // Public methods: 
  /////////////////////////////////////////////////////////////////// 
 public: 

  // Copy constructor: 

  /// Constructor with parameters: 
  AthService( const std::string& name, ISvcLocator* pSvcLocator );

  /// Destructor: 
  virtual ~AthService(); 

  /// Initialize @c AthService
  virtual StatusCode sysInitialize();

  /// Finalize @c AthService
  virtual StatusCode sysFinalize();

  virtual StatusCode queryInterface( const InterfaceID& riid, 
                                     void** ppvInterface );

  /////////////////////////////////////////////////////////////////// 
  // Const methods: 
  ///////////////////////////////////////////////////////////////////

  /** @brief Test the output level
   *  @param lvl The message level to test against
   *  @return boolean Indicting if messages at given level will be printed
   *  @retval true Messages at level "lvl" will be printed
   */
  bool 
  msgLvl( const MSG::Level lvl ) const;

  /** The standard message stream.
   *  Returns a reference to the default message stream
   *  May not be invoked before sysInitialize() has been invoked.
   */
  MsgStream& msg() const;

  /** The standard message stream.
   *  Returns a reference to the default message stream
   *  May not be invoked before sysInitialize() has been invoked.
   */
  MsgStream& msg( const MSG::Level lvl) const;

  /////////////////////////////////////////////////////////////////// 
  // Non-const methods: 
  /////////////////////////////////////////////////////////////////// 

  /////////////////////////////////////////////////////////////////// 
  // Protected methods: 
  /////////////////////////////////////////////////////////////////// 
 protected: 

  /// callback for output level property 
  void msg_update_handler(Property& outputLevel);

  /////////////////////////////////////////////////////////////////// 
  // Private data: 
  /////////////////////////////////////////////////////////////////// 
 private: 

  /// Default constructor: 
  AthService();

  /// MsgStream instance (a std::cout like with print-out levels)
  MsgStream m_msg;

}; 

/////////////////////////////////////////////////////////////////// 
// Inline methods: 
/////////////////////////////////////////////////////////////////// 

inline
bool 
AthService::msgLvl (const MSG::Level lvl) const 
{ return static_cast<MSG::Level>(outputLevel()) <= lvl; }

inline
MsgStream&
AthService::msg() const 
{ return const_cast<MsgStream&>(m_msg); }

inline
MsgStream&
AthService::msg (const MSG::Level lvl) const 
{ return const_cast<MsgStream&>(m_msg) << lvl; }

#endif //> ATHENABASECOMPS_ATHSERVICE_H