48 #if __cplusplus > 199711L
52 dataBuffer.resize(128*1024);
57 dataBuffer.resize(size);
144 printf(
"-removing %d, %d\n",index.first,index.second);
149 std::memmove(&dataBuffer[index.first],&dataBuffer[index.first+
BANK_STRUCTURE_SIZE+index.second],toCopy);
150 printf(
" first = %d, second = %d\n",index.first,index.second);
151 printf(
" \t memcopy = %d, %d, ncopy %d , size = %d , new size = %d\n",
154 uint32_t newSize_u =
static_cast<uint32_t
>(newSize);
155 std::memcpy(&dataBuffer[
EH_SIZE_OFFSET], &newSize_u,
sizeof(newSize_u));
166 int evt_capacity = dataBuffer.size();
173 if((evt_size + str_size)<evt_capacity){
175 uint32_t new_size =
static_cast<uint32_t
>(evt_size + str_size);
176 std::memcpy(&dataBuffer[
EH_SIZE_OFFSET], &new_size,
sizeof(new_size));
178 printf(
"event::add : error adding structure with size = %5d (capacity = %5d, size = %5d)\n",
179 str_size,evt_capacity, evt_size);
187 if(_n_data_length==0)
return;
191 int ev_capacity = dataBuffer.size();
192 if((ev_size + _n_size)<ev_capacity){
193 memcpy(&dataBuffer[ev_size], _n.
pointer(),_n_size);
194 uint32_t new_size =
static_cast<uint32_t
>(ev_size + _n_size);
195 std::memcpy(&dataBuffer[
EH_SIZE_OFFSET], &new_size,
sizeof(new_size));
197 printf(
"event::add : error adding structure with size = %5d (capacity = %5d, size = %5d)\n",
198 _n_size,ev_capacity, ev_size);
211 printf(
" found the structure : %d/%d - properties = %d, %d\n",group,item,index.first,index.second);
214 printf(
"calling notify.....\n");
225 std::memcpy(&eventTag_u, &dataBuffer[
EH_TAG_OFFSET],
sizeof(eventTag_u));
226 return static_cast<int>(eventTag_u);
230 uint32_t tag_u =
static_cast<uint32_t
>(tag);
231 std::memcpy(&dataBuffer[
EH_TAG_OFFSET], &tag_u,
sizeof(tag_u));
235 dataBuffer.resize(buffer.size());
236 std::memcpy(&dataBuffer[0],&buffer[0],buffer.size());
241 uint32_t eventSize_u;
242 std::memcpy(&eventSize_u, &buffer[
EH_SIZE_OFFSET],
sizeof(eventSize_u));
243 int eventSize =
static_cast<int>(eventSize_u);
246 std::memcpy(&gid, &buffer[position],
sizeof(gid));
247 uint8_t iid =
static_cast<uint8_t
>(buffer[position+2]);
249 std::memcpy(&length, &buffer[position+4],
sizeof(length));
250 if(gid==group&&iid==item)
return std::make_pair(position,length);
253 return std::make_pair(-1,0);
258 uint32_t eventSize_u;
259 std::memcpy(&eventSize_u, &dataBuffer[
EH_SIZE_OFFSET],
sizeof(eventSize_u));
260 int eventSize =
static_cast<int>(eventSize_u);
263 std::memcpy(&gid, &dataBuffer[position],
sizeof(gid));
264 uint8_t iid =
static_cast<uint8_t
>(dataBuffer[position+2]);
266 std::memcpy(&word, &dataBuffer[position+4],
sizeof(word));
268 if(gid==group&&iid==item)
return std::make_pair(position,length);
271 return std::make_pair(-1,0);
276 uint32_t eventSize_u;
277 std::memcpy(&eventSize_u, &dataBuffer[
EH_SIZE_OFFSET],
sizeof(eventSize_u));
278 int eventSize =
static_cast<int>(eventSize_u);
281 std::memcpy(&gid, &dataBuffer[position],
sizeof(gid));
282 uint8_t iid =
static_cast<uint8_t
>(dataBuffer[position+2]);
284 std::memcpy(&length, &dataBuffer[position+4],
sizeof(length));
285 if(gid==group&&iid==item)
return std::make_pair(position,length);
288 return std::make_pair(-1,0);
307 if(dataBuffer.size()<=size){
308 dataBuffer.resize(size+1024);
310 std::memcpy(&dataBuffer[0],buffer,size);
311 uint32_t size_u =
static_cast<uint32_t
>(size);
312 std::memcpy(&dataBuffer[
EH_SIZE_OFFSET], &size_u,
sizeof(size_u));
317 std::memcpy(&size_u, &dataBuffer[
EH_SIZE_OFFSET],
sizeof(size_u));
318 return static_cast<int>(size_u);
322 dataBuffer[0] =
'E'; dataBuffer[1] =
'V';
323 dataBuffer[2] =
'N'; dataBuffer[3] =
'T';
326 val = 0; std::memcpy(&dataBuffer[
EH_TAG_OFFSET], &val,
sizeof(val));
337 printf(
" EVENT SIZE = %d\n",
getSize());
339 uint32_t eventSize_u;
340 std::memcpy(&eventSize_u, &dataBuffer[
EH_SIZE_OFFSET],
sizeof(eventSize_u));
341 int eventSize =
static_cast<int>(eventSize_u);
344 std::memcpy(&gid, &dataBuffer[position],
sizeof(gid));
345 uint8_t iid =
static_cast<uint8_t
>(dataBuffer[position+2]);
346 uint8_t type =
static_cast<uint8_t
>(dataBuffer[position+3]);
348 std::memcpy(&sizeWord, &dataBuffer[position+4],
sizeof(sizeWord));
353 printf(
"%12s node [%9d %4d] type = %12d, fotmat size = %3d , length = %12d\n",
" ",gid,iid,type,format,length);
Represents a HIPO bank, a tabular data structure with rows and typed columns.
std::vector< char > & getEventBuffer()
static void getStructureNoCopy(const char *buffer, hipo::structure &str, int group, int item)
Extract a structure from a raw buffer without copying the data.
event()
Default constructor. Creates an empty event.
void write(hipo::node &node)
Write a node into this event.
void addStructure(hipo::structure &str)
Add a structure to the event.
void get(hipo::node &_n, int group, int item)
Get a node from the event by group and item identifiers.
void override(hipo::structure &str)
Override an existing structure in the event.
void read(hipo::bank &b)
Read a bank from this event (alias for getStructure).
void getStructure(hipo::structure &str, int group, int item)
Extract a structure from the event by group and item identifiers.
std::pair< int, int > getStructurePosition(int group, int item)
Find the position and length of a structure in the event buffer.
void init(std::vector< char > &buffer)
Initialize the event from an existing buffer.
void show()
Display the event contents to standard output.
void remove(hipo::bank &str)
Remove a bank from the event.
std::pair< int, int > getStructurePosition4(int group, int item)
Find the position and length of a structure using 4-byte header format.
void reset()
Reset the event to an empty state.
void add(hipo::node &_n)
Add a node to the event.
virtual ~event()
Destructor.
void replace(hipo::bank &bank)
Replace an existing bank in the event.
void getStructure4(hipo::structure &str, int group, int item)
Extract a structure using 4-byte header format.
Low-level node representing a tagged data element in a HIPO structure.
int size() const noexcept
int dataLength() const noexcept
void initEmpty()
Initialize the node to an empty state.
void init(const char *b, int length)
Initialize the node by copying raw bytes into the internal buffer.
virtual void notify()
Callback invoked when the node content is updated (e.g., after deserialization).
std::string getName() const
Get the schema name.
int getItem()
Get the item identifier.
int getGroup()
Get the group identifier.
Low-level data structure representing a HIPO structure.
void initStructureBySize(int __group, int __item, int __type, int __size)
Initialize the structure buffer with the given group, item, type, and data size.
int getSize() const noexcept
int getStructureBufferSize()
void initNoCopy(const char *buffer, int size)
std::vector< char > & getStructureBuffer()
virtual void notify()
Called when the structure is updated (e.g., after reading an event).
void init(const char *buffer, int size)
HIPO event container and manipulation interface.
constexpr uint32_t STRUCT_FORMAT_BYTE
constexpr int BANK_STRUCTURE_SIZE
constexpr int EH_SIZE_OFFSET
constexpr int STRUCT_FORMAT_SHIFT
constexpr int EVENT_HEADER_SIZE
constexpr int EH_TAG_OFFSET
constexpr int EH_RESERVED_OFFSET
constexpr uint32_t STRUCT_SIZE_MASK