library: libCore #include "TMessageHandler.h"

# TMessageHandler

class description - source file - inheritance tree (.pdf)

## class TMessageHandler : public TNamed

| Inheritance Chart:
`TObject`
| <- | `TNamed`
| <- | `TMessageHandler` |

        public:

                          TMessageHandler(const TClass* cl, Bool_t derived = kTRUE)
                          TMessageHandler(const char* cl, Bool_t derived = kTRUE)
                          TMessageHandler(const TMessageHandler&)
                  virtual ~TMessageHandler()
             virtual void Add()
           static TClass* Class()
            virtual Int_t GetMessageCount(Int_t messId) const
                    Int_t GetSize() const
            virtual Int_t GetTotalMessageCount() const
                   Bool_t HandleDerived() const
             virtual void HandleMessage(Int_t id, const TObject* obj)
          virtual TClass* IsA() const
           virtual Bool_t Notify()
             virtual void Print(Option_t* option = "") const
             virtual void Remove()
             virtual void ShowMembers(TMemberInspector& insp, char* parent)
             virtual void Streamer(TBuffer& b)
                     void StreamerNVirtual(TBuffer& b)

### Data Members

        protected:

           const TClass* fClass    class for which message has to be handled
          const TObject* fMessObj  object generating message
                   Int_t fMessId   message id (often matching specific enum in fClass)
                   Int_t fSize     number of different messages handled
                  Int_t* fCnts     count per message
                  Int_t* fMessIds  message ids
                  Bool_t fDerived  if true handle messages also for derived classes

## Class Description

     TMessageHandler

     Handle messages that might be generated by the system.
     By default a handler only keeps track of the different messages
     generated for a specific class. By deriving from this class and
     overriding Notify() one can implement custom message handling.
     In Notify() one has access to the message id and the object
     generating the message. One can install more than one message
     handler per class. A message handler can be removed or again
     added when needed.
     All Root "Warnings"  are logged as message 1001
     All Root "Errors"    are logged as message 1002
     All Root "SysErrors" are logged as message 1003
     All Root "Fatals"    are logged as message 1004

TMessageHandler(const TClass *cl, Bool_t derived)

     Create a new message handler for class cl and add it to the list
     of message handlers.

TMessageHandler(const char *cl, Bool_t derived)

     Create a new message handler for class named cl and add it to the list
     of message handlers.

~TMessageHandler()

     Clean up the messagehandler.

void Add()

     Add this message handler to the list of messages handlers.

Int_t GetMessageCount(Int_t messId) const

     Return counter for message with ID=messid.

Int_t GetTotalMessageCount() const

     Return total number of messages.

void HandleMessage(Int_t id, const TObject *obj)

     Store message origin, keep statistics and call Notify().

Bool_t Notify()

     This method must be overridden to handle object notifcation.

void Print(Option_t *) const

     Print statistics for this message handler.

void Remove()

     Remove this message handler from the list of messages handlers.

### Inline Functions

                      Int_t GetSize() const
                     Bool_t HandleDerived() const
                    TClass* Class()
                    TClass* IsA() const
                       void ShowMembers(TMemberInspector& insp, char* parent)
                       void Streamer(TBuffer& b)
                       void StreamerNVirtual(TBuffer& b)
            TMessageHandler TMessageHandler(const TMessageHandler&)

Author: Rene Brun 11/11/99
Last update: root/base:$Name: $:$Id: TMessageHandler.cxx,v 1.5 2005/06/23 06:24:27 brun Exp $
Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *