EventAnalysis  1.3.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
EA::DataProvider Class Reference

A base class for data providers. More...

#include <DataProvider.h>

Inheritance diagram for EA::DataProvider:
EA::Info EA::Configurable EA::ObjectProducer EA::RootDataProvider EA::RootDataProviderV0

Public Member Functions

 DataProvider (const std::string &name, const std::string &dataSource)
 Constructor. More...
 
virtual ~DataProvider ()=default
 Destructor. More...
 
const std::string & GetDataSource ()
 Getter for data source string. More...
 
bool IsDisabled ()
 Check if the data provider is disabled. More...
 
bool SetDisabled (bool disabled=true)
 Disables/enables the data provider. More...
 
RetrievalResult RetrieveObject (const std::string &name, ObjectCategory category, ObjectWrapper &wrapper, std::string &actualName)
 Retrieve the requested data object for current event. More...
 
virtual bool IsEventAvailable (unsigned int event)
 Checks if the data provider can provide the given event. More...
 
bool ConnectSource ()
 Opens the connection to the data source. More...
 
bool DisconnectSource ()
 Closes the connection to the data source. More...
 
bool SetEvent (unsigned int event, std::vector< std::string > &notValidGlobalObjects)
 Set the current event. More...
 
bool SetPass (unsigned int pass, unsigned int iteration)
 Set the current processing pass. More...
 
- Public Member Functions inherited from EA::Info
 Info (const std::string &name)
 Constructor. More...
 
virtual ~Info ()
 Destructor. More...
 
virtual const std::string GetType () const
 
virtual const std::string GetName () const
 The type (i.e. class) of the object. More...
 
virtual const std::string GetVersion () const
 The name of the object. More...
 
- Public Member Functions inherited from EA::Configurable
 Configurable ()
 Constructor. More...
 
template<typename T >
bool SetParameter (const std::string &name, const T &value)
 Set the value of a parameter. More...
 
bool SetParameter (const std::string &name, const char *value)
 Set the value of a string parameter using a string literal. More...
 
std::vector< std::string > GetParameters ()
 Get the names of the parameters. More...
 
- Public Member Functions inherited from EA::ObjectProducer
 ObjectProducer ()
 Constructor. More...
 
virtual ~ObjectProducer ()
 Destructor. More...
 
template<typename C >
void DeclareProducedObject (std::string name, ObjectCategory category, C aliases, std::string store)
 Declare a produced objects. More...
 
const ProducedObjectsGetProducedObjects () const
 Getter method for produced objects. More...
 
bool SetDisabled (bool disabled=true)
 Disables/enables the producer. More...
 
virtual std::vector< std::string > FreeObjects (const std::vector< std::string > &objs, Memory::Status memStatus)
 Free the memory for given objects. More...
 
template<>
void DeclareProducedObject (std::string name, ObjectCategory category, const char *alias, std::string store)
 

Private Member Functions

virtual bool Connect ()
 Opens the connection to the data source. More...
 
virtual bool Disconnect ()
 Closes the connection to the data source. More...
 
virtual RetrievalResult GetObject (const std::string &name, ObjectCategory category, ObjectWrapper &wrapper, std::string &actualName)
 Get the requested data object for current event. More...
 
virtual RetrievalResult GetObject (const std::string &name, ObjectCategory category, ObjectWrapper &wrapper)
 Get the requested data object for current event. More...
 
virtual bool SetCurrentEvent (unsigned int event, std::vector< std::string > &notValidGlobalObjects)
 Set the current event. More...
 
virtual bool SetCurrentEvent (unsigned int event)
 Set the current event. More...
 
virtual bool SetCurrentPass (unsigned int pass, unsigned int iteration)
 Set the current processing pass. More...
 

Private Attributes

std::string _dataSource
 
bool _disabled = false
 The data connection. More...
 

Additional Inherited Members

- Public Types inherited from EA::ObjectProducer
using ProducedObjects = std::vector< ProducedObject >
 Type for container of produced objects. More...
 
- Protected Member Functions inherited from EA::Info
 Info (const std::shared_ptr< Representation > &impl)
 
std::shared_ptr< Representation > & GetRepresentation ()
 
- Protected Member Functions inherited from EA::Configurable
template<typename T >
bool DefineParameter (const std::string &name, T &variable)
 Set a parameter. More...
 
 Configurable (const std::shared_ptr< Representation > &impl)
 
std::shared_ptr< Representation > & GetRepresentation ()
 
- Protected Member Functions inherited from EA::ObjectProducer
 ObjectProducer (const std::shared_ptr< Representation > &impl)
 
std::shared_ptr< Representation > & GetRepresentation ()
 

Detailed Description

A base class for data providers.

This abstract class declares the interface for classes that provide event informations.

Constructor & Destructor Documentation

◆ DataProvider()

EA::DataProvider::DataProvider ( const std::string &  name,
const std::string &  dataSource 
)
inline

Constructor.

The #dataSource parameter specifies the data source. It can be anything that identifies how to connect to a data source, like a file name, a glob expression, a database connection string etc. The data source string can be retrieved with the GetDataSource protected method.

Parameters
nameThe name of the data provider.
dataSourceReference to the data source.

◆ ~DataProvider()

virtual EA::DataProvider::~DataProvider ( )
virtualdefault

Destructor.

Member Function Documentation

◆ Connect()

virtual bool EA::DataProvider::Connect ( )
inlineprivatevirtual

Opens the connection to the data source.

This method opens the connection to the data source specified when calling the constructor.

Returns
true if the data source has been successfully connected.

Reimplemented in EA::RootDataProvider, and EA::RootDataProviderV0.

◆ ConnectSource()

bool EA::DataProvider::ConnectSource ( )

Opens the connection to the data source.

This method opens the connection to the data source specified when calling the constructor. If the data provider is disabled then no operation is done and true is returned.

Returns
true if the data source has been successfully connected.

◆ Disconnect()

virtual bool EA::DataProvider::Disconnect ( )
inlineprivatevirtual

Closes the connection to the data source.

This method closes the connection to the data source opened by Connect.

Returns
true if the data source has been successfully disconnected.

Reimplemented in EA::RootDataProvider, and EA::RootDataProviderV0.

◆ DisconnectSource()

bool EA::DataProvider::DisconnectSource ( )

Closes the connection to the data source.

This method closes the connection to the data source opened by ConnectSource. If the data provider is disabled then no operation is done and true is returned.

Returns
true if the data source has been successfully disconnected.

◆ GetDataSource()

const std::string& EA::DataProvider::GetDataSource ( )
inline

Getter for data source string.

Returns
The data source string specified as constructor argument.

◆ GetObject() [1/2]

virtual RetrievalResult EA::DataProvider::GetObject ( const std::string &  name,
ObjectCategory  category,
ObjectWrapper wrapper,
std::string &  actualName 
)
inlineprivatevirtual

Get the requested data object for current event.

Overrides of this method implements the actual retrieval of a data object from the provider's data source.

The possible return values are:

In case of RetrievalResult::SUCCESS, the requested object must be returned to the caller by means of the wrapper parameter; if the implementation recognizes the name of the requested parameter as an alias then it must return the actual object name by setting the actualName parameter. In any other case wrapper must be set equal to nullptr and actualName to "".

Parameters
nameThe name of the object.
categoryThe category of the object to be retrieved (ObjectCategory::EVENT, ObjectCategory::PASS or ObjectCategory::GLOBAL).
wrapperReturn wrapper for the desired object (wraps nothing if the object is non-existent or not available for the current event).
actualNamethe actual object name, in case name has been recognized as an alias.
Returns
the outcome of the retrieve operation.

Reimplemented in EA::RootDataProvider, and EA::RootDataProviderV0.

◆ GetObject() [2/2]

virtual RetrievalResult EA::DataProvider::GetObject ( const std::string &  name,
ObjectCategory  category,
ObjectWrapper wrapper 
)
inlineprivatevirtual

Get the requested data object for current event.

Overrides of this method implements the actual retrieval of a data object from the provider's data source.

Data providers that do not support aliases can override just this method instead of GetObject(const std::string &, ObjectCategory, ObjectWrapper &, std::string &).

It is provided mainly for backwards compatibility. New data provider implementations should override the other overload.

Parameters
nameThe name of the object.
categoryThe category of the object to be retrieved (ObjectCategory::EVENT, ObjectCategory::PASS or ObjectCategory::GLOBAL).
wrapperReturn wrapper for the desired object (wraps nothing if the object is non-existent or not available for the current event).
Returns
the outcome of the retrieve operation.

◆ IsDisabled()

bool EA::DataProvider::IsDisabled ( )
inline

Check if the data provider is disabled.

A disabled data provider does not provide any object; all of its methods will always return the values of this base implementation, regardless of the overrides in the derived classes.

Returns
true if the provider is disabled

◆ IsEventAvailable()

virtual bool EA::DataProvider::IsEventAvailable ( unsigned int  event)
inlinevirtual

Checks if the data provider can provide the given event.

This method checks if the given event is available. It is a more safe alternative than calling SetCurrentEvent and checking its return value, since this can invalidate global objects. Implementations of IsEventAvailable must have no no side effects.

Parameters
eventThe number of the event.
Returns
true if the given event can be provided, false otherwise.

Reimplemented in EA::RootDataProvider, and EA::RootDataProviderV0.

◆ RetrieveObject()

RetrievalResult EA::DataProvider::RetrieveObject ( const std::string &  name,
ObjectCategory  category,
ObjectWrapper wrapper,
std::string &  actualName 
)
inline

Retrieve the requested data object for current event.

The possible return values are:

In case of RetrievalResult::SUCCESS, the requested object is returned to the caller by means of the wrapper parameter; if the data provider recognizes the name of the requested parameter as an alias then it can return the actual object name by setting the actualName parameter. In any other case wrapper must be set equal to nullptr and actualName to "".

If the data provider is disabled then no object is retrieved and RetrievalResult::NOTFOUND is returned.

  • Parameters
    nameThe name of the object.
    categoryThe category of the object to be retrieved (ObjectCategory::EVENT, ObjectCategory::PASS or ObjectCategory::GLOBAL).
    wrapperReturn wrapper for the desired object (wraps nothing if the object is non-existent or not available for the current event).
    actualNamethe actual object name, in case name has been recognized as an alias.
    Returns
    the outcome of the retrieve operation.

◆ SetCurrentEvent() [1/2]

virtual bool EA::DataProvider::SetCurrentEvent ( unsigned int  event,
std::vector< std::string > &  notValidGlobalObjects 
)
inlineprivatevirtual

Set the current event.

Overrides of this method implements the setting of the current event.

This method will be called to communicate to the data provider the number of the current event. Subsequent calls to the GetObject method must load the data objects for the given event. In case the requested event is not available (e.g. there are less events than required) then the returned value must be false.

A list of global objects that were already provided by the provider in previous events, and that will need to be provided again for the current event, must be returned to the caller by filling the notValidGlobalObjects vector parameter.

Parameters
eventThe number of the current event.
notValidGlobalObjectsA list of global objects which are no longer valid and will need to be re-provided for the current event.
Returns
true if the requested event is available, false otherwise.

Reimplemented in EA::RootDataProvider, and EA::RootDataProviderV0.

◆ SetCurrentEvent() [2/2]

virtual bool EA::DataProvider::SetCurrentEvent ( unsigned int  event)
inlineprivatevirtual

Set the current event.

Overrides of this method implements the setting of the current event.

This overload of SetCurrentEvent must be overridden by those providers that does not encompass the possibility to invalidate global objects.

It is provided mainly for backwards compatibility. New data provider implementations should override the other overload.

Parameters
eventThe number of the current event.
Returns
true if the requested event is available, false otherwise.

◆ SetCurrentPass()

virtual bool EA::DataProvider::SetCurrentPass ( unsigned int  pass,
unsigned int  iteration 
)
inlineprivatevirtual

Set the current processing pass.

Overrides of this method implements the setting of the current processing pass.

This method will be called to communicate to the data provider the number of the current processing pass and of the current iteration for current pass. Subsequent calls to the RetrieveObject method must load the data objects for the given pass and iteration..

Parameters
passThe number of the current processing pass.
Returns
true if the pass setting has been successful.

◆ SetDisabled()

bool EA::DataProvider::SetDisabled ( bool  disabled = true)

Disables/enables the data provider.

Parameters
disabledIf true the data provider will be disabled, otherwise it will be enabled.
Returns
true if the provider has been successfully disabled/enabled.

◆ SetEvent()

bool EA::DataProvider::SetEvent ( unsigned int  event,
std::vector< std::string > &  notValidGlobalObjects 
)

Set the current event.

This method is used to communicate to the data provider the number of the current event. Subsequent calls to the RetrieveObject method will load the data objects for the given event. In case the requested event is not available (e.g. there are less events than required) then the returned value will be false.

A list of global objects that were already provided by the provider in previous events, and that will need to be provided again for the current event, is returned to the caller by filling the notValidGlobalObjects vector parameter. This can be useful to inform the caller about those global objects that needs to be re-read from the data source for the current event (e.g. the caller can remove them from the data store and thus a subsequent request from an algorithm will be passed to the data provider that could in turn provide the new version). This feature is available only for providers actually supporting

Parameters
eventThe number of the current event.
notValidGlobalObjectsA list of global objects which are no longer valid and will need to be re-provided for the current event.
Returns
true if the requested event is available, false otherwise.

◆ SetPass()

bool EA::DataProvider::SetPass ( unsigned int  pass,
unsigned int  iteration 
)

Set the current processing pass.

This method can be used to communicate to the data provider the number of the current processing pass and of the current iteration for current pass. Subsequent calls to the GetObject method will load the data objects for the given pass and iteration.

Parameters
passThe number of the current processing pass.
Returns
true if the pass setting has been successful.

Member Data Documentation

◆ _dataSource

std::string EA::DataProvider::_dataSource
private

◆ _disabled

bool EA::DataProvider::_disabled = false
private

The data connection.


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