KaliVeda
Toolkit for HIC analysis
KVZMQMessage.h
1 #ifndef KVZMQMESSAGE_H
2 #define KVZMQMESSAGE_H
3 #include "TMessage.h"
4 #include "TClass.h"
5 #include "zmq.hpp"
6 #include "KVConfig.h"
7 
46 class KVZMQMessage : public TMessage {
47  std::unique_ptr<TObject> fObject;
49  zmq::message_t fMessage;
50 
51 public:
54  {
56  }
57  KVZMQMessage(zmq::message_t& g)
58  : TMessage(g.data(), g.size())
59  {
64  }
65  virtual ~KVZMQMessage() {}
66 #if ROOT_VERSION_CODE < ROOT_VERSION(6,12,0)
67  virtual void WriteObject(const TObject* obj)
68  {
70 #else
71  virtual void WriteObject(const TObject* obj, Bool_t cacheReuse = kTRUE)
72  {
73  TMessage::WriteObject(obj, cacheReuse);
74 #endif
75  SetLength();
76  }
77  zmq::message_t& GetMessage()
78  {
79  fMessage.rebuild(Buffer(), Length());
80  return fMessage;
81  }
83  {
84  if (fReadNewObject) {
85  fObject.reset(ReadObject(GetClass()));
87  }
88  return fObject.get();
89  }
90  template <class T>
92  {
93  if (GetClass()->InheritsFrom(T::Class())) {
94  return (T*)(GetObject());
95  }
96  return nullptr;
97  }
98 };
99 
100 #endif // KVMESSAGE_H
kMESS_OBJECT
size_t size(const MatrixT &matrix)
bool Bool_t
constexpr Bool_t kFALSE
constexpr Bool_t kTRUE
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t g
Allow to send/receive ROOT/KV objects between ZeroMQ sockets.
Definition: KVZMQMessage.h:46
KVZMQMessage(zmq::message_t &g)
Definition: KVZMQMessage.h:57
virtual void WriteObject(const TObject *obj, Bool_t cacheReuse=kTRUE)
Definition: KVZMQMessage.h:71
zmq::message_t fMessage
Definition: KVZMQMessage.h:49
virtual ~KVZMQMessage()
Definition: KVZMQMessage.h:65
T * GetObject()
Definition: KVZMQMessage.h:91
zmq::message_t & GetMessage()
Definition: KVZMQMessage.h:77
std::unique_ptr< TObject > fObject
Definition: KVZMQMessage.h:47
Bool_t fReadNewObject
Definition: KVZMQMessage.h:48
TObject * GetObject()
Definition: KVZMQMessage.h:82
TObject * ReadObject(const TClass *cl) override
Int_t WriteObject(const T *objptr, Bool_t cacheReuse=kTRUE)
Int_t Length() const
char * Buffer() const
void SetLength() const
TClass * GetClass() const
virtual Bool_t InheritsFrom(const char *classname) const
void ResetBit(UInt_t f)
double T(double x)