library: libCore #include "TMessage.h"

# TMessage

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

## class TMessage : public TBuffer

| Inheritance Chart:

`TObject`

<-

`TBuffer`

<-

`TMessage`

        private:

                   TMessage(const TMessage&)
              void operator=(const TMessage&)

        protected:

                   TMessage(void* buf, Int_t bufsize)
              void SetLength() const

        public:

                          TMessage(UInt_t what = kMESS_ANY)
                  virtual ~TMessage()
           static TClass* Class()
                    char* CompBuffer() const
                    Int_t CompLength() const
                    Int_t Compress()
                     void Forward()
                  TClass* GetClass() const
                    Int_t GetCompressionLevel() const
          virtual TClass* IsA() const
             virtual void Reset()
                     void Reset(UInt_t what)
                     void SetCompressionLevel(Int_t level = 1)
                     void SetWhat(UInt_t what)
             virtual void ShowMembers(TMemberInspector& insp, char* parent)
             virtual void Streamer(TBuffer& b)
                     void StreamerNVirtual(TBuffer& b)
                    Int_t Uncompress()
                   UInt_t What() const

### Data Members

        private:

           UInt_t fWhat        Message type
          TClass* fClass       If message is kMESS_OBJECT pointer to object's class
            Int_t fCompress    Compression level from 0 (not compressed) to 9 (max compression)
            char* fBufComp     Compressed buffer
            char* fBufCompCur  Current position in compressed buffer
            char* fCompPos     Position of fBufCur when message was compressed

## Class Description

     TMessage

     Message buffer class used for serializing objects and sending them
     over a network. This class inherits from TBuffer the basic I/O
     serializer.

TMessage(UInt_t what) : TBuffer(kWrite)

     Create a TMessage object for storing objects. The "what" integer
     describes the type of message. Predifined ROOT system message types
     can be found in MessageTypes.h. Make sure your own message types are
     unique from the ROOT defined message types (i.e. 0 - 10000 are
     reserved by ROOT). In case you OR "what" with kMESS_ACK, the message
     will wait for an acknowledgement from the remote side. This makes
     the sending process synchronous. In case you OR "what" with kMESS_ZIP,
     the message will be compressed in TSocket using the zip algorithm
     (only if message is > 256 bytes).

TMessage(void *buf, Int_t bufsize) : TBuffer(kRead, bufsize, buf)

     Create a TMessage object for reading objects. The objects will be
     read from buf. Use the What() method to get the message type.

~TMessage()

     Clean up compression buffer.

void Forward()

     Change a buffer that was received into one that can be send, i.e.
     forward a just received message.

void Reset()

     Reset the message buffer so we can use (i.e. fill) it again.

void SetLength() const

     Set the message length at the beginning of the message buffer.
     This method is only called by TSocket::Send().

void SetWhat(UInt_t what)

     Using this method one can change the message type a-posteriory.
     In case you OR "what" with kMESS_ACK, the message will wait for
     an acknowledgement from the remote side. This makes the sending
     process synchronous.

void SetCompressionLevel(Int_t level)

     Set the message compression level. Can be between 0 and 9 with 0
     being no compression and 9 maximum compression. In general the default
     level of 1 is the best compromise between achieved compression and
     cpu time. Compression will only happen when the message is > 256 bytes.

Int_t Compress()

     Compress the message. The message will only be compressed if the
     compression level > 0 and the if the message is > 256 bytes.
     Returns -1 in case of error (when compression fails or
     when the message increases in size in some pathological cases),
     otherwise returns 0.

Int_t Uncompress()

     Uncompress the message. The message will only be uncompressed when
     kMESS_ZIP is set. Returns -1 in case of error, 0 otherwise.

### Inline Functions

                   void operator=(const TMessage&)
               TMessage TMessage(UInt_t what = kMESS_ANY)
                TClass* GetClass() const
                   void Reset(UInt_t what)
                 UInt_t What() const
                  Int_t GetCompressionLevel() const
                  char* CompBuffer() const
                  Int_t CompLength() const
                TClass* Class()
                TClass* IsA() const
                   void ShowMembers(TMemberInspector& insp, char* parent)
                   void Streamer(TBuffer& b)
                   void StreamerNVirtual(TBuffer& b)

Author: Fons Rademakers 19/12/96
Last update: root/net:$Name: $:$Id: TMessage.cxx,v 1.6 2004/05/07 09:51:58 brun Exp $
Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *