Commits

bi...@4525493e-7705-40b1-a816-d608a930855b  committed d67ed2e

added convenience macros for MsgStream (ATH_MSG_xyz)

  • Participants
  • Parent commits 8a9621b

Comments (0)

Files changed (8)

File AthenaBaseComps/AthAlgTool.h

 // FrameWork includes
 #include "GaudiKernel/AlgTool.h"
 #include "GaudiKernel/MsgStream.h"
+#include "AthenaBaseComps/AthMsgStreamMacros.h"
 
 class AthAlgTool : public AlgTool
 { 
    *  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 = MSG::INFO ) const;
+  msg( const MSG::Level lvl ) const;
 
   /////////////////////////////////////////////////////////////////// 
   // Non-const methods: 
 
 inline
 MsgStream&
+AthAlgTool::msg() const 
+{ return const_cast<MsgStream&>(m_msg); }
+
+inline
+MsgStream&
 AthAlgTool::msg (const MSG::Level lvl) const 
 { return const_cast<MsgStream&>(m_msg) << lvl; }
 

File AthenaBaseComps/AthAlgorithm.h

 #include "GaudiKernel/Algorithm.h"
 #include "GaudiKernel/MsgStream.h"
 #include "GaudiKernel/ServiceHandle.h"
+#include "AthenaBaseComps/AthMsgStreamMacros.h"
 
 // Forward declaration
 class StoreGateSvc;
    *  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 = MSG::INFO) const;
+  msg (const MSG::Level lvl) const;
 
   /** @brief The standard @c StoreGateSvc
    * Returns (kind of) a pointer to the @c StoreGateSvc
 
 inline
 MsgStream&
+AthAlgorithm::msg() const 
+{ return const_cast<MsgStream&>(m_msg); }
+
+inline
+MsgStream&
 AthAlgorithm::msg (const MSG::Level lvl) const 
 { return const_cast<MsgStream&>(m_msg) << lvl; }
 

File AthenaBaseComps/AthMsgStreamMacros.h

+///////////////////////// -*- C++ -*- /////////////////////////////
+// AthMsgStreamMacros.h 
+// Header file for useful macros when comes to using MsgStream
+// Author: S.Binet<binet@cern.ch>
+/////////////////////////////////////////////////////////////////// 
+#ifndef ATHENABASECOMPS_ATHMSGSTREAMMACROS_H 
+#define ATHENABASECOMPS_ATHMSGSTREAMMACROS_H 1
+
+// FIXME: operator precedence ?!
+#define ATH_MSG_LVL(lvl, x) \
+  do {					    \
+    if (this->msgLvl (lvl)) {		    \
+      this->msg(lvl) << x;		    \
+      this->msg(lvl) << endreq;		    \
+    }					    \
+  } while (0)
+
+#define ATH_MSG_VERBOSE(x) ATH_MSG_LVL(MSG::VERBOSE, x)
+#define ATH_MSG_DEBUG(x)   ATH_MSG_LVL(MSG::DEBUG, x)
+#define ATH_MSG_INFO(x)    ATH_MSG_LVL(MSG::INFO, x)
+#define ATH_MSG_WARNING(x) ATH_MSG_LVL(MSG::WARNING, x)
+#define ATH_MSG_ERROR(x)   ATH_MSG_LVL(MSG::ERROR, x)
+#define ATH_MSG_FATAL(x)   ATH_MSG_LVL(MSG::FATAL, x)
+#define ATH_MSG_ALWAYS(x)  ATH_MSG_LVL(MSG::ALWAYS, x)
+
+
+#endif //> !ATHENABASECOMPS_ATHMSGSTREAMMACROS_H
+

File AthenaBaseComps/AthService.h

 // FrameWork includes
 #include "GaudiKernel/Service.h"
 #include "GaudiKernel/MsgStream.h"
+#include "AthenaBaseComps/AthMsgStreamMacros.h"
 
 // Forward declaration
 class ISvcLocator;
    *  Returns a reference to the default message stream
    *  May not be invoked before sysInitialize() has been invoked.
    */
-  MsgStream& 
-  msg( const MSG::Level lvl = MSG::INFO ) const;
+  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: 
 
 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; }
 
+2008-09-08  Sebastien Binet  <binet@lblbox>
+
+	* tagging AthenaBaseComps-00-01-01
+	* added convenience macros for MsgStream (ATH_MSG_xyz).
+	  note that these macros will only work _within_ an AthXyz component
+	* A AthenaBaseComps/AthMsgStreamMacros.h
+	* M AthenaBaseComps/AthAlgTool.h
+	* M AthenaBaseComps/AthAlgorithm.h
+	* M AthenaBaseComps/AthService.h
+	* M src/AthAlgTool.cxx
+	* M src/AthAlgorithm.cxx
+	* M src/AthService.cxx
+
 2008-09-04  Sebastien Binet  <binet@lblbox>
 
 	* tagging AthenaBaseComps-00-01-00

File src/AthAlgTool.cxx

 ///////////////
 AthAlgTool::~AthAlgTool()
 { 
-  msg(MSG::DEBUG) << "Calling destructor" << endreq;
+  ATH_MSG_DEBUG ("Calling destructor");
 }
 
 /////////////////////////////////////////////////////////////////// 

File src/AthAlgorithm.cxx

 ///////////////
 AthAlgorithm::~AthAlgorithm()
 { 
-  msg (MSG::DEBUG) << "Calling destructor" << endreq;
+  ATH_MSG_DEBUG ("Calling destructor");
 }
 
 /////////////////////////////////////////////////////////////////// 

File src/AthService.cxx

 ///////////////
 AthService::~AthService()
 { 
-  msg(MSG::DEBUG) << "Calling destructor" << endreq;
+  ATH_MSG_DEBUG ("Calling destructor");
 }
 
 StatusCode AthService::sysInitialize()
 {
   // Initialize it only if was not done
   if( m_state != OFFLINE ) {
-    msg(MSG::WARNING) <<  "Service already initialized" << endreq;
+    ATH_MSG_WARNING ("Service already initialized");
     return StatusCode::FAILURE;
   }