1 #include <TVirtualStreamerInfo.h>
6 #include "AliNetMessage.h"
8 Bool_t AliNetMessage::fgEvolution = kFALSE;
10 ClassImp(AliNetMessage)
12 //______________________________________________________________________________
13 AliNetMessage::AliNetMessage(UInt_t what)
22 // Create a AliNetMessage object for storing objects. The "what" integer
23 // describes the type of message. Predifined ROOT system message types
24 // can be found in MessageTypes.h. Make sure your own message types are
25 // unique from the ROOT defined message types (i.e. 0 - 10000 are
26 // reserved by ROOT). In case you OR "what" with kMESS_ACK, the message
27 // will wait for an acknowledgement from the remote side. This makes
28 // the sending process synchronous. In case you OR "what" with kMESS_ZIP,
29 // the message will be compressed in TSocket using the zip algorithm
30 // (only if message is > 256 bytes).
32 // space at the beginning of the message reserved for the message length
38 SetBit(kCannotHandleMemberWiseStreaming);
42 //______________________________________________________________________________
43 AliNetMessage::AliNetMessage(void *buf, Int_t bufsize)
45 TBufferFile(kRead, bufsize, buf),
52 // Create a AliNetMessage object for reading objects. The objects will be
53 // read from buf. Use the What() method to get the message type.
55 // skip space at the beginning of the message reserved for the message length
56 fBufCur += sizeof(UInt_t);
60 if (fWhat == kMESS_OBJECT) {
62 fClass = ReadClass(); // get first the class stored in message
63 SetBufferOffset(sizeof(UInt_t) + sizeof(fWhat));
70 //______________________________________________________________________________
71 AliNetMessage::~AliNetMessage()
77 //______________________________________________________________________________
78 void AliNetMessage::EnableSchemaEvolutionForAll(Bool_t enable)
80 // Static function enabling or disabling the automatic schema evolution.
81 // By default schema evolution support is off.
86 //______________________________________________________________________________
87 Bool_t AliNetMessage::UsesSchemaEvolutionForAll()
89 // Static function returning status of global schema evolution.
94 //______________________________________________________________________________
95 void AliNetMessage::ForceWriteInfo(TVirtualStreamerInfo *info, Bool_t /* force */)
97 // Force writing the TStreamerInfo to the message.
99 if (fgEvolution || fEvolution) {
100 if (!fInfos) fInfos = new TList();
105 //______________________________________________________________________________
106 void AliNetMessage::Forward()
108 // Change a buffer that was received into one that can be send, i.e.
109 // forward a just received message.
113 SetBufferOffset(fBufSize);
114 SetBit(kCannotHandleMemberWiseStreaming);
118 //______________________________________________________________________________
119 void AliNetMessage::TagStreamerInfo(TVirtualStreamerInfo *info)
121 // Remember that the StreamerInfo is being used in writing.
123 if (fgEvolution || fEvolution) {
124 if (!fInfos) fInfos = new TList();
129 //______________________________________________________________________________
130 void AliNetMessage::IncrementLevel(TVirtualStreamerInfo *info)
134 TBufferFile::IncrementLevel(info);
137 if (fgEvolution || fEvolution) {
138 if (!fInfos) fInfos = new TList();
140 // add the streamer info, but only once
141 // this assumes that there is only one version
142 if (fInfos->FindObject(info->GetName())==NULL) {
148 //______________________________________________________________________________
149 void AliNetMessage::Reset()
151 // Reset the message buffer so we can use (i.e. fill) it again.
153 SetBufferOffset(sizeof(UInt_t) + sizeof(fWhat));
156 if (fBufUncompressed) {
157 delete [] fBufUncompressed;
158 fBufUncompressed=NULL;
162 //______________________________________________________________________________
163 void AliNetMessage::SetLength() const
165 // Set the message length at the beginning of the message buffer.
168 char *buf = Buffer();
169 *((UInt_t*)buf) = (UInt_t)(Length() - sizeof(UInt_t));
173 //______________________________________________________________________________
174 void AliNetMessage::SetWhat(UInt_t what)
176 // Using this method one can change the message type a-posteriory.
177 // In case you OR "what" with kMESS_ACK, the message will wait for
178 // an acknowledgement from the remote side. This makes the sending
179 // process synchronous.
183 char *buf = Buffer();
184 buf += sizeof(UInt_t); // skip reserved length space
188 //______________________________________________________________________________
189 void AliNetMessage::WriteObject(const TObject *obj)
191 // Write object to message buffer.
192 // When support for schema evolution is enabled the list of TStreamerInfo
193 // used to stream this object is kept in fInfos. This information is used
194 // by TSocket::Send that sends this list through the socket. This list is in
195 // turn used by TSocket::Recv to store the TStreamerInfo objects in the
196 // relevant TClass in case the TClass does not know yet about a particular
197 // class version. This feature is implemented to support clients and servers
198 // with either different ROOT versions or different user classes versions.
200 if (fgEvolution || fEvolution) {
204 fInfos = new TList();
207 WriteObjectAny(obj, TObject::Class());