Logo ROOT   6.08/07
Reference Guide
TMessage.h
Go to the documentation of this file.
1 // @(#)root/net:$Id$
2 // Author: Fons Rademakers 19/12/96
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TMessage
13 #define ROOT_TMessage
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TMessage //
19 // //
20 // Message buffer class used for serializing objects and sending them //
21 // over the network. //
22 // //
23 //////////////////////////////////////////////////////////////////////////
24 
25 #ifndef ROOT_TBufferFile
26 #include "TBufferFile.h"
27 #endif
28 #ifndef ROOT_MessageTypes
29 #include "MessageTypes.h"
30 #endif
31 #ifndef ROOT_TBits
32 #include "TBits.h"
33 #endif
34 
35 class TList;
37 
38 class TMessage : public TBufferFile {
39 
40 friend class TAuthenticate;
41 friend class TSocket;
42 friend class TUDPSocket;
43 friend class TPSocket;
44 friend class TXSocket;
45 
46 private:
47  TList *fInfos; //List of TStreamerInfo used in WriteObject
48  TBits fBitsPIDs; //Array of bits to mark the TProcessIDs uids written to the message
49  UInt_t fWhat; //Message type
50  TClass *fClass; //If message is kMESS_OBJECT pointer to object's class
51  Int_t fCompress; //Compression level and algorithm
52  char *fBufComp; //Compressed buffer
53  char *fBufCompCur; //Current position in compressed buffer
54  char *fCompPos; //Position of fBufCur when message was compressed
55  Bool_t fEvolution; //True if support for schema evolution required
56 
57  static Bool_t fgEvolution; //True if global support for schema evolution required
58 
59  // TMessage objects cannot be copied or assigned
60  TMessage(const TMessage &); // not implemented
61  void operator=(const TMessage &); // not implemented
62 
63  // used by friend TSocket
64  Bool_t TestBitNumber(UInt_t bitnumber) const { return fBitsPIDs.TestBitNumber(bitnumber); }
65 
66 protected:
67  TMessage(void *buf, Int_t bufsize); // only called by T(P)Socket::Recv()
68  void SetLength() const; // only called by T(P)Socket::Send()
69 
70 public:
72  virtual ~TMessage();
73 
74  void ForceWriteInfo(TVirtualStreamerInfo *info, Bool_t force);
75  void Forward();
76  TClass *GetClass() const { return fClass;}
78  void Reset();
79  void Reset(UInt_t what) { SetWhat(what); Reset(); }
80  UInt_t What() const { return fWhat; }
81  void SetWhat(UInt_t what);
82 
83  void EnableSchemaEvolution(Bool_t enable = kTRUE) { fEvolution = enable; }
85  TList *GetStreamerInfos() const { return fInfos; }
87  Int_t GetCompressionLevel() const;
89  void SetCompressionAlgorithm(Int_t algorithm=0);
90  void SetCompressionLevel(Int_t level=1);
91  void SetCompressionSettings(Int_t settings=1);
92  Int_t Compress();
93  Int_t Uncompress();
94  char *CompBuffer() const { return fBufComp; }
95  Int_t CompLength() const { return (Int_t)(fBufCompCur - fBufComp); }
96  void WriteObject(const TObject *obj);
98 
99  static void EnableSchemaEvolutionForAll(Bool_t enable = kTRUE);
101 
102  ClassDef(TMessage,0) // Message buffer class
103 };
104 
105 //______________________________________________________________________________
107 {
108  return (fCompress < 0) ? -1 : fCompress / 100;
109 }
110 
111 //______________________________________________________________________________
113 {
114  return (fCompress < 0) ? -1 : fCompress % 100;
115 }
116 
117 //______________________________________________________________________________
119 {
120  return (fCompress < 0) ? -1 : fCompress;
121 }
122 
123 #endif
void SetCompressionSettings(Int_t settings=1)
Definition: TMessage.cxx:268
TClass * GetClass() const
Definition: TMessage.h:76
Int_t Compress()
Compress the message.
Definition: TMessage.cxx:286
Bool_t UsesSchemaEvolution() const
Definition: TMessage.h:84
The concrete implementation of TBuffer for writing/reading to/from a ROOT file or socket...
Definition: TBufferFile.h:51
char * CompBuffer() const
Definition: TMessage.h:94
static Bool_t fgEvolution
Definition: TMessage.h:57
TMessage(const TMessage &)
unsigned short UShort_t
Definition: RtypesCore.h:36
UInt_t fWhat
Definition: TMessage.h:49
Int_t GetCompressionAlgorithm() const
Definition: TMessage.h:106
void operator=(const TMessage &)
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
void SetCompressionAlgorithm(Int_t algorithm=0)
Definition: TMessage.cxx:224
static Bool_t UsesSchemaEvolutionForAll()
Static function returning status of global schema evolution.
Definition: TMessage.cxx:124
char * fBufCompCur
Definition: TMessage.h:53
void TagStreamerInfo(TVirtualStreamerInfo *info)
Remember that the StreamerInfo is being used in writing.
Definition: TMessage.cxx:160
TClass * fClass
Definition: TMessage.h:50
char * fBufComp
Definition: TMessage.h:52
#define ClassDef(name, id)
Definition: Rtypes.h:254
void SetWhat(UInt_t what)
Using this method one can change the message type a-posteriory.
Definition: TMessage.cxx:207
Int_t CompLength() const
Definition: TMessage.h:95
A TProcessID identifies a ROOT job in a unique way in time and space.
Definition: TProcessID.h:73
Bool_t TestBitNumber(UInt_t bitnumber) const
Definition: TBits.h:223
A doubly linked list.
Definition: TList.h:47
static const char * what
Definition: stlLoader.cc:6
void Reset()
Reset the message buffer so we can use (i.e. fill) it again.
Definition: TMessage.cxx:171
void Reset(UInt_t what)
Definition: TMessage.h:79
High level handler of connections to XProofD.
Definition: TXSocket.h:73
unsigned int UInt_t
Definition: RtypesCore.h:42
Int_t Uncompress()
Uncompress the message.
Definition: TMessage.cxx:365
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:81
TList * fInfos
Definition: TMessage.h:47
Bool_t fEvolution
Definition: TMessage.h:55
static void EnableSchemaEvolutionForAll(Bool_t enable=kTRUE)
Static function enabling or disabling the automatic schema evolution.
Definition: TMessage.cxx:116
void EnableSchemaEvolution(Bool_t enable=kTRUE)
Definition: TMessage.h:83
UInt_t What() const
Definition: TMessage.h:80
UShort_t WriteProcessID(TProcessID *pid)
Check if the ProcessID pid is already in the message.
Definition: TMessage.cxx:437
void ForceWriteInfo(TVirtualStreamerInfo *info, Bool_t force)
Force writing the TStreamerInfo to the message.
Definition: TMessage.cxx:132
Int_t GetCompressionLevel() const
Definition: TMessage.h:112
char * fCompPos
Definition: TMessage.h:54
Mother of all ROOT objects.
Definition: TObject.h:37
Container of bits.
Definition: TBits.h:33
void SetLength() const
Set the message length at the beginning of the message buffer.
Definition: TMessage.cxx:188
TBits fBitsPIDs
Definition: TMessage.h:48
void WriteObject(const TObject *obj)
Write object to message buffer.
Definition: TMessage.cxx:418
void SetCompressionLevel(Int_t level=1)
Definition: TMessage.cxx:245
Int_t GetCompressionSettings() const
Definition: TMessage.h:118
virtual ~TMessage()
Clean up compression buffer.
Definition: TMessage.cxx:106
TList * GetStreamerInfos() const
Definition: TMessage.h:85
Bool_t TestBitNumber(UInt_t bitnumber) const
Definition: TMessage.h:64
Abstract Interface class describing Streamer information for one class.
const Bool_t kTRUE
Definition: Rtypes.h:91
void Forward()
Change a buffer that was received into one that can be send, i.e.
Definition: TMessage.cxx:144
Int_t fCompress
Definition: TMessage.h:51