Belle II Software  release-08-01-10
Framework Class Reference

This class combines all subsystems of the framework, and exports the main interface to Python. More...

#include <Framework.h>

Public Member Functions

 Framework ()
 Constructor.
 
virtual ~Framework ()
 Destructor.
 

Static Public Member Functions

static void addModuleSearchPath (const std::string &path)
 Adds a new filepath to the list of filepaths which are searched for modules. More...
 
static void setExternalsPath (const std::string &path)
 Sets the path in which the externals of the framework are located. More...
 
static ModulePtr registerModule (const std::string &moduleName)
 Registers a new module to the framework and returns a shared pointer. More...
 
static ModulePtr registerModule (const std::string &moduleName, const std::string &sharedLibPath)
 Registers a new module to the framework and returns a shared pointer. More...
 
static void process (PathPtr startPath, long maxEvent=0)
 Processes up to maxEvent events by starting with the first module in the specified path. More...
 
static void setNumberProcesses (int numProcesses)
 Function to set number of worker processes for parallel processing.
 
static int getNumberProcesses ()
 Function to get number of worker processes for parallel processing.
 
static void setPicklePath (const std::string &path)
 Function to set the path to the file where the pickled path is stored. More...
 
static std::string getPicklePath ()
 Function to get the path to the file where the pickled path is stored. More...
 
static void setStreamingObjects (const boost::python::list &streamingObjects)
 Function to set streaming objects for Tx module. More...
 
static void setRealm (const std::string &realm)
 Function to set the execution realm. More...
 
static std::string findFile (const std::string &filename, const std::string &type, bool ignore_errors=false)
 Find a file. More...
 
static boost::python::list getModuleSearchPathsPython ()
 Returns a list of all module search paths known to the framework. More...
 
static boost::python::dict getAvailableModulesPython ()
 Returns a dictionary containing the found modules and the filenames of the shared libraries in which they can be found. More...
 
static boost::python::list getRegisteredModulesPython ()
 Returns a list of all registered modules. More...
 
static void exposePythonAPI ()
 Exposes methods of the Framework class to Python.
 

Detailed Description

This class combines all subsystems of the framework, and exports the main interface to Python.

Definition at line 27 of file Framework.h.

Member Function Documentation

◆ addModuleSearchPath()

void addModuleSearchPath ( const std::string &  path)
static

Adds a new filepath to the list of filepaths which are searched for modules.

If a module is requested by the method registerModule(), all module search paths are scanned for shared libraries or map files which contain the requested module.

Parameters
pathThe module search path which should be added to the list of paths.

Definition at line 64 of file Framework.cc.

65 {
67 }
static ModuleManager & Instance()
Exception is thrown if the requested module could not be created by the ModuleManager.
void addModuleSearchPath(const std::string &path)
Adds a new filepath to the list of filepaths which are searched for a requested module.

◆ findFile()

std::string findFile ( const std::string &  filename,
const std::string &  type,
bool  ignore_errors = false 
)
static

Find a file.

This is a wrapper around FileSystem::findFile() to be able to call it nicely from python and create a FileNotFoundError if the file cannot be found.

Known types:

  • empty string: exactly like FileSystem::findFile, look in $BELLE2_LOCAL_DIR and then $BELLE2_RELEASE_DIR and then relative to local dir
  • 'examples': look for example data in $BELLE2_EXAMPLES_DATA_DIR, then relative to the local directory
  • 'validation': look for validation data in $BELLE2_VALIDATION_DATA_DIR, then relative to the local directory
Parameters
filenamerelative filename to look for, either in a central place or in the current working directory
typeif set, specifies where to look if the file cannot be found locally
ignore_errorsif true don't print any errors and silently return None. Otherwise this function will raise a FileNotFoundError exception if the file cannot be found.
Returns
relative or absolute filename if found, empty string if not found and ignore_errors is true

Definition at line 217 of file Framework.cc.

◆ getAvailableModulesPython()

boost::python::dict getAvailableModulesPython ( )
static

Returns a dictionary containing the found modules and the filenames of the shared libraries in which they can be found.

Returns
A python dictionary dictionary containing the found modules.

Definition at line 251 of file Framework.cc.

◆ getModuleSearchPathsPython()

boost::python::list getModuleSearchPathsPython ( )
static

Returns a list of all module search paths known to the framework.

Returns
A python list containing all module search paths known to the framework.

Definition at line 241 of file Framework.cc.

◆ getPicklePath()

std::string getPicklePath ( )
static

Function to get the path to the file where the pickled path is stored.

Returns
path to file where the pickled path is stored

Definition at line 186 of file Framework.cc.

◆ getRegisteredModulesPython()

boost::python::list getRegisteredModulesPython ( )
static

Returns a list of all registered modules.

Returns
A python list containing all registered modules.

Definition at line 260 of file Framework.cc.

◆ process()

void process ( PathPtr  startPath,
long  maxEvent = 0 
)
static

Processes up to maxEvent events by starting with the first module in the specified path.

This method starts processing events only if there is a module in the path which is capable of specifying the end of the data flow.

Parameters
startPathThe processing starts with the first module of this path.
maxEventThe maximum number of events that will be processed. If the number is smaller than 1, all events will be processed (default).

Definition at line 88 of file Framework.cc.

◆ registerModule() [1/2]

ModulePtr registerModule ( const std::string &  moduleName)
static

Registers a new module to the framework and returns a shared pointer.

This method creates a new Module based on the given module name. If the shared library file containing the module was already loaded, the module is directly created. Otherwise the shared library file is dynamically loaded first.

If the module could not be registered, an exception of type ModuleNotCreatedError is thrown.

Parameters
moduleNameThe unique name of the module which should be created.
Returns
A shared pointer of the newly created and registered module.

Definition at line 76 of file Framework.cc.

◆ registerModule() [2/2]

ModulePtr registerModule ( const std::string &  moduleName,
const std::string &  sharedLibPath 
)
static

Registers a new module to the framework and returns a shared pointer.

This method creates a new Module based on the given module name. If the shared library file containing the module was already loaded, the module is directly created. Otherwise the shared library file is dynamically loaded first.

If the module could not be registered, an exception of type ModuleNotCreatedError is thrown.

Parameters
moduleNameThe unique name of the module which should be created.
sharedLibPathOptional: The shared library from which the module should be registered (not a map file !).
Returns
A shared pointer of the newly created and registered module.

Definition at line 82 of file Framework.cc.

◆ setExternalsPath()

void setExternalsPath ( const std::string &  path)
static

Sets the path in which the externals of the framework are located.

Parameters
pathThe path in which the externals of the framework are located.

Definition at line 70 of file Framework.cc.

◆ setPicklePath()

void setPicklePath ( const std::string &  path)
static

Function to set the path to the file where the pickled path is stored.

Parameters
pathpath to file where the pickled path is stored

Definition at line 180 of file Framework.cc.

◆ setRealm()

void setRealm ( const std::string &  realm)
static

Function to set the execution realm.

Parameters
realmbasf2 execution realm

Definition at line 197 of file Framework.cc.

◆ setStreamingObjects()

void setStreamingObjects ( const boost::python::list &  streamingObjects)
static

Function to set streaming objects for Tx module.

Parameters
streamingObjectsobjects to be streamed

Definition at line 191 of file Framework.cc.


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