72 std::vector<char> nodeBuffer;
73 const char *nodePointer;
91 void init(
const char *b,
int length){
allocate(length); memcpy(
const_cast<char *
>(nodePointer),b,length);}
105 node(std::tuple<int,int,int,int> params){
106 create(std::get<0>(params),std::get<1>(params), std::get<2>(params), std::get<3>(params));
121 void assign(std::tuple<int,int,int,int> params );
129 if(((
int) nodeBuffer.size()) <
size){
130 nodeBuffer.resize(
size+8); nodePointer = &nodeBuffer[0];
139 int length = *
reinterpret_cast<const uint32_t *
>(nodePointer+4);
146 return (
int) nodeBuffer.size();
152 int length = *
reinterpret_cast<const uint32_t *
>(nodePointer+4);
162 char *dest =
const_cast<char *
>(nodePointer);
164 }
else { printf(
"node::setFormatLength: error >>> the format length can not exceed 128, you tried to set it to %d\n",length);}
172 int word = *
reinterpret_cast<const uint32_t *
>(nodePointer+4);
201 uint32_t word = *
reinterpret_cast<const uint32_t *
>(nodePointer+4);
203 char *dest =
const_cast<char *
>(nodePointer);
204 *
reinterpret_cast<uint32_t *
>(dest+4) = nodeSize;
205 }
else { printf(
"node::setNodeLength:: error: the total size of the node exceeds 16777215\n");}
212 int group(){
return (
int) (*
reinterpret_cast<const uint16_t *
>(nodePointer));}
214 int item(){
return (
int) (*
reinterpret_cast<const uint8_t *
>(nodePointer+2));}
216 int type(){
return (
int) (*
reinterpret_cast<const uint8_t *
>(nodePointer+3));}
235 return *
reinterpret_cast<const int32_t*
>(nodePointer + index +
dataOffset());
241 return *
reinterpret_cast<const int16_t*
>(nodePointer + index +
dataOffset());
246 return *
reinterpret_cast<const int8_t*
>(nodePointer + index +
dataOffset());
251 return *
reinterpret_cast<const float*
>(nodePointer + index +
dataOffset());
256 return *
reinterpret_cast<const double*
>(nodePointer + index +
dataOffset());
261 return *
reinterpret_cast<const int64_t*
>(nodePointer + index +
dataOffset());
270 char *a =
const_cast<char*
>(nodePointer);
271 *
reinterpret_cast<int32_t*
>(a + index +
dataOffset()) = value;
278 char *a =
const_cast<char*
>(nodePointer);
279 *
reinterpret_cast<int16_t*
>(a + index +
dataOffset()) = value;
286 char *a =
const_cast<char*
>(nodePointer);
287 *
reinterpret_cast<int8_t*
>(a + index +
dataOffset()) = value;
294 char *a =
const_cast<char*
>(nodePointer);
295 *
reinterpret_cast<float*
>(a + index +
dataOffset()) = value;
302 char *a =
const_cast<char*
>(nodePointer);
303 *
reinterpret_cast<double*
>(a + index +
dataOffset()) = value;
310 char *a =
const_cast<char*
>(nodePointer);
311 *
reinterpret_cast<int64_t*
>(a + index +
dataOffset()) = value;
Represents a HIPO event, a container for multiple structures/banks.
Low-level node representing a tagged data element in a HIPO structure.
void setNodeLength(int size)
Set the total node length in the header word.
int formatLength() const noexcept
virtual void reset()
Reset the node by setting the data length to zero.
int size() const noexcept
virtual void show()
Print a summary of this node to stdout.
float getFloatAt(int index) const noexcept
Read a 32-bit float at the given byte offset within the data region.
void putFloatAt(int index, float value)
Write a 32-bit float at the given byte offset within the data region.
void assign(std::tuple< int, int, int, int > params)
Re-initialize this node from a parameter tuple.
int capacity() const noexcept
int8_t getByteAt(int index) const noexcept
Read an 8-bit integer at the given byte offset within the data region.
int dataOffset() const noexcept
node()
Default constructor; allocates an 8-byte header.
int dataLength() const noexcept
void putShortAt(int index, int16_t value)
Write a 16-bit integer at the given byte offset within the data region.
void initEmpty()
Initialize the node to an empty state.
void create(int group, int item, int type, int size)
Create a node with the given header fields and allocate storage.
node(int size)
Construct a node with a pre-allocated data region.
void putByteAt(int index, int8_t value)
Write an 8-bit integer at the given byte offset within the data region.
long getLongAt(int index) const noexcept
Read a 64-bit integer at the given byte offset within the data region.
int16_t getShortAt(int index) const noexcept
Read a 16-bit integer at the given byte offset within the data region.
void setSize(int size)
Set the total size of the node.
double getDoubleAt(int index) const noexcept
Read a 64-bit double at the given byte offset within the data region.
void init(const char *b, int length)
Initialize the node by copying raw bytes into the internal buffer.
void putIntAt(int index, int value)
Write a 32-bit integer at the given byte offset within the data region.
node(std::tuple< int, int, int, int > params)
Construct a node from a parameter tuple.
void putDoubleAt(int index, double value)
Write a 64-bit double at the given byte offset within the data region.
void putLongAt(int index, int64_t value)
Write a 64-bit integer at the given byte offset within the data region.
int getIntAt(int index) const noexcept
Read a 32-bit integer at the given byte offset within the data region.
virtual void notify()
Callback invoked when the node content is updated (e.g., after deserialization).
void setDataLength(int length)
Set the data payload length, preserving the format length.
void setFormatLength(int length)
Set the format descriptor length.
bool allocate(int size)
Ensure the internal buffer can hold at least size bytes.
N-tuple writer for storing columnar float data in HIPO files.
constexpr uint32_t STRUCT_FORMAT_BYTE
constexpr int STRUCT_FORMAT_SHIFT
constexpr uint32_t STRUCT_FORMAT_MASK
constexpr uint32_t STRUCT_SIZE_MASK