15 #ifndef FAIRMQUNPACKER_H
16 #define FAIRMQUNPACKER_H
20 #include <FairMQDevice.h>
26 template<
typename UnpackerType,
typename SerializationType = RootSerializer>
53 const std::string& channelName)
56 LOG(error) <<
"Only one input channel allowed for this device";
58 SubEvtKey key(type, subType, procid, subCrate, control);
62 LOG(warn) <<
"FairMQLmdSampler : subevent header key '(" << type <<
"," << subType <<
"," << procid
63 <<
"," << subCrate <<
"," << control <<
")' has already been defined. "
73 fType = fConfig->GetValue<
short>(
"lmd-type");
74 fSubType = fConfig->GetValue<
short>(
"lmd-sub-type");
75 fProcId = fConfig->GetValue<
short>(
"lmd-proc-id");
76 fSubCrate = fConfig->GetValue<
short>(
"lmd-sub-crate");
77 fControl = fConfig->GetValue<
short>(
"lmd-control");
87 throw std::runtime_error(std::string(
"Sub-event map not configured."));
93 +
"' does not exist. Check the MQ-channel configuration");
102 fUnpacker =
new UnpackerType(setype, sesubtype, seprocid, sesubcrate, secontrol);
110 while (!NewStatePending()) {
111 FairMQMessagePtr msgSize(NewMessage());
112 FairMQMessagePtr msg(NewMessage());
114 if (inputChannel.Receive(msgSize) >= 0) {
115 if (inputChannel.Receive(msg) >= 0) {
116 int dataSize = *(
static_cast<int*
>(msgSize->GetData()));
117 int* subEvtPtr =
static_cast<int*
>(msg->GetData());
125 fUnpacker->DoUnpack(subEvtPtr, dataSize);
126 Serialize<SerializationType>(*msg,
fUnpacker->GetOutputData());
134 typedef std::tuple<short, short, short, short, short>
SubEvtKey;
virtual ~FairMQUnpacker()
std::string fInputChanName
std::string fInputChannelName
void AddSubEvtKey(short type, short subType, short procid, short subCrate, short control, const std::string &channelName)
std::map< std::string, SubEvtKey > fSubEventChanMap
std::string fOutputChanName
std::tuple< short, short, short, short, short > SubEvtKey
FairMQUnpacker operator=(const FairMQUnpacker &)=delete