Logo ROOT   6.12/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 #include "TBufferFile.h"
26 #include "MessageTypes.h"
27 #include "TBits.h"
28 
29 class TList;
31 
32 class TMessage : public TBufferFile {
33 
34 friend class TAuthenticate;
35 friend class TSocket;
36 friend class TUDPSocket;
37 friend class TPSocket;
38 friend class TXSocket;
39 
40 private:
41  TList *fInfos; //List of TStreamerInfo used in WriteObject
42  TBits fBitsPIDs; //Array of bits to mark the TProcessIDs uids written to the message
43  UInt_t fWhat; //Message type
44  TClass *fClass; //If message is kMESS_OBJECT pointer to object's class
45  Int_t fCompress; //Compression level and algorithm
46  char *fBufComp; //Compressed buffer
47  char *fBufCompCur; //Current position in compressed buffer
48  char *fCompPos; //Position of fBufCur when message was compressed
49  Bool_t fEvolution; //True if support for schema evolution required
50 
51  static Bool_t fgEvolution; //True if global support for schema evolution required
52 
53  // TMessage objects cannot be copied or assigned
54  TMessage(const TMessage &); // not implemented
55  void operator=(const TMessage &); // not implemented
56 
57  // used by friend TSocket
58  Bool_t TestBitNumber(UInt_t bitnumber) const { return fBitsPIDs.TestBitNumber(bitnumber); }
59 
60 protected:
61  TMessage(void *buf, Int_t bufsize); // only called by T(P)Socket::Recv()
62  void SetLength() const; // only called by T(P)Socket::Send()
63 
64 public:
66  virtual ~TMessage();
67 
68  void ForceWriteInfo(TVirtualStreamerInfo *info, Bool_t force);
69  void Forward();
70  TClass *GetClass() const { return fClass;}
72  void Reset();
73  void Reset(UInt_t what) { SetWhat(what); Reset(); }
74  UInt_t What() const { return fWhat; }
75  void SetWhat(UInt_t what);
76 
77  void EnableSchemaEvolution(Bool_t enable = kTRUE) { fEvolution = enable; }
79  TList *GetStreamerInfos() const { return fInfos; }
81  Int_t GetCompressionLevel() const;
83  void SetCompressionAlgorithm(Int_t algorithm=0);
84  void SetCompressionLevel(Int_t level=1);
85  void SetCompressionSettings(Int_t settings=1);
86  Int_t Compress();
87  Int_t Uncompress();
88  char *CompBuffer() const { return fBufComp; }
89  Int_t CompLength() const { return (Int_t)(fBufCompCur - fBufComp); }
91 
92  static void EnableSchemaEvolutionForAll(Bool_t enable = kTRUE);
94 
95  ClassDef(TMessage,0) // Message buffer class
96 };
97 
98 //______________________________________________________________________________
100 {
101  return (fCompress < 0) ? -1 : fCompress / 100;
102 }
103 
104 //______________________________________________________________________________
106 {
107  return (fCompress < 0) ? -1 : fCompress % 100;
108 }
109 
110 //______________________________________________________________________________
112 {
113  return (fCompress < 0) ? -1 : fCompress;
114 }
115 
116 #endif
void SetCompressionSettings(Int_t settings=1)
Definition: TMessage.cxx:281
TClass * GetClass() const
Definition: TMessage.h:70
Int_t Compress()
Compress the message.
Definition: TMessage.cxx:299
Bool_t UsesSchemaEvolution() const
Definition: TMessage.h:78
The concrete implementation of TBuffer for writing/reading to/from a ROOT file or socket...
Definition: TBufferFile.h:47
char * CompBuffer() const
Definition: TMessage.h:88
static Bool_t fgEvolution
Definition: TMessage.h:51
TMessage(const TMessage &)
unsigned short UShort_t
Definition: RtypesCore.h:36
UInt_t fWhat
Definition: TMessage.h:43
Int_t GetCompressionAlgorithm() const
Definition: TMessage.h:99
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:237
static Bool_t UsesSchemaEvolutionForAll()
Static function returning status of global schema evolution.
Definition: TMessage.cxx:124
char * fBufCompCur
Definition: TMessage.h:47
void TagStreamerInfo(TVirtualStreamerInfo *info)
Remember that the StreamerInfo is being used in writing.
Definition: TMessage.cxx:167
TClass * fClass
Definition: TMessage.h:44
char * fBufComp
Definition: TMessage.h:46
#define ClassDef(name, id)
Definition: Rtypes.h:320
void SetWhat(UInt_t what)
Using this method one can change the message type a-posteriory.
Definition: TMessage.cxx:220
Int_t CompLength() const
Definition: TMessage.h:89
A TProcessID identifies a ROOT job in a unique way in time and space.
Definition: TProcessID.h:69
Bool_t TestBitNumber(UInt_t bitnumber) const
Definition: TBits.h:219
A doubly linked list.
Definition: TList.h:44
void Reset()
Reset the message buffer so we can use (i.e. fill) it again.
Definition: TMessage.cxx:178
void Reset(UInt_t what)
Definition: TMessage.h:73
High level handler of connections to XProofD.
Definition: TXSocket.h:59
unsigned int UInt_t
Definition: RtypesCore.h:42
Int_t Uncompress()
Uncompress the message.
Definition: TMessage.cxx:379
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:75
TList * fInfos
Definition: TMessage.h:41
Bool_t fEvolution
Definition: TMessage.h:49
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:77
UInt_t What() const
Definition: TMessage.h:74
UShort_t WriteProcessID(TProcessID *pid)
Check if the ProcessID pid is already in the message.
Definition: TMessage.cxx:428
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:105
char * fCompPos
Definition: TMessage.h:48
Container of bits.
Definition: TBits.h:29
void SetLength() const
Set the message length at the beginning of the message buffer.
Definition: TMessage.cxx:201
TBits fBitsPIDs
Definition: TMessage.h:42
void SetCompressionLevel(Int_t level=1)
Definition: TMessage.cxx:258
Int_t GetCompressionSettings() const
Definition: TMessage.h:111
virtual ~TMessage()
Clean up compression buffer.
Definition: TMessage.cxx:106
TList * GetStreamerInfos() const
Definition: TMessage.h:79
Bool_t TestBitNumber(UInt_t bitnumber) const
Definition: TMessage.h:58
Abstract Interface class describing Streamer information for one class.
void Forward()
Change a buffer that was received into one that can be send, i.e.
Definition: TMessage.cxx:144
const Bool_t kTRUE
Definition: RtypesCore.h:87
Int_t fCompress
Definition: TMessage.h:45