mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-13 16:46:47 +00:00
change serialization API so that it takes a FairMQMessage reference
This commit is contained in:
parent
5f365c84c7
commit
dcb791694a
|
@ -41,13 +41,6 @@ void FairMQExample8Sampler::Run()
|
|||
LOG(INFO) << "Sending header with stopFlag: " << header->stopFlag;
|
||||
|
||||
FairMQParts parts;
|
||||
|
||||
parts.AddPart(NewMessage(header, // data pointer
|
||||
sizeof(Ex8Header), // data size
|
||||
[](void* data, void* hint) { delete static_cast<Ex8Header*>(data); } // callback to deallocate after the transfer
|
||||
));
|
||||
parts.AddPart(NewMessage(1000));
|
||||
|
||||
LOG(INFO) << "Sending body of size: " << parts.At(1)->GetSize();
|
||||
|
||||
Send(parts, "data-out");
|
||||
|
|
|
@ -19,48 +19,6 @@
|
|||
|
||||
#include "FairMQDevice.h"
|
||||
|
||||
|
||||
struct MyPoint
|
||||
{
|
||||
/* data */
|
||||
double x=6;
|
||||
double y=6;
|
||||
double z=6;
|
||||
};
|
||||
|
||||
struct Ex8Header {
|
||||
int32_t stopFlag;
|
||||
};
|
||||
|
||||
|
||||
|
||||
struct MyPointSerializer
|
||||
{
|
||||
void Serialize(std::unique_ptr<FairMQMessage>& msg, MyPoint* input)
|
||||
{
|
||||
int DataSize = sizeof(MyPoint);
|
||||
msg->Rebuild(DataSize);
|
||||
MyPoint* digiptr = reinterpret_cast<MyPoint*>(msg->GetData());
|
||||
digiptr->x=input->x;
|
||||
digiptr->y=input->y;
|
||||
digiptr->z=input->z;
|
||||
}
|
||||
|
||||
void Deserialize(std::unique_ptr<FairMQMessage>& msg, MyPoint* input)
|
||||
{
|
||||
MyPoint* digiptr = static_cast<MyPoint*>(msg->GetData());
|
||||
input->x=digiptr->x;
|
||||
input->y=digiptr->y;
|
||||
input->z=digiptr->z;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class FairMQExample8Sampler : public FairMQDevice
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -17,51 +17,6 @@
|
|||
|
||||
#include "FairMQDevice.h"
|
||||
|
||||
|
||||
struct Ex8Header {
|
||||
int32_t stopFlag;
|
||||
};
|
||||
|
||||
|
||||
struct MyPoint
|
||||
{
|
||||
/* data */
|
||||
double x=1;
|
||||
double y=1;
|
||||
double z=1;
|
||||
};
|
||||
|
||||
|
||||
struct MyPointSerializer
|
||||
{
|
||||
void Serialize(std::unique_ptr<FairMQMessage>& msg, MyPoint* input)
|
||||
{
|
||||
int DataSize = sizeof(MyPoint);
|
||||
msg->Rebuild(DataSize);
|
||||
MyPoint* digiptr = reinterpret_cast<MyPoint*>(msg->GetData());
|
||||
digiptr->x=input->x;
|
||||
digiptr->y=input->y;
|
||||
digiptr->z=input->z;
|
||||
}
|
||||
|
||||
void Deserialize(std::unique_ptr<FairMQMessage>& msg, MyPoint* input)
|
||||
{
|
||||
MyPoint* digiptr = static_cast<MyPoint*>(msg->GetData());
|
||||
input->x=digiptr->x;
|
||||
input->y=digiptr->y;
|
||||
input->z=digiptr->z;
|
||||
}
|
||||
|
||||
void Deserialize(FairMQMessage& msg, MyPoint* input)
|
||||
{
|
||||
MyPoint* digiptr = static_cast<MyPoint*>(msg.GetData());
|
||||
input->x=digiptr->x;
|
||||
input->y=digiptr->y;
|
||||
input->z=digiptr->z;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class FairMQExample8Sink : public FairMQDevice
|
||||
{
|
||||
public:
|
||||
|
|
Loading…
Reference in New Issue
Block a user