Logo ROOT   6.18/05
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
30class TList;
32
33class TMessage : public TBufferFile {
34
35friend class TAuthenticate;
36friend class TSocket;
37friend class TUDPSocket;
38friend class TPSocket;
39friend class TXSocket;
40
41private:
42 TList *fInfos; //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; //Message type
45 TClass *fClass; //If message is kMESS_OBJECT pointer to object's class
46 Int_t fCompress; //Compression level and algorithm
47 char *fBufComp; //Compressed buffer
48 char *fBufCompCur; //Current position in compressed buffer
49 char *fCompPos; //Position of fBufCur when message was compressed
50 Bool_t fEvolution; //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
61protected:
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
65public:
67 virtual ~TMessage();
68
70 void Forward();
71 TClass *GetClass() const { return fClass;}
73 void Reset();
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; }
89 char *CompBuffer() const { return fBufComp; }
90 Int_t CompLength() const { return (Int_t)(fBufCompCur - fBufComp); }
92
93 static void EnableSchemaEvolutionForAll(Bool_t enable = kTRUE);
95
96 ClassDef(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
@ kMESS_ANY
Definition: MessageTypes.h:31
unsigned short UShort_t
Definition: RtypesCore.h:36
int Int_t
Definition: RtypesCore.h:41
unsigned int UInt_t
Definition: RtypesCore.h:42
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kTRUE
Definition: RtypesCore.h:87
#define ClassDef(name, id)
Definition: Rtypes.h:326
Container of bits.
Definition: TBits.h:27
Bool_t TestBitNumber(UInt_t bitnumber) const
Definition: TBits.h:222
The concrete implementation of TBuffer for writing/reading to/from a ROOT file or socket.
Definition: TBufferFile.h:46
@ kInitialSize
Definition: TBuffer.h:77
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition: TClass.h:75
A doubly linked list.
Definition: TList.h:44
UShort_t WriteProcessID(TProcessID *pid)
Check if the ProcessID pid is already in the message.
Definition: TMessage.cxx:436
static void EnableSchemaEvolutionForAll(Bool_t enable=kTRUE)
Static function enabling or disabling the automatic schema evolution.
Definition: TMessage.cxx:116
void Reset(UInt_t what)
Definition: TMessage.h:74
void operator=(const TMessage &)
Bool_t UsesSchemaEvolution() const
Definition: TMessage.h:79
void ForceWriteInfo(TVirtualStreamerInfo *info, Bool_t force)
Force writing the TStreamerInfo to the message.
Definition: TMessage.cxx:132
UInt_t fWhat
Definition: TMessage.h:44
UInt_t What() const
Definition: TMessage.h:75
void TagStreamerInfo(TVirtualStreamerInfo *info)
Remember that the StreamerInfo is being used in writing.
Definition: TMessage.cxx:167
char * fCompPos
Definition: TMessage.h:49
void Forward()
Change a buffer that was received into one that can be send, i.e.
Definition: TMessage.cxx:144
void SetLength() const
Set the message length at the beginning of the message buffer.
Definition: TMessage.cxx:201
void Reset()
Reset the message buffer so we can use (i.e. fill) it again.
Definition: TMessage.cxx:178
Int_t GetCompressionAlgorithm() const
Definition: TMessage.h:100
TClass * fClass
Definition: TMessage.h:45
Bool_t TestBitNumber(UInt_t bitnumber) const
Definition: TMessage.h:59
char * CompBuffer() const
Definition: TMessage.h:89
char * fBufComp
Definition: TMessage.h:47
char * fBufCompCur
Definition: TMessage.h:48
Bool_t fEvolution
Definition: TMessage.h:50
void SetCompressionSettings(Int_t settings=ROOT::RCompressionSetting::EDefaults::kUseGeneralPurpose)
Definition: TMessage.cxx:284
TList * GetStreamerInfos() const
Definition: TMessage.h:80
Int_t Compress()
Compress the message.
Definition: TMessage.cxx:302
virtual ~TMessage()
Clean up compression buffer.
Definition: TMessage.cxx:106
Int_t fCompress
Definition: TMessage.h:46
static Bool_t UsesSchemaEvolutionForAll()
Static function returning status of global schema evolution.
Definition: TMessage.cxx:124
TMessage(const TMessage &)
Int_t GetCompressionSettings() const
Definition: TMessage.h:112
void SetCompressionLevel(Int_t level=ROOT::RCompressionSetting::ELevel::kUseMin)
Definition: TMessage.cxx:261
Int_t Uncompress()
Uncompress the message.
Definition: TMessage.cxx:387
Int_t GetCompressionLevel() const
Definition: TMessage.h:106
TBits fBitsPIDs
Definition: TMessage.h:43
TList * fInfos
Definition: TMessage.h:42
Int_t CompLength() const
Definition: TMessage.h:90
static Bool_t fgEvolution
Definition: TMessage.h:52
void SetWhat(UInt_t what)
Using this method one can change the message type a-posteriory.
Definition: TMessage.cxx:221
void SetCompressionAlgorithm(Int_t algorithm=ROOT::RCompressionSetting::EAlgorithm::kUseGlobal)
Definition: TMessage.cxx:240
TClass * GetClass() const
Definition: TMessage.h:71
void EnableSchemaEvolution(Bool_t enable=kTRUE)
Definition: TMessage.h:78
A TProcessID identifies a ROOT job in a unique way in time and space.
Definition: TProcessID.h:69
Abstract Interface class describing Streamer information for one class.
High level handler of connections to XProofD.
Definition: TXSocket.h:59
@ kUseGlobal
Use the global compression algorithm.
Definition: Compression.h:81
@ kUseGeneralPurpose
Use the recommended general-purpose setting; moderate read / write speed and compression ratio.
Definition: Compression.h:53