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

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...
 

Detailed Description

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.

Author
heddle (original Java file).
timmer
Date
5/19/2020

Member Function Documentation

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.

Parameters
listenerThe Evio listener to add.
void evio::EventParser::eventParse ( std::shared_ptr< EvioEvent > &  evioEvent)
static

Method for parsing the event which will drill down and uncover all structures.

Parameters
evioEventthe event to parse.

Referenced by evio::EvioReader::parseEvent().

void evio::EventParser::getMatchingStructures ( std::shared_ptr< BaseStructure > const &  structure,
std::shared_ptr< IEvioFilter > const &  filter,
std::vector< std::shared_ptr< BaseStructure >> &  structs 
)
static

Visit all the descendant structures, and collect those that pass a filter.

Parameters
structurethe structure to start scanning.
filterthe filter that must be passed. If nullptr, this will return all the structures.
structsvector 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.

Returns
true if notification of events to the listeners is active.

References notificationActive.

void evio::EventParser::notifyEvioListeners ( std::shared_ptr< EvioEvent > &  evioEvent,
std::shared_ptr< BaseStructure > &  structure 
)
protected

This is when a structure is encountered while parsing an event.

It notifies all listeners about the structure.

Parameters
evioEventevent being parsed
structurethe structure encountered, which may be a Bank, Segment, or TagSegment.

References notificationActive.

void evio::EventParser::notifyStart ( std::shared_ptr< EvioEvent > &  evioEvent)
protected

Notify listeners we are starting to parse a new event.

Parameters
evioEventthe event in question;

References notificationActive.

Referenced by parseEvent().

void evio::EventParser::notifyStop ( std::shared_ptr< EvioEvent > &  evioEvent)
protected

Notify listeners we are done to parsing a new event.

Parameters
evioEventthe 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.

Parameters
evioEventthe event to parse.
Exceptions
EvioExceptionif 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().

Parameters
evioEventthe event to parse.
syncedif true, mutex protect this method.
Exceptions
EvioExceptionif 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.

Parameters
listenerThe 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.

Parameters
filterthe filter to set.
See Also
IEvioFilter
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.

Parameters
activeset true if notification of events to the listeners is active.

References notificationActive.

void evio::EventParser::vistAllStructures ( std::shared_ptr< BaseStructure > const &  structure,
std::shared_ptr< IEvioListener > const &  listener 
)
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.

Parameters
structurethe structure to start scanning.
listeneran listener to notify as each structure is visited.

Referenced by getMatchingStructures().

void evio::EventParser::vistAllStructures ( std::shared_ptr< BaseStructure > const &  structure,
std::shared_ptr< IEvioListener > const &  listener,
std::shared_ptr< IEvioFilter > const &  filter 
)
static

Visit all the structures in the given structure (including the structure itself – which is considered its own descendant) in a depth first manner.

Parameters
structurethe structure to start scanning.
listeneran listener to notify as each structure is visited.
filteran 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.

Member Data Documentation

std::recursive_mutex evio::EventParser::mtx
protected

Mutex for thread safety.

Referenced by parseEvent().

bool evio::EventParser::notificationActive = true
protected

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