Event class for interfacing with processors.
This class is what is given to the processors to 'get' data from and/or 'add' data to.
The 'Process' class is a friend class so that it can do all the orginizational work behind the scenes using private methods while the public methods are the only ones available to processors written by users.
Only our good friend Process can construct us.
Besides the name of the pass, the input_file handle is initialized to a nullptr to signify that no input file has been "registered" yet and i_entry_ is started at zero.
Pass drop/keep rules for determining if a data set is going to be written to the output file or not.
The regex grammar is set to "extended", case is ignored, and the 'nosubs' parameter is passed.
- Parameters
-
[in] | pass | name of current processing pass |
[in] | dk_rules | configuration for the drop/keep rules |
register our event header with a data set for save/load
template<typename DataType >
void fire::Event::add |
( |
const std::string & |
name, |
|
|
const DataType & |
data |
|
) |
| |
|
inline |
add a piece of data to the event
If the data isn't already in the list of in-memory objects, we do the initialization procedure defined below. After init, we check if the object has already been updated by another processor, and if it hasn't, we give the input data to the event object to update the in-memory copy.
Initilialization
To initilialize a new in-memory object, we first check that a object with the same name and pass doesn't exist in the available objects. This prevents processors from silently overwriting data that could have been read in from the input file. Then, we create a new event object to hold the in-memory data, wrapping the event object with h5::Data. We also set the event object flags. should_save : determined by Event::keep with the default set to true should_load : false, this is a new object and is not being read in updated : false, we haven't updated it yet
Finally, if we end up needing to save this object, we also making sure to call h5::Data::save enough times to align the number of entries in the serialized data with the current number of entries we are on (Event::i_entry_).
- Exceptions
-
Exception | if two data sets of the same name and the same pass are added |
Exception | if input DataType doesn't match the type stored in the data set |
- Template Parameters
-
DataType | type of data being added |
- Parameters
-
[in] | name | name of data being added |
[in] | data | actual value of data being added |
maybe throw bad_cast exception
template<typename DataType >
get a piece of data from the event
Object Deduction
Optionally providing a pass name means we need some automatic deduction of what the pass name should be. If the pass name is provided, all of the deduction procedure is skippped. A cache of known name -> name+pass deductions is kept in Event::known_lookups_ to save time. The deduction is pretty simple, we use Event::search with the input name and the demangled input type in order to retrieve a list of options. If the list of options is empty or has more than one element, we throw an exception, otherwise, we have successfully deduced the pass name.
If the requested object is not in the list of in-memory objects, then we must have an input file. This assumption is enforced with an exception the pointer to the input file is nullptr
. If we do have an input file, then we create a new in-memory object to read this data set. After wrapping the input data type with h5::Data, we deduce the other tags: should_save: use Event::keep with the default of false
should_load: true since this is a reading updated: false We also use h5::Data::load to get the reading pointer to the entry in the data set corresponding to the current entry we are on (Event::i_entry_).
After all of this setup, we attempt to retrieve the a constant reference to the data stored in the in-memory object.
- Exceptions
-
Exception | if requested data doesn't exist |
Exception | if requested DataType doesn't match type in data set |
- Template Parameters
-
DataType | type of requested data |
- Parameters
-
[in] | name | Name of requested data |
[in] | pass | optional pass name to use for getting the data |
- Returns
- const reference to data in event
Search through the available objects for a specific match.
This can be helpful for higher-level processors that require some amount of introsepction. Additionally, the EventObjectTag has the demangled type name for a specific event object, so the processor could use this functionality to more dynamically handle various types of event objects.
An empty matching string is interpreted as the "match anything" regex '.*'.
- Parameters
-
[in] | namematch | regex to match name of event object |
[in] | passmatch | regex to match pass of event object |
[in] | typematch | regex to match demangled type of event object |
- Returns
- list of event object tags that match all of the regex