8 #ifndef COMMONMESSAGING_H_ 9 #define COMMONMESSAGING_H_ 24 #define generate_has_( method, args ) \ 25 template <typename T, typename SFINAE = void> \ 26 struct has_ ## method : std::false_type {}; \ 27 template <typename T> \ 28 struct has_ ## method<T, is_valid_t<decltype(std::declval<const T&>().method args)>> : std::true_type {}; 30 #define generate_add_(method, ret, args ) \ 31 template <typename Base, bool> struct add_ ## method; \ 32 template <typename Base> \ 33 struct add_ ## method <Base,false> : public Base { \ 36 template <typename Base> \ 37 struct add_ ## method <Base, true> : public Base { \ 39 virtual ~add_ ## method () = default; \ 40 virtual ret method args const = 0; \ 44 template <
typename>
struct void_t {
typedef void type; };
55 template <
typename Base>
using add_name = implementation_detail::add_name< Base, ! implementation_detail::has_name<Base>::value >;
56 template <
typename Base>
using add_serviceLocator = implementation_detail::add_serviceLocator< Base, ! implementation_detail::has_serviceLocator<Base>::value >;
65 virtual void create_msgSvc()
const = 0;
66 virtual void create_msgStream()
const = 0;
74 if (
UNLIKELY(!m_msgsvc)) create_msgSvc();
78 #if defined(GAUDI_V20_COMPAT) && !defined(G21_NO_DEPRECATED) 84 [[deprecated(
"will be removed in v28r1, use msgSvc() instead, see https://gitlab.cern.ch/gaudi/Gaudi/merge_requests/80")]]
92 if (
UNLIKELY((m_createMsgStream))) create_msgStream();
107 return msgStream() <<
level;
139 if (
UNLIKELY(!m_msgStream)) create_msgStream();
165 template <
typename BASE>
177 m_msgsvc = this->serviceLocator();
182 m_createMsgStream = (!
ms.isValid() || !m_msgStream);
183 m_level = m_msgStream ? m_msgStream->level() :
MSG::NIL;
190 if (level !=
MSG::NIL && level != m_level) {
192 msgSvc()->setOutputLevel(this->
name(), level);
194 if (m_msgStream) m_msgStream->setLevel(level);
196 debug() <<
"Property update for OutputLevel : new value = " << level <<
endmsg;
#define generate_add_(method, ret, args)
Definition of the MsgStream class used to transmit messages.
Small smart pointer class with automatic reference counting for IInterface.
MsgStream & msg() const
shortcut for the method msgStream(MSG::INFO)
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
SmartIF< IMessageSvc > m_msgsvc
Pointer to the message service;.
std::unique_ptr< MsgStream > m_msgStream
The predefined message stream.
void create_msgSvc() const override final
cold functionality
MsgStream & err() const
shortcut for the method msgStream(MSG::ERROR)
generate_has_(name,()) generate_add_(name
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
void updateMsgStreamOutputLevel(int level)
Update the output level of the cached MsgStream.
void create_msgStream() const override final
implementation_detail::add_serviceLocator< Base,!implementation_detail::has_serviceLocator< Base >::value > add_serviceLocator
MSG::Level outputLevel() const __attribute__((deprecated))
Backward compatibility function for getting the output level.
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
implementation_detail::add_name< Base,!implementation_detail::has_name< Base >::value > add_name
MsgStream & msgStream() const
Return an uninitialized MsgStream.
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
typename void_t< T >::type is_valid_t
MsgStream & msgStream(const MSG::Level level) const
Predefined configurable message stream for the efficient printouts.
MsgStream & fatal() const
shortcut for the method msgStream(MSG::FATAL)
MSG::Level msgLevel() const
get the output level from the embedded MsgStream
MsgStream & always() const
shortcut for the method msgStream(MSG::ALWAYS)
bool m_createMsgStream
Flag to trigger a new MsgStream.
bool msgLevel(MSG::Level lvl) const
get the output level from the embedded MsgStream
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.