Belle II Software development
StreamHelper Class Reference

Helper class for data store serialization. More...

#include <StreamHelper.h>

Public Member Functions

void initialize (int compressionLevel, bool handleMergeable)
 Initialize this class. Call this e.g. in the first event.
 
std::unique_ptr< EvtMessagestream (bool addPersistentDurability=true, bool streamTransientObjects=true)
 Stream the data store into an event message.
 
void read (std::unique_ptr< ZMQNoIdMessage > message)
 Read in a ZMQ message and rebuilt the data store from it.
 

Private Attributes

std::unique_ptr< DataStoreStreamerm_streamer
 The data store streamer to use.
 
StoreObjPtr< RandomGeneratorm_randomGenerator
 The random generator object in the data store that we need to transport also.
 

Detailed Description

Helper class for data store serialization.

Definition at line 23 of file StreamHelper.h.

Member Function Documentation

◆ initialize()

void initialize ( int  compressionLevel,
bool  handleMergeable 
)

Initialize this class. Call this e.g. in the first event.

Definition at line 18 of file StreamHelper.cc.

19{
20 gSystem->Load("libdataobjects");
21 m_streamer = std::make_unique<DataStoreStreamer>(compressionLevel, handleMergeable);
22
23 if ((Environment::Instance().getStreamingObjects()).size() > 0) {
24 m_streamer->setStreamingObjects(Environment::Instance().getStreamingObjects());
25 B2INFO("Tx: Streaming objects limited : " << (Environment::Instance().getStreamingObjects()).size() << " objects");
26 }
27}
static Environment & Instance()
Static method to get a reference to the Environment instance.
Definition: Environment.cc:28
std::unique_ptr< DataStoreStreamer > m_streamer
The data store streamer to use.
Definition: StreamHelper.h:34

◆ read()

void read ( std::unique_ptr< ZMQNoIdMessage message)

Read in a ZMQ message and rebuilt the data store from it.

Definition at line 41 of file StreamHelper.cc.

42{
43 EvtMessage eventMessage(message->getMessagePartAsCharArray<ZMQNoIdMessage::c_data>());
44 m_streamer->restoreDataStore(&eventMessage);
45
46 if (m_randomGenerator.isValid()) {
48 }
49}
Class to manage streamed object.
Definition: EvtMessage.h:59
static RandomGenerator & getEventRandomGenerator()
return reference to the event dependent random generator
Definition: RandomNumbers.h:73
StoreObjPtr< RandomGenerator > m_randomGenerator
The random generator object in the data store that we need to transport also.
Definition: StreamHelper.h:36
static constexpr const unsigned int c_data
Where the data is stored.

◆ stream()

std::unique_ptr< EvtMessage > stream ( bool  addPersistentDurability = true,
bool  streamTransientObjects = true 
)

Stream the data store into an event message.

Definition at line 29 of file StreamHelper.cc.

30{
31 if (m_randomGenerator.isOptional()) {
32 if (not m_randomGenerator.isValid()) {
34 } else {
36 }
37 }
38 return std::unique_ptr<EvtMessage>(m_streamer->streamDataStore(addPersistentDurability, streamTransientObjects));
39}

Member Data Documentation

◆ m_randomGenerator

StoreObjPtr<RandomGenerator> m_randomGenerator
private

The random generator object in the data store that we need to transport also.

Definition at line 36 of file StreamHelper.h.

◆ m_streamer

std::unique_ptr<DataStoreStreamer> m_streamer
private

The data store streamer to use.

Definition at line 34 of file StreamHelper.h.


The documentation for this class was generated from the following files: