2 #ifndef EUDAQ_INCLUDED_AidaPacket
3 #define EUDAQ_INCLUDED_AidaPacket
12 #include "eudaq/Serializable.hh"
13 #include "eudaq/Serializer.hh"
14 #include "eudaq/Event.hh"
15 #include "eudaq/Exception.hh"
17 #include "eudaq/SmartEnum.hh"
18 #include "eudaq/Platform.hh"
19 #include "eudaq/MetaData.hh"
21 #define EUDAQ_DECLARE_PACKET() \
23 static uint64_t eudaq_static_type(); \
24 virtual uint64_t get_type() const { return eudaq_static_type(); }
28 #define EUDAQ_DEFINE_PACKET(type, name) \
29 uint64_t type::eudaq_static_type() { \
30 static const uint64_t type_(name); \
33 namespace _eudaq_dummy_ { \
34 static eudaq::RegisterPacketType<type> eudaq_packet_reg; \
42 m_header.data.packetType = type;
43 m_header.data.packetSubType = subtype;
56 uint64_t packetSubType;
57 uint64_t packetNumber;
63 uint64_t GetPacketMarker()
const {
return m_header.data.marker; };
64 uint64_t GetPacketType()
const {
return m_header.data.packetType; };
65 uint64_t GetPacketSubType()
const {
return m_header.data.packetSubType; };
66 uint64_t GetPacketNumber()
const {
return m_header.data.packetNumber; };
68 uint64_t GetPacketDataSize()
const {
return m_data_size; };
70 void SetPacketType(uint64_t type) { m_header.data.packetType = type; };
71 void SetPacketSubType(uint64_t type) {
72 m_header.data.packetSubType = type;
79 MetaData &GetMetaData() {
return m_meta_data; }
81 void SerializeMetaData(Serializer &)
const;
87 void SetData(uint64_t *data, uint64_t size) {
92 void SetData(std::vector<uint64_t> &data) {
93 m_data_size = data.size();
97 void SetData(std::vector<uint64_t> *data) {
98 m_data = data->data();
99 m_data_size = data->size();
102 virtual void DeserializeData(Deserializer &);
104 virtual void Serialize(Serializer &)
const;
106 static PacketHeader DeserializeHeader(Deserializer &);
108 virtual void Print(std::ostream &os)
const;
121 static uint64_t str2type(
const std::string &str);
122 static std::string type2str(uint64_t
id);
124 static const uint64_t *
const bit_mask();
130 m_header.data.marker = identifier().number;
131 m_header.data.packetNumber = getNextPacketNumber();
137 static uint64_t getNextPacketNumber() {
138 static uint64_t packetCounter = 0;
139 return ++packetCounter;
142 PacketHeader m_header;
143 MetaData m_meta_data;
147 std::unique_ptr<uint64_t[]> placeholder;
148 uint64_t m_data_size;
153 EUDAQ_DECLARE_PACKET();
166 DLLEXPORT std::ostream &operator<<(std::ostream &,
const AidaPacket &);
170 static std::shared_ptr<AidaPacket> Create(
Deserializer &ds);
172 typedef std::shared_ptr<AidaPacket>(*packet_creator)(
174 static void Register(uint64_t
id, packet_creator func);
175 static packet_creator GetCreator(
int id);
178 typedef std::map<int, packet_creator> map_t;
179 static map_t &get_map();
187 PacketFactory::Register(T_Packet::eudaq_static_type(), &factory_func);
189 static std::shared_ptr<AidaPacket>
191 return std::shared_ptr<AidaPacket>(
new T_Packet(header, ds));
196 #endif // EUDAQ_INCLUDED_AidaPacket
Definition: AidaIndexData.hh:14
Definition: AidaPacket.hh:114
Definition: Serializer.hh:156
Definition: AidaPacket.hh:168
Definition: Serializable.hh:13
Definition: AidaPacket.hh:39
Definition: AidaPacket.hh:152
Definition: Serializer.hh:19
Definition: AidaPacket.hh:185