Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-03-19 08:52:40

0001 /***********************************************************************************\
0002 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
0003 *                                                                                   *
0004 * This software is distributed under the terms of the Apache version 2 licence,     *
0005 * copied verbatim in the file "LICENSE".                                            *
0006 *                                                                                   *
0007 * In applying this licence, CERN does not waive the privileges and immunities       *
0008 * granted to it by virtue of its status as an Intergovernmental Organization        *
0009 * or submit itself to any jurisdiction.                                             *
0010 \***********************************************************************************/
0011 #ifndef GAUDIKERNEL_IMESSAGESVC_H
0012 #define GAUDIKERNEL_IMESSAGESVC_H
0013 
0014 // Include files
0015 #include "GaudiKernel/IInterface.h"
0016 #include <iostream>
0017 #include <string>
0018 
0019 // Forward declarations
0020 class StatusCode;
0021 class Message;
0022 
0023 /// Print levels enumeration
0024 namespace MSG {
0025   enum Level { NIL = 0, VERBOSE, DEBUG, INFO, WARNING, ERROR, FATAL, ALWAYS, NUM_LEVELS };
0026   enum Color { BLACK = 0, RED, GREEN, YELLOW, BLUE, PURPLE, CYAN, WHITE, NUM_COLORS };
0027 } // namespace MSG
0028 
0029 #ifdef _WIN32
0030 // Avoid (hopefully) conflicts between Windows' headers and MSG.
0031 #  ifndef NOMSG
0032 #    define NOMSG
0033 #    ifndef NOGDI
0034 #      define NOGDI
0035 #    endif
0036 #  endif
0037 #endif
0038 
0039 /** @class IMessageSvc IMessageSvc.h GaudiKernel/IMessageSvc.h
0040 
0041     The IMessage is the interface implemented by the message service.
0042     This interface is used by any algorithm or services wanting to report
0043     messages to the end-user.
0044 
0045     @author Iain Last
0046 */
0047 class GAUDI_API IMessageSvc : virtual public IInterface {
0048 public:
0049   /// InterfaceID
0050   DeclareInterfaceID( IMessageSvc, 2, 0 );
0051 
0052   /** Report a message by sending a Message object to the message service
0053       @param message  Reference to a message object
0054       @param outputLevel Output level of the message source for this message
0055   */
0056   virtual void reportMessage( const Message& msg, int outputLevel ) = 0;
0057 
0058   /** Report a message by sending a Message object to the message service
0059       @param message  Reference to a message object
0060   */
0061   virtual void reportMessage( const Message& message ) = 0;
0062 
0063   /** Report an error to the message service. The service will use the error code
0064       number for formating a human readable message
0065       @param code Error code number
0066       @param source Message source. Typically the alg/svc name
0067   */
0068   virtual void reportMessage( const StatusCode& code, std::string_view source = "" ) = 0;
0069 
0070   /** Report a message by specifying the source, severity level and text.
0071       @param source Message source. Typically the alg/svc name
0072       @param type Severity level
0073       @param message Text message
0074   */
0075   virtual void reportMessage( std::string source, int type, std::string message ) = 0;
0076 
0077   /** Insert a message to be sent for a given status code into the error code repository.
0078       @param code Status error code
0079       @param message Message associated
0080   */
0081   virtual void insertMessage( const StatusCode& code, Message message ) = 0;
0082 
0083   /// Erase all messages associated to all status codes.
0084   virtual void eraseMessage() = 0;
0085 
0086   /// Erase message associated to a given status code.
0087   virtual void eraseMessage( const StatusCode& code ) = 0;
0088 
0089   /** Erase a given message associated to a given status code.
0090       @param code Status error code
0091       @param message Message associated
0092   */
0093   virtual void eraseMessage( const StatusCode& code, const Message& message ) = 0;
0094 
0095   /** Add a new stream for a message type (severity level).
0096       @param type Severity level
0097       @param name Stream name
0098       @param stream Pointer to a C++ stream
0099   */
0100   virtual void insertStream( int type, std::string name, std::ostream* stream ) = 0;
0101 
0102   /// Delete all the streams.
0103   virtual void eraseStream() = 0;
0104 
0105   /// Delete all the streams for a given message type (severity level).
0106   virtual void eraseStream( int message_type ) = 0;
0107 
0108   /** Delete a single stream for a given message type (severity level)
0109       @param type Severity level
0110       @param stream Pointer to a C++ stream
0111   */
0112   virtual void eraseStream( int type, std::ostream* stream ) = 0;
0113 
0114   /** Delete all occurrences of a stream.
0115       @param stream Pointer to a C++ stream
0116   */
0117   virtual void eraseStream( std::ostream* stream ) = 0;
0118 
0119   /// Get the default stream.
0120   virtual std::ostream* defaultStream() const = 0;
0121 
0122   /** Set the default stream.
0123       @param stream Pointer to a C++ stream
0124   */
0125   virtual void setDefaultStream( std::ostream* stream ) = 0;
0126 
0127   /// Retrieve the current output level threshold
0128   virtual int outputLevel() const = 0;
0129 
0130   /** Retrieve the current output level threshold for a given message source
0131       @param source Message source. Typically the alg/svc name
0132   */
0133   virtual int outputLevel( std::string_view source ) const = 0;
0134 
0135   /// Set new global output level threshold
0136   virtual void setOutputLevel( int new_level ) = 0;
0137 
0138   /** Set new output level threshold for a given message source
0139       @param source  Message source
0140       @param new_level Severity level
0141   */
0142   virtual void setOutputLevel( std::string_view source, int new_level ) = 0;
0143 
0144   /** Show whether colors are used
0145    */
0146   virtual bool useColor() const = 0;
0147 
0148   /** Get the color codes for various log levels
0149       @param logLevel Logging level
0150    */
0151   virtual std::string getLogColor( int logLevel ) const = 0;
0152 
0153   /** Get the number of messages issued at a particular level
0154    */
0155   virtual int messageCount( MSG::Level level ) const = 0;
0156 };
0157 
0158 class GAUDI_API IInactiveMessageCounter : virtual public IInterface {
0159 public:
0160   /// InterfaceID
0161   DeclareInterfaceID( IInactiveMessageCounter, 2, 0 );
0162 
0163   /** Increment deactivated message count.
0164    *  Used by MsgStream to record the sources of messages that are prepared, but
0165    *  not printed (because if insufficient level).
0166    */
0167   virtual void incrInactiveCount( MSG::Level level, std::string_view src ) = 0;
0168 };
0169 
0170 #endif // GAUDIKERNEL_IMESSAGESVC_H