HIPO  4.3.0
High Performance Output data format for experimental physics
hipo::writer Class Reference

Writer for creating HIPO files. More...

#include <writer.h>

Public Member Functions

 writer ()
 
virtual ~writer ()
 
void addEvent (hipo::event &hevent)
 Add an event to the current record buffer. More...
 
void addEvent (std::vector< char > &vec, int size=-1)
 Add raw event data from a byte vector. More...
 
void addUserConfig (std::string key, std::string value)
 Add a user configuration key-value pair to the file header. More...
 
void addUserConfig (const char *key, const char *value)
 Add a user configuration key-value pair to the file header (C-string overload). More...
 
void writeRecord (recordbuilder &builder)
 Write a completed record to the output file. More...
 
void open (const char *filename)
 Open a file for writing. More...
 
void close ()
 Close the file, flushing remaining events and writing the trailer. More...
 
void showSummary ()
 Print a summary of records written to stdout. More...
 
void addDictionary (hipo::dictionary &dict)
 Set the dictionary to be written into the file header. More...
 
hipo::dictionarygetDictionary ()
 
void setUserIntegerOne (long userIntOne)
 Set the first user-defined integer in the file header. More...
 
void setUserIntegerTwo (long userIntTwo)
 Set the second user-defined integer in the file header. More...
 
void flush ()
 Flush the current record buffer to disk. More...
 
void setVerbose (int level)
 Set the verbosity level for output messages. More...
 

Detailed Description

Writer for creating HIPO files.

Events are buffered in records and automatically flushed to disk. A dictionary of schemas must be added before opening the file.

hipo::schema schema("REC::Particle", 300, 1);
schema.parse("pid/I,px/F,py/F,pz/F");
writer.getDictionary().addSchema(schema);
writer.open("output.hipo");
hipo::bank b(schema, 1);
b.putInt("pid", 0, 11);
event.addStructure(b);
writer.addEvent(event);
writer.close();
Represents a HIPO bank, a tabular data structure with rows and typed columns.
Definition: bank.h:352
Represents a HIPO event, a container for multiple structures/banks.
Definition: event.h:77
void addStructure(hipo::structure &str)
Add a structure to the event.
Definition: event.cpp:161
Schema definition for a HIPO bank.
Definition: dictionary.h:73
Writer for creating HIPO files.
Definition: writer.h:156

Definition at line 156 of file writer.h.

Constructor & Destructor Documentation

◆ writer()

hipo::writer::writer ( )
inline

Definition at line 172 of file writer.h.

◆ ~writer()

virtual hipo::writer::~writer ( )
inlinevirtual

Definition at line 173 of file writer.h.

Member Function Documentation

◆ addDictionary()

void hipo::writer::addDictionary ( hipo::dictionary dict)

Set the dictionary to be written into the file header.

Parameters
dictDictionary containing schema definitions

Definition at line 123 of file writer.cpp.

◆ addEvent() [1/2]

void hipo::writer::addEvent ( hipo::event hevent)

Add an event to the current record buffer.

Parameters
heventEvent to add

Definition at line 130 of file writer.cpp.

◆ addEvent() [2/2]

void hipo::writer::addEvent ( std::vector< char > &  vec,
int  size = -1 
)

Add raw event data from a byte vector.

Parameters
vecRaw event buffer
sizeNumber of bytes to use (-1 for entire vector)

Definition at line 148 of file writer.cpp.

◆ addUserConfig() [1/2]

void hipo::writer::addUserConfig ( const char *  key,
const char *  value 
)
inline

Add a user configuration key-value pair to the file header (C-string overload).

Definition at line 185 of file writer.h.

◆ addUserConfig() [2/2]

void hipo::writer::addUserConfig ( std::string  key,
std::string  value 
)
inline

Add a user configuration key-value pair to the file header.

Definition at line 183 of file writer.h.

◆ close()

void hipo::writer::close ( )

Close the file, flushing remaining events and writing the trailer.

Definition at line 216 of file writer.cpp.

◆ flush()

void hipo::writer::flush ( )

Flush the current record buffer to disk.

Definition at line 246 of file writer.cpp.

◆ getDictionary()

hipo::dictionary& hipo::writer::getDictionary ( )
inline
Returns
Reference to the writer's dictionary.

Definition at line 200 of file writer.h.

◆ open()

void hipo::writer::open ( const char *  filename)

Open a file for writing.

Parameters
filenamePath to the output file

Open a File for writing, it includes the dictionary in the file.

Definition at line 45 of file writer.cpp.

◆ setUserIntegerOne()

void hipo::writer::setUserIntegerOne ( long  userIntOne)

Set the first user-defined integer in the file header.

Definition at line 232 of file writer.cpp.

◆ setUserIntegerTwo()

void hipo::writer::setUserIntegerTwo ( long  userIntTwo)

Set the second user-defined integer in the file header.

Definition at line 239 of file writer.cpp.

◆ setVerbose()

void hipo::writer::setVerbose ( int  level)
inline

Set the verbosity level for output messages.

Parameters
levelVerbosity level (0=quiet)

Definition at line 209 of file writer.h.

◆ showSummary()

void hipo::writer::showSummary ( )

Print a summary of records written to stdout.

Definition at line 178 of file writer.cpp.

◆ writeRecord()

void hipo::writer::writeRecord ( recordbuilder builder)

Write a completed record to the output file.

Parameters
builderRecord builder containing the record data

Definition at line 158 of file writer.cpp.


The documentation for this class was generated from the following files: