Logo ROOT  
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 "Compression.h"
26 #include "TBufferFile.h"
27 #include "MessageTypes.h"
28 #include "TBits.h"
29 
30 class TList;
32 
33 class TMessage : public TBufferFile {
34 
35 friend class TAuthenticate;
36 friend class TSocket;
37 friend class TUDPSocket;
38 friend class TPSocket;
39 friend class TXSocket;
40 
41 private:
42  TList *fInfos{nullptr}; // List of TStreamerInfo used in WriteObject
43  TBits fBitsPIDs; // Array of bits to mark the TProcessIDs uids written to the message
44  UInt_t fWhat{0}; // Message type
45  TClass *fClass{nullptr}; // If message is kMESS_OBJECT pointer to object's class
46  Int_t fCompress{0}; // Compression level and algorithm
47  char *fBufComp{nullptr}; // Compressed buffer
48  char *fBufCompCur{nullptr}; // Current position in compressed buffer
49  char *fCompPos{nullptr}; // Position of fBufCur when message was compressed
50  Bool_t fEvolution{kFALSE}; // True if support for schema evolution required
51 
52  static Bool_t fgEvolution; //True if global support for schema evolution required
53 
54  // TMessage objects cannot be copied or assigned
55  TMessage(const TMessage &); // not implemented
56  void operator=(const TMessage &); // not implemented
57 
58  // used by friend TSocket
59  Bool_t TestBitNumber(UInt_t bitnumber) const { return fBitsPIDs.TestBitNumber(bitnumber); }
60 
61 protected:
62  TMessage(void *buf, Int_t bufsize); // only called by T(P)Socket::Recv()
63  void SetLength() const; // only called by T(P)Socket::Send()
64 
65 public:
67  virtual ~TMessage();
68 
69  void ForceWriteInfo(TVirtualStreamerInfo *info, Bool_t force) override;
70  void Forward();
71  TClass *GetClass() const { return fClass;}
72  void TagStreamerInfo(TVirtualStreamerInfo* info) override;
73  void Reset() override;
74  void Reset(UInt_t what) { SetWhat(what); Reset(); }
75  UInt_t What() const { return fWhat; }
76  void SetWhat(UInt_t what);
77 
78  void EnableSchemaEvolution(Bool_t enable = kTRUE) { fEvolution = enable; }
80  TList *GetStreamerInfos() const { return fInfos; }
82  Int_t GetCompressionLevel() const;
87  Int_t Compress();
88  Int_t Uncompress();
89  char *CompBuffer() const { return fBufComp; }
90  Int_t CompLength() const { return (Int_t)(fBufCompCur - fBufComp); }
91  UShort_t WriteProcessID(TProcessID *pid) override;
92 
93  static void EnableSchemaEvolutionForAll(Bool_t enable = kTRUE);
95 
96  ClassDefOverride(TMessage,0) // Message buffer class
97 };
98 
99 //______________________________________________________________________________
101 {
102  return (fCompress < 0) ? -1 : fCompress / 100;
103 }
104 
105 //______________________________________________________________________________
107 {
108  return (fCompress < 0) ? -1 : fCompress % 100;
109 }
110 
111 //______________________________________________________________________________
113 {
114  return (fCompress < 0) ? -1 : fCompress;
115 }
116 
117 #endif
TMessage::SetCompressionAlgorithm
void SetCompressionAlgorithm(Int_t algorithm=ROOT::RCompressionSetting::EAlgorithm::kUseGlobal)
Set compression algorithm.
Definition: TMessage.cxx:242
TMessage::~TMessage
virtual ~TMessage()
Destructor.
Definition: TMessage.cxx:106
Compression.h
TUDPSocket
Definition: TUDPSocket.h:37
TXSocket
High level handler of connections to XProofD.
Definition: TXSocket.h:59
TMessage::SetCompressionLevel
void SetCompressionLevel(Int_t level=ROOT::RCompressionSetting::ELevel::kUseMin)
Set compression level.
Definition: TMessage.cxx:264
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:100
ROOT::RCompressionSetting::ELevel::kUseMin
@ kUseMin
Compression level reserved when we are not sure what to use (1 is for the fastest compression)
Definition: Compression.h:68
ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault
@ kUseCompiledDefault
Use the compile-time default setting.
Definition: Compression.h:50
UShort_t
unsigned short UShort_t
Definition: RtypesCore.h:40
TProcessID
A TProcessID identifies a ROOT job in a unique way in time and space.
Definition: TProcessID.h:74
Int_t
int Int_t
Definition: RtypesCore.h:45
MessageTypes.h
TMessage::TestBitNumber
Bool_t TestBitNumber(UInt_t bitnumber) const
Definition: TMessage.h:59
TBits::TestBitNumber
Bool_t TestBitNumber(UInt_t bitnumber) const
Definition: TBits.h:222
TBits
Container of bits.
Definition: TBits.h:26
TMessage::Compress
Int_t Compress()
Compress the message.
Definition: TMessage.cxx:306
TMessage::What
UInt_t What() const
Definition: TMessage.h:75
TAuthenticate
Definition: TAuthenticate.h:53
TMessage::TagStreamerInfo
void TagStreamerInfo(TVirtualStreamerInfo *info) override
Remember that the StreamerInfo is being used in writing.
Definition: TMessage.cxx:168
ClassDefOverride
#define ClassDefOverride(name, id)
Definition: Rtypes.h:329
TMessage::GetCompressionAlgorithm
Int_t GetCompressionAlgorithm() const
Definition: TMessage.h:100
Bool_t
bool Bool_t
Definition: RtypesCore.h:63
TMessage::fInfos
TList * fInfos
Definition: TMessage.h:42
TMessage::fCompress
Int_t fCompress
Definition: TMessage.h:46
TVirtualStreamerInfo
Abstract Interface class describing Streamer information for one class.
Definition: TVirtualStreamerInfo.h:37
bool
TMessage::fBufCompCur
char * fBufCompCur
Definition: TMessage.h:48
TMessage::TMessage
TMessage(const TMessage &)
TMessage::SetCompressionSettings
void SetCompressionSettings(Int_t settings=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault)
Set compression settings.
Definition: TMessage.cxx:288
TSocket
Definition: TSocket.h:41
TMessage::CompLength
Int_t CompLength() const
Definition: TMessage.h:90
TMessage::EnableSchemaEvolutionForAll
static void EnableSchemaEvolutionForAll(Bool_t enable=kTRUE)
Static function enabling or disabling the automatic schema evolution.
Definition: TMessage.cxx:116
TMessage::GetCompressionSettings
Int_t GetCompressionSettings() const
Definition: TMessage.h:112
TMessage::fClass
TClass * fClass
Definition: TMessage.h:45
TMessage::fBufComp
char * fBufComp
Definition: TMessage.h:47
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:101
TMessage::fEvolution
Bool_t fEvolution
Definition: TMessage.h:50
what
static const char * what
Definition: stlLoader.cc:6
kMESS_ANY
@ kMESS_ANY
Definition: MessageTypes.h:31
UInt_t
unsigned int UInt_t
Definition: RtypesCore.h:46
TMessage::GetCompressionLevel
Int_t GetCompressionLevel() const
Definition: TMessage.h:106
TMessage::Reset
void Reset(UInt_t what)
Definition: TMessage.h:74
ROOT::RCompressionSetting::EAlgorithm::kUseGlobal
@ kUseGlobal
Use the global compression algorithm.
Definition: Compression.h:88
TMessage::UsesSchemaEvolutionForAll
static Bool_t UsesSchemaEvolutionForAll()
Static function returning status of global schema evolution.
Definition: TMessage.cxx:124
TMessage::UsesSchemaEvolution
Bool_t UsesSchemaEvolution() const
Definition: TMessage.h:79
TMessage::Uncompress
Int_t Uncompress()
Uncompress the message.
Definition: TMessage.cxx:391
unsigned int
TMessage::CompBuffer
char * CompBuffer() const
Definition: TMessage.h:89
TMessage::GetStreamerInfos
TList * GetStreamerInfos() const
Definition: TMessage.h:80
TMessage::fCompPos
char * fCompPos
Definition: TMessage.h:49
TMessage::Reset
void Reset() override
Reset the message buffer so we can use (i.e. fill) it again.
Definition: TMessage.cxx:179
TPSocket
Definition: TPSocket.h:33
TMessage::SetLength
void SetLength() const
Set the message length at the beginning of the message buffer.
Definition: TMessage.cxx:202
TMessage::SetWhat
void SetWhat(UInt_t what)
Using this method one can change the message type a-posteriori In case you OR "what" with kMESS_ACK,...
Definition: TMessage.cxx:222
TBits.h
TClass
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition: TClass.h:80
TMessage::ForceWriteInfo
void ForceWriteInfo(TVirtualStreamerInfo *info, Bool_t force) override
Force writing the TStreamerInfo to the message.
Definition: TMessage.cxx:132
TMessage::fBitsPIDs
TBits fBitsPIDs
Definition: TMessage.h:43
TBufferFile.h
TMessage::fgEvolution
static Bool_t fgEvolution
Definition: TMessage.h:52
TMessage::GetClass
TClass * GetClass() const
Definition: TMessage.h:71
TMessage::Forward
void Forward()
Change a buffer that was received into one that can be send, i.e.
Definition: TMessage.cxx:144
TMessage::WriteProcessID
UShort_t WriteProcessID(TProcessID *pid) override
Check if the ProcessID pid is already in the message.
Definition: TMessage.cxx:440
TMessage
Definition: TMessage.h:33
TMessage::fWhat
UInt_t fWhat
Definition: TMessage.h:44
TMessage::operator=
void operator=(const TMessage &)
TMessage::EnableSchemaEvolution
void EnableSchemaEvolution(Bool_t enable=kTRUE)
Definition: TMessage.h:78
TBufferFile
The concrete implementation of TBuffer for writing/reading to/from a ROOT file or socket.
Definition: TBufferFile.h:47
TBuffer::kInitialSize
@ kInitialSize
Definition: TBuffer.h:78
TList
A doubly linked list.
Definition: TList.h:44
int