3 /** @file AliHLTMessage.h
4 @author Matthias Richter (customization of Root TMessage )
6 @brief Serialization of Root objects in the ALICE HLT. */
8 // This is the original Root TMessage implementation with a few minor
9 // modifications, original revision:
10 // root/net: v5-14-00 $: TMessage.h,v 1.9 2005/12/09 15:12:19 rdm
11 // Author: Fons Rademakers 19/12/96
13 /*************************************************************************
14 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
15 * All rights reserved. *
17 * For the licensing terms see $ROOTSYS/LICENSE. *
18 * For the list of contributors see $ROOTSYS/README/CREDITS. *
19 *************************************************************************/
21 #ifndef ALIHLTMESSAGE_H
22 #define ALIHLTMESSAGE_H
25 //////////////////////////////////////////////////////////////////////////
29 // Message buffer class used for serializing objects and sending them //
30 // over the network. //
32 //////////////////////////////////////////////////////////////////////////
34 // TBuffer has been made pure virtual in root version v5-15-02, this
35 // requires to inherit from TBufferFile instead of TBuffer.
36 // TMessage is not really used by this class but by including it we also get
37 // TBufferFile if this exists. The define ROOT_TBufferFile can than be used
38 // to differentiate between the usage of TBuffer or TBufferFile.
41 #ifndef ROOT_MessageTypes
42 #include "MessageTypes.h"
45 #include "AliHLTLogging.h"
47 * @class AliHLTMessage
48 * Serialization of Root objects for transport in the Alice HLT analysis
50 * This is the original Root TMessage implementation with a few minor
52 * - the <tt> AliHLTMessage(void *buf, Int_t bufsize)</tt> constructor has been
53 * made public in order to be used externally.
55 * The class can be used to extract an object from an input data block, or a
56 * data block received via the HOMER interface or from the file writer.
58 * AliHLTMessage msg(buffer, size);
59 * TObject* pObj=msg.ReadObject(msg.GetClass());
62 * A simple test macro for a file can look like
64 * const char* filename="TPC_804.ddl";
65 * //const char* filename="TPC_768.ddl";
66 * TString param=filename;
67 * param+="?filetype=raw";
69 * if (file.IsZombie()) {
70 * cout << "can not open file " << filename << endl;
74 * TArrayC buffer(file.GetSize());
75 * TArrayC tgtbuffer(file.GetSize());
76 * if (file.ReadBuffer(buffer.GetArray(), buffer.GetSize())) {
77 * cout << "error reading file " << filename << endl;
81 * AliHLTMessage msg(buffer.GetArray(), buffer.GetSize());
82 * TObject* pObj=msg.ReadObject(msg.GetClass());
85 * @see AliHLTRootFileWriterComponent for an easy way to save objects
86 * exported via AliHLTMessage in a ROOT file.
90 # if defined(ROOT_TBufferFile)
95 public AliHLTLogging {
98 AliHLTMessage(UInt_t what = kMESS_ANY);
99 AliHLTMessage(void *buf, Int_t bufsize);
100 virtual ~AliHLTMessage();
102 void SetLength() const;
105 TClass *GetClass() const { return fClass; }
107 void Reset(UInt_t what) { SetWhat(what); Reset(); }
108 UInt_t What() const { return fWhat; }
109 void SetWhat(UInt_t what);
111 void SetCompressionLevel(Int_t level = 1);
112 Int_t GetCompressionLevel() const { return fCompress; }
115 char *CompBuffer() const { return fBufComp; }
116 Int_t CompLength() const { return (Int_t)(fBufCompCur - fBufComp); }
119 UInt_t fWhat; //Message type
120 TClass *fClass; //If message is kMESS_OBJECT pointer to object's class
121 Int_t fCompress; //Compression level from 0 (not compressed) to 9 (max compression)
122 char *fBufComp; //Compressed buffer
123 char *fBufCompCur; //Current position in compressed buffer
124 char *fCompPos; //Position of fBufCur when message was compressed
126 // AliHLTMessage objects cannot be copied or assigned
127 AliHLTMessage(const AliHLTMessage &); // not implemented
128 void operator=(const AliHLTMessage &); // not implemented
130 ClassDef(AliHLTMessage,0) // Message buffer class
133 #endif // ALIHLTMESSAGE_H