evio
6.0
|
Creates an object that controls the parsing of events. More...
#include <EventParser.h>
Public Member Functions | |
void | parseEvent (std::shared_ptr< EvioEvent > &evioEvent) |
This is the workhorse method for parsing the event. More... | |
void | parseEvent (std::shared_ptr< EvioEvent > &evioEvent, bool synced) |
This is the workhorse method for parsing the event. More... | |
void | removeEvioListener (std::shared_ptr< IEvioListener > listener) |
Remove an Evio listener. More... | |
void | addEvioListener (std::shared_ptr< IEvioListener > listener) |
Add an Evio listener. More... | |
bool | isNotificationActive () const |
Get the flag determining whether notification of listeners is active. More... | |
void | setNotificationActive (bool notificationActive) |
Set the flag determining whether notification of listeners is active. More... | |
void | setEvioFilter (std::shared_ptr< IEvioFilter > evioFilter) |
Set the global filter used for filtering structures. More... | |
Static Public Member Functions | |
static void | eventParse (std::shared_ptr< EvioEvent > &evioEvent) |
Method for parsing the event which will drill down and uncover all structures. More... | |
static void | vistAllStructures (std::shared_ptr< BaseStructure > const &structure, std::shared_ptr< IEvioListener > const &listener) |
Visit all the structures in the given structure (including the structure itself – which is considered its own descendant). More... | |
static void | vistAllStructures (std::shared_ptr< BaseStructure > const &structure, std::shared_ptr< IEvioListener > const &listener, std::shared_ptr< IEvioFilter > const &filter) |
Visit all the structures in the given structure (including the structure itself – which is considered its own descendant) in a depth first manner. More... | |
static void | getMatchingStructures (std::shared_ptr< BaseStructure > const &structure, std::shared_ptr< IEvioFilter > const &filter, std::vector< std::shared_ptr< BaseStructure >> &structs) |
Visit all the descendant structures, and collect those that pass a filter. More... | |
Protected Member Functions | |
void | notifyEvioListeners (std::shared_ptr< EvioEvent > &event, std::shared_ptr< BaseStructure > &structure) |
This is when a structure is encountered while parsing an event. More... | |
void | notifyStart (std::shared_ptr< EvioEvent > &event) |
Notify listeners we are starting to parse a new event. More... | |
void | notifyStop (std::shared_ptr< EvioEvent > &event) |
Notify listeners we are done to parsing a new event. More... | |
Protected Attributes | |
bool | notificationActive = true |
std::recursive_mutex | mtx |
Mutex for thread safety. More... | |
Creates an object that controls the parsing of events.
This object, like the EvioReader object, has a method for parsing an event. An EvioReader object will ultimately call this method–i.e., the concrete implementation of event parsing is in this class. There is also a static method to do the parsing of an event, but without notifications.
This class is also used to scan already parsed structures in a BaseStructure tree. Originally, in it's java form, the "visit" methods were part of the BaseStructure class, but since that results in C++ circular references, it is now in this class and slightly modified to be static.
void evio::EventParser::addEvioListener | ( | std::shared_ptr< IEvioListener > | listener | ) |
Add an Evio listener.
Evio listeners listen for structures encountered when an event is being parsed.
listener | The Evio listener to add. |
|
static |
Method for parsing the event which will drill down and uncover all structures.
evioEvent | the event to parse. |
Referenced by evio::EvioReader::parseEvent().
|
static |
Visit all the descendant structures, and collect those that pass a filter.
structure | the structure to start scanning. |
filter | the filter that must be passed. If nullptr , this will return all the structures. |
structs | vector to be filled with all structures that are accepted by filter. |
References vistAllStructures().
bool evio::EventParser::isNotificationActive | ( | ) | const |
Get the flag determining whether notification of listeners is active.
Normally it is. But in some cases it should be temporarily suspended. For example, in a "goto event" process, the listeners will not be notified of the intervening events as the file is scanned to get to the target event.
true
if notification of events to the listeners is active. References notificationActive.
|
protected |
This is when a structure is encountered while parsing an event.
It notifies all listeners about the structure.
evioEvent | event being parsed |
structure | the structure encountered, which may be a Bank, Segment, or TagSegment. |
References notificationActive.
|
protected |
Notify listeners we are starting to parse a new event.
evioEvent | the event in question; |
References notificationActive.
Referenced by parseEvent().
|
protected |
Notify listeners we are done to parsing a new event.
evioEvent | the event in question; |
References notificationActive.
Referenced by parseEvent().
void evio::EventParser::parseEvent | ( | std::shared_ptr< EvioEvent > & | evioEvent | ) |
This is the workhorse method for parsing the event.
It will drill down and uncover all structures (banks, segments, and tagsegments) and notify any interested listeners in a SAX-Like manner.
evioEvent | the event to parse. |
EvioException | if arg is null or data not in evio format. |
References mtx, notifyStart(), and notifyStop().
Referenced by parseEvent().
void evio::EventParser::parseEvent | ( | std::shared_ptr< EvioEvent > & | evioEvent, |
bool | synced | ||
) |
This is the workhorse method for parsing the event.
It will drill down and uncover all structures (banks, segments, and tagsegments) and notify any interested listeners in a SAX-Like manner.
Note: applications may choose not to provide a listener. In that case, when the event is parsed, its structures may be accessed through the event's tree model, i.e., via event.getTreeModel()
.
evioEvent | the event to parse. |
synced | if true, mutex protect this method. |
EvioException | if arg is null or data not in evio format. |
References notifyStart(), notifyStop(), and parseEvent().
void evio::EventParser::removeEvioListener | ( | std::shared_ptr< IEvioListener > | listener | ) |
Remove an Evio listener.
Evio listeners listen for structures encountered when an event is being parsed.
listener | The Evio listener to remove. |
void evio::EventParser::setEvioFilter | ( | std::shared_ptr< IEvioFilter > | filter | ) |
Set the global filter used for filtering structures.
If set to null
, the default, then all structures will be sent to the listeners.
filter | the filter to set. |
void evio::EventParser::setNotificationActive | ( | bool | active | ) |
Set the flag determining whether notification of listeners is active.
Normally it is. But in some cases it should be temporarily suspended. For example, in a "goto event" process, the listeners will not be notified of the intervening events as the file is scanned to get to the target event.
active | set true if notification of events to the listeners is active. |
References notificationActive.
|
static |
Visit all the structures in the given structure (including the structure itself – which is considered its own descendant).
This is similar to listening to the event as it is being parsed, but is done to a complete (already) parsed event.
structure | the structure to start scanning. |
listener | an listener to notify as each structure is visited. |
Referenced by getMatchingStructures().
|
static |
Visit all the structures in the given structure (including the structure itself – which is considered its own descendant) in a depth first manner.
structure | the structure to start scanning. |
listener | an listener to notify as each structure is visited. |
filter | an optional filter that must "accept" structures before they are passed to the listener. If null , all structures are passed. In this way, specific types of structures can be captured. |
|
protected |
Mutex for thread safety.
Referenced by parseEvent().
|
protected |
Referenced by isNotificationActive(), notifyEvioListeners(), notifyStart(), notifyStop(), and setNotificationActive().