evio  6.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
evio::EventBuilder Class Reference

This class is used for creating and manipulating events. More...

#include <EventBuilder.h>

Public Member Functions

 EventBuilder (uint16_t tag, DataType const dataType, uint8_t num)
 This is the constructor to use for an EventBuilder object that will operate on a new, empty event. More...
 
 EventBuilder (std::shared_ptr< EvioEvent > &event)
 This is the constructor to use when you want to manipulate an existing event. More...
 
void setAllHeaderLengths ()
 This goes through the event recursively, and makes sure all the length fields in the headers are properly set. More...
 
void clearData (std::shared_ptr< BaseStructure > structure)
 This clears all the data fields in a structure, but not the parent or the children. More...
 
void addChild (std::shared_ptr< BaseStructure > parent, std::shared_ptr< BaseStructure > child)
 Add a child to a parent structure. More...
 
void remove (std::shared_ptr< BaseStructure > child)
 This removes a structure (and all its descendants) from the tree. More...
 
void setIntData (std::shared_ptr< BaseStructure > structure, int32_t *data, size_t count)
 Set int data in the structure. More...
 
void setUIntData (std::shared_ptr< BaseStructure > structure, uint32_t *data, size_t count)
 Set unsigned int data in the structure. More...
 
void setShortData (std::shared_ptr< BaseStructure > structure, int16_t *data, size_t count)
 Set short data in the structure. More...
 
void setUShortData (std::shared_ptr< BaseStructure > structure, uint16_t *data, size_t count)
 Set unsigned short data in the structure. More...
 
void setLongData (std::shared_ptr< BaseStructure > structure, int64_t *data, size_t count)
 Set long data in the structure. More...
 
void setULongData (std::shared_ptr< BaseStructure > structure, uint64_t *data, size_t count)
 Set unsigned long data in the structure. More...
 
void setCharData (std::shared_ptr< BaseStructure > structure, char *data, size_t count)
 Set char data in the structure. More...
 
void setUCharData (std::shared_ptr< BaseStructure > structure, unsigned char *data, size_t count)
 Set unsigned char data in the structure. More...
 
void setFloatData (std::shared_ptr< BaseStructure > structure, float *data, size_t count)
 Set float data in the structure. More...
 
void setDoubleData (std::shared_ptr< BaseStructure > structure, double *data, size_t count)
 Set double data in the structure. More...
 
void setStringData (std::shared_ptr< BaseStructure > structure, std::string *data, size_t count)
 Set string data in the structure. More...
 
void setCompositeData (std::shared_ptr< BaseStructure > structure, std::shared_ptr< CompositeData > *data, size_t count)
 Set composite data in the structure. More...
 
void appendIntData (std::shared_ptr< BaseStructure > structure, int32_t *data, size_t count)
 Append int data to the structure. More...
 
void appendUIntData (std::shared_ptr< BaseStructure > structure, uint32_t *data, size_t count)
 Append unsigned int data to the structure. More...
 
void appendShortData (std::shared_ptr< BaseStructure > structure, int16_t *data, size_t count)
 Append short data to the structure. More...
 
void appendUShortData (std::shared_ptr< BaseStructure > structure, uint16_t *data, size_t count)
 Append unsigned short data to the structure. More...
 
void appendLongData (std::shared_ptr< BaseStructure > structure, int64_t *data, size_t count)
 Append long data to the structure. More...
 
void appendULongData (std::shared_ptr< BaseStructure > structure, uint64_t *data, size_t count)
 Append unsigned long data to the structure. More...
 
void appendCharData (std::shared_ptr< BaseStructure > structure, char *data, size_t count)
 Append char data to the structure. More...
 
void appendUCharData (std::shared_ptr< BaseStructure > structure, unsigned char *data, size_t count)
 Append unsigned char data to the structure. More...
 
void appendFloatData (std::shared_ptr< BaseStructure > structure, float *data, size_t count)
 Append float data to the structure. More...
 
void appendDoubleData (std::shared_ptr< BaseStructure > structure, double *data, size_t count)
 Append double data to the structure. More...
 
void appendStringData (std::shared_ptr< BaseStructure > structure, std::string *data, size_t count)
 Append string data to the structure. More...
 
void appendCompositeData (std::shared_ptr< BaseStructure > structure, std::shared_ptr< CompositeData > *data, size_t count)
 Append string data to the structure. More...
 
std::shared_ptr< EvioEventgetEvent ()
 Get the underlying event. More...
 
void setEvent (std::shared_ptr< EvioEvent > &ev)
 Set the underlying event. More...
 

Static Public Member Functions

static int main (int argc, char **argv)
 Main program for testing. More...
 

Detailed Description

This class is used for creating and manipulating events.

One constructor is convenient for creating new events while another is useful for manipulating existing events. You can create a new EventBuilder for each event being handled; however, in many cases one can use the same EventBuilder for all events by calling the setEvent method. The only reason a singleton pattern was not used was to allow for the possibility that events will be built or manipulated on multiple threads.

Author
heddle (original java version)
timmer

Constructor & Destructor Documentation

evio::EventBuilder::EventBuilder ( uint16_t  tag,
DataType const  dataType,
uint8_t  num 
)

This is the constructor to use for an EventBuilder object that will operate on a new, empty event.

Parameters
tagthe tag for the event header (which is just a bank header).
dataTypethe data type for the event object–which again is just the type for the outer most bank. Often an event is a bank of banks, so typically this will be DataType.BANK, or 0xe (14).
numoften an ordinal enumeration.

References evio::EvioEvent::getInstance().

evio::EventBuilder::EventBuilder ( std::shared_ptr< EvioEvent > &  ev)

This is the constructor to use when you want to manipulate an existing event.

Parameters
evthe event to manipulate.

Member Function Documentation

void evio::EventBuilder::addChild ( std::shared_ptr< BaseStructure parent,
std::shared_ptr< BaseStructure child 
)

Add a child to a parent structure.

Parameters
parentthe parent structure.
childthe child structure.
Exceptions
EvioExceptionif parent or child is null, child has wrong byte order, is wrong structure type, or parent is not a container

References evio::DataType::ALSOBANK, evio::DataType::ALSOSEGMENT, evio::DataType::BANK, evio::DataType::getDataType(), evio::DataType::getName(), evio::DataType::isStructure(), evio::DataType::SEGMENT, setAllHeaderLengths(), evio::StructureType::STRUCT_BANK, evio::StructureType::STRUCT_SEGMENT, evio::StructureType::STRUCT_TAGSEGMENT, and evio::DataType::TAGSEGMENT.

Referenced by main().

void evio::EventBuilder::appendCharData ( std::shared_ptr< BaseStructure structure,
char *  data,
size_t  count 
)

Append char data to the structure.

If the structure has no data, then this is the same as setting the data (except the the data type may not be changed).

Parameters
structurethe structure to receive the data.
datapointer to data (array of chars) to append.
countnumber of chars to append.
Exceptions
EvioExceptionif structure or data arg(s) is null, data type is not char.

References evio::DataType::CHAR8, and setAllHeaderLengths().

void evio::EventBuilder::appendCompositeData ( std::shared_ptr< BaseStructure structure,
std::shared_ptr< CompositeData > *  data,
size_t  count 
)

Append string data to the structure.

If the structure has no data, then this is the same as setting the data (except the the data type may not be changed).

Parameters
structurethe structure to receive the data.
datapointer to data (array of string) to append.
countnumber of strings to append.
Exceptions
EvioExceptionif structure or data arg(s) is null, data type is not string.

References evio::DataType::COMPOSITE, and setAllHeaderLengths().

void evio::EventBuilder::appendDoubleData ( std::shared_ptr< BaseStructure structure,
double *  data,
size_t  count 
)

Append double data to the structure.

If the structure has no data, then this is the same as setting the data (except the the data type may not be changed).

Parameters
structurethe structure to receive the data.
datapointer to data (array of doubles) to append.
countnumber of doubles to append.
Exceptions
EvioExceptionif structure or data arg(s) is null, data type is not double.

References evio::DataType::DOUBLE64, and setAllHeaderLengths().

Referenced by main().

void evio::EventBuilder::appendFloatData ( std::shared_ptr< BaseStructure structure,
float *  data,
size_t  count 
)

Append float data to the structure.

If the structure has no data, then this is the same as setting the data (except the the data type may not be changed).

Parameters
structurethe structure to receive the data.
datapointer to data (array of floats) to append.
countnumber of floats to append.
Exceptions
EvioExceptionif structure or data arg(s) is null, data type is not float.

References evio::DataType::FLOAT32, and setAllHeaderLengths().

void evio::EventBuilder::appendIntData ( std::shared_ptr< BaseStructure structure,
int32_t *  data,
size_t  count 
)

Append int data to the structure.

If the structure has no data, then this is the same as setting the data (except the the data type may not be changed).

Parameters
structurethe structure to receive the data.
datapointer to data (array of ints) to append.
countnumber of ints to append.
Exceptions
EvioExceptionif structure or data arg(s) is null, data type is not int.

References evio::DataType::INT32, and setAllHeaderLengths().

void evio::EventBuilder::appendLongData ( std::shared_ptr< BaseStructure structure,
int64_t *  data,
size_t  count 
)

Append long data to the structure.

If the structure has no data, then this is the same as setting the data (except the the data type may not be changed).

Parameters
structurethe structure to receive the data.
datapointer to data (array of longs) to append.
countnumber of longs to append.
Exceptions
EvioExceptionif structure or data arg(s) is null, data type is not long.

References evio::DataType::LONG64, and setAllHeaderLengths().

void evio::EventBuilder::appendShortData ( std::shared_ptr< BaseStructure structure,
int16_t *  data,
size_t  count 
)

Append short data to the structure.

If the structure has no data, then this is the same as setting the data (except the the data type may not be changed).

Parameters
structurethe structure to receive the data.
datapointer to data (array of shorts) to append.
countnumber of shorts to append.
Exceptions
EvioExceptionif structure or data arg(s) is null, data type is not short.

References setAllHeaderLengths(), and evio::DataType::SHORT16.

void evio::EventBuilder::appendStringData ( std::shared_ptr< BaseStructure structure,
std::string *  data,
size_t  count 
)

Append string data to the structure.

If the structure has no data, then this is the same as setting the data (except the the data type may not be changed).

Parameters
structurethe structure to receive the data.
datapointer to data (array of string) to append.
countnumber of strings to append.
Exceptions
EvioExceptionif structure or data arg(s) is null, data type is not string.

References evio::DataType::CHARSTAR8, and setAllHeaderLengths().

Referenced by main().

void evio::EventBuilder::appendUCharData ( std::shared_ptr< BaseStructure structure,
unsigned char *  data,
size_t  count 
)

Append unsigned char data to the structure.

If the structure has no data, then this is the same as setting the data (except the the data type may not be changed).

Parameters
structurethe structure to receive the data.
datapointer to data (array of uchars) to append.
countnumber of chars to append.
Exceptions
EvioExceptionif structure or data arg(s) is null, data type is not unsigned char.

References setAllHeaderLengths(), and evio::DataType::UCHAR8.

void evio::EventBuilder::appendUIntData ( std::shared_ptr< BaseStructure structure,
uint32_t *  data,
size_t  count 
)

Append unsigned int data to the structure.

If the structure has no data, then this is the same as setting the data (except the the data type may not be changed).

Parameters
structurethe structure to receive the data.
datapointer to data (array of uints) to append.
countnumber of ints to append.
Exceptions
EvioExceptionif structure or data arg(s) is null, data type is not unsigned int.

References setAllHeaderLengths(), and evio::DataType::UINT32.

Referenced by main().

void evio::EventBuilder::appendULongData ( std::shared_ptr< BaseStructure structure,
uint64_t *  data,
size_t  count 
)

Append unsigned long data to the structure.

If the structure has no data, then this is the same as setting the data (except the the data type may not be changed).

Parameters
structurethe structure to receive the data.
datapointer to data (array of ulongs) to append.
countnumber of longs to append.
Exceptions
EvioExceptionif structure or data arg(s) is null, data type is not unsigned long.

References setAllHeaderLengths(), and evio::DataType::ULONG64.

void evio::EventBuilder::appendUShortData ( std::shared_ptr< BaseStructure structure,
uint16_t *  data,
size_t  count 
)

Append unsigned short data to the structure.

If the structure has no data, then this is the same as setting the data (except the the data type may not be changed).

Parameters
structurethe structure to receive the data.
datapointer to data (array of ushorts) to append.
countnumber of shorts to append.
Exceptions
EvioExceptionif structure or data arg(s) is null, data type is not unsigned short.

References setAllHeaderLengths(), and evio::DataType::USHORT16.

Referenced by main().

void evio::EventBuilder::clearData ( std::shared_ptr< BaseStructure structure)

This clears all the data fields in a structure, but not the parent or the children.

This keeps the existing tree structure intact. To remove a structure (and, consequently, all its descendants) from the tree, use remove

Parameters
structurethe segment to clear.
std::shared_ptr< EvioEvent > evio::EventBuilder::getEvent ( )

Get the underlying event.

Returns
the underlying event.

Referenced by main().

void evio::EventBuilder::remove ( std::shared_ptr< BaseStructure child)

This removes a structure (and all its descendants) from the tree.

Parameters
childthe child structure to remove.
Exceptions
EvioExceptionif arg is null or its parent is null

References setAllHeaderLengths().

void evio::EventBuilder::setCharData ( std::shared_ptr< BaseStructure structure,
char *  data,
size_t  count 
)

Set char data in the structure.

If the structure has data, it is overwritten even if the existing data is of a different type.

Parameters
structurethe structure to receive the data.
datapointer to data (array of chars) to write.
countnumber of bytes to write.
Exceptions
EvioExceptionif structure or data arg(s) is null.

References evio::DataType::CHAR8, and setAllHeaderLengths().

void evio::EventBuilder::setCompositeData ( std::shared_ptr< BaseStructure structure,
std::shared_ptr< CompositeData > *  data,
size_t  count 
)

Set composite data in the structure.

If the structure has data, it is overwritten even if the existing data is of a different type.

Parameters
structurethe structure to receive the data.
datapointer to data (array of shared pointers of composite type) to write.
countnumber of (shared pointer of) composites to write.
Exceptions
EvioExceptionif structure or data arg(s) is null.

References evio::DataType::COMPOSITE, and setAllHeaderLengths().

void evio::EventBuilder::setDoubleData ( std::shared_ptr< BaseStructure structure,
double *  data,
size_t  count 
)

Set double data in the structure.

If the structure has data, it is overwritten even if the existing data is of a different type.

Parameters
structurethe structure to receive the data.
datapointer to data (array of doubles) to write.
countnumber of doubles to write.
Exceptions
EvioExceptionif structure or data arg(s) is null.

References evio::DataType::DOUBLE64, and setAllHeaderLengths().

void evio::EventBuilder::setEvent ( std::shared_ptr< EvioEvent > &  ev)

Set the underlying event.

As far as this event builder is concerned, the previous underlying event is lost, and all subsequent calls will affect the newly supplied event.

Parameters
evthe new underlying event.
void evio::EventBuilder::setFloatData ( std::shared_ptr< BaseStructure structure,
float *  data,
size_t  count 
)

Set float data in the structure.

If the structure has data, it is overwritten even if the existing data is of a different type.

Parameters
structurethe structure to receive the data.
datapointer to data (array of floats) to write.
countnumber of floats to write.
Exceptions
EvioExceptionif structure or data arg(s) is null.

References evio::DataType::FLOAT32, and setAllHeaderLengths().

void evio::EventBuilder::setIntData ( std::shared_ptr< BaseStructure structure,
int32_t *  data,
size_t  count 
)

Set int data in the structure.

If the structure has data, it is overwritten even if the existing data is of a different type.

Parameters
structurethe structure to receive the data.
datapointer to data (array of ints) to write.
countnumber of ints to write.
Exceptions
EvioExceptionif structure or data arg(s) is null.

References evio::DataType::INT32, and setAllHeaderLengths().

void evio::EventBuilder::setLongData ( std::shared_ptr< BaseStructure structure,
int64_t *  data,
size_t  count 
)

Set long data in the structure.

If the structure has data, it is overwritten even if the existing data is of a different type.

Parameters
structurethe structure to receive the data.
datapointer to data (array of longs) to write.
countnumber of longs to write.
Exceptions
EvioExceptionif structure or data arg(s) is null.

References evio::DataType::LONG64, and setAllHeaderLengths().

void evio::EventBuilder::setShortData ( std::shared_ptr< BaseStructure structure,
int16_t *  data,
size_t  count 
)

Set short data in the structure.

If the structure has data, it is overwritten even if the existing data is of a different type.

Parameters
structurethe structure to receive the data.
datapointer to data (array of shorts) to write.
countnumber of shorts to write.
Exceptions
EvioExceptionif structure or data arg(s) is null.

References setAllHeaderLengths(), and evio::DataType::SHORT16.

void evio::EventBuilder::setStringData ( std::shared_ptr< BaseStructure structure,
std::string *  data,
size_t  count 
)

Set string data in the structure.

If the structure has data, it is overwritten even if the existing data is of a different type.

Parameters
structurethe structure to receive the data.
datapointer to data (array of strings) to write.
countnumber of strings to write.
Exceptions
EvioExceptionif structure or data arg(s) is null.

References evio::DataType::CHARSTAR8, and setAllHeaderLengths().

void evio::EventBuilder::setUCharData ( std::shared_ptr< BaseStructure structure,
unsigned char *  data,
size_t  count 
)

Set unsigned char data in the structure.

If the structure has data, it is overwritten even if the existing data is of a different type.

Parameters
structurethe structure to receive the data.
datapointer to data (array of uchars) to write.
countnumber of bytes to write.
Exceptions
EvioExceptionif structure or data arg(s) is null.

References setAllHeaderLengths(), and evio::DataType::UCHAR8.

void evio::EventBuilder::setUIntData ( std::shared_ptr< BaseStructure structure,
uint32_t *  data,
size_t  count 
)

Set unsigned int data in the structure.

If the structure has data, it is overwritten even if the existing data is of a different type.

Parameters
structurethe structure to receive the data.
datapointer to data (array of uints) to write.
countnumber of ints to write.
Exceptions
EvioExceptionif structure or data arg(s) is null.

References setAllHeaderLengths(), and evio::DataType::UINT32.

void evio::EventBuilder::setULongData ( std::shared_ptr< BaseStructure structure,
uint64_t *  data,
size_t  count 
)

Set unsigned long data in the structure.

If the structure has data, it is overwritten even if the existing data is of a different type.

Parameters
structurethe structure to receive the data.
datapointer to data (array of ulongs) to write.
countnumber of longs to write.
Exceptions
EvioExceptionif structure or data arg(s) is null.

References setAllHeaderLengths(), and evio::DataType::ULONG64.

void evio::EventBuilder::setUShortData ( std::shared_ptr< BaseStructure structure,
uint16_t *  data,
size_t  count 
)

Set unsigned short data in the structure.

If the structure has data, it is overwritten even if the existing data is of a different type.

Parameters
structurethe structure to receive the data.
datapointer to data (array of ushorts) to write.
countnumber of shorts to write.
Exceptions
EvioExceptionif structure or data arg(s) is null.

References setAllHeaderLengths(), and evio::DataType::USHORT16.


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