#include <Beliefstate.h>
Public Member Functions | |
std::string | baseDataDirectory () |
Beliefstate (int argc, char **argv) | |
Constructor of the main belief state system class. | |
bool | cycle () |
Main cycle method, maintaining core functionality for the system. | |
Result | deinit () |
Deinitialization method for the belief state system. | |
std::string | findPrefixPath (std::string strPathList, std::string strMatchingSuffix, std::string strDelimiter=":") |
virtual std::string | findTokenReplacement (std::string strToken) |
bool | handleUnhandledEvent (Event evEvent) |
std::string | homeDirectory () |
Returns the current user's home directory. | |
Result | init (std::string strConfigFile="") |
Main initialization method for the belief state system. | |
bool | loadConfigFile (std::string strConfigFile) |
Loads the specified configuration file. | |
bool | loadIndividualPluginConfigurationBranch (libconfig::Setting &sBranch, CKeyValuePair *ckvpInto, std::string strConfigPath="", bool bIgnorePluginField=false) |
Loads the plugin-specific configuration portion of the configuration file. | |
std::string | resolveDirectoryTokens (std::string strPath) |
void | setBaseDataDirectory (std::string strBaseDataDirectory) |
bool | spreadEvent (Event evEvent) |
Spreads incoming system events to all subscribing plugins. | |
void | spreadServiceEvent (ServiceEvent seServiceEvent) |
Spread incoming system service events to all subscribing plugins. | |
void | triggerShutdown () |
Triggers the belief state system shutdown. | |
void | triggerTerminalResize () |
Triggers the processing of a terminal resize event. | |
std::string | version () |
Returns the current version of the belief state system software. | |
virtual std::string | workspaceDirectory () |
Returns the current set workspace directory. | |
~Beliefstate () | |
Destructor of the main belief state system class. | |
Protected Attributes | |
std::list< std::string > | m_lstConfigFileLocations |
Private Attributes | |
int | m_argc |
Internal copy of the global argc parameter holding the number of command line parameters supplied when starting the system. This parameter, together with m_argv, is handed to all plugins during initialization. | |
char ** | m_argv |
Internal copy of the global argv parameter holding the command line parameter values supplied when starting the system. This parameter, together with m_argc, is handed to all plugins during initialization. | |
bool | m_bCommandLineOutput |
Flag that signals whether command line output should be printed or not. | |
bool | m_bOnlyDisplayImportant |
Flag that signals whether all, or only important messages should be printed to the console. | |
bool | m_bRun |
Flag representing the current run state of the main loop cycle. If true, the main loop will continue to run; if false, will stop execution of the main loop and quit. | |
bool | m_bTerminalWindowResize |
Flag that signals whether the terminal window is currently being resized. | |
std::list< Event > | m_lstGlobalEvents |
List of currently available global events to process. The entries in this list only last one cycle of the main loop. They are dropped afterwards, but are handed to all plugins that subscribed to the respective event type beforehand. This is the main communication mechanism between the belief state system and loaded plugins. | |
std::list< std::string > | m_lstPluginsToLoad |
List of plugins to load. This list is populated by the plugins/load configuration section in the configuration file. | |
std::mutex | m_mtxTerminalResize |
Mutex that controls whether terminal window resizes are currently being processed. | |
PluginSystem * | m_psPlugins |
Internal pointer to the PluginSystem class instance used for loading and managing plugin instances. | |
std::string | m_strVersion |
Variable holding the current version of the belief state system core software. | |
std::string | m_strWorkspaceDirectory |
In case a static workspace directory was specified in the configuration file, its value is stored here. This value, if not empty, takes precedence over the dynamically resolved return value of workspaceDirectory(). |
Definition at line 64 of file Beliefstate.h.
beliefstate::Beliefstate::Beliefstate | ( | int | argc, |
char ** | argv | ||
) |
Constructor of the main belief state system class.
argc | The main argc variable supplied to main(), holding the number of available command line parameters issues when running the system. |
argv | The main argv variable supplied to main(), holding the actual available command line parameters issues when running the system. |
Definition at line 44 of file Beliefstate.cpp.
Destructor of the main belief state system class.
Deletes all instances of internal objects.
Definition at line 62 of file Beliefstate.cpp.
std::string beliefstate::Beliefstate::baseDataDirectory | ( | ) |
Definition at line 706 of file Beliefstate.cpp.
bool beliefstate::Beliefstate::cycle | ( | ) |
Main cycle method, maintaining core functionality for the system.
The main cycle function triggers processing of event pipelines, and forwards messages between plugins, utilizing functions present in the beliefstate class. This function is being called from outside the function in a loop.
Definition at line 531 of file Beliefstate.cpp.
Deinitialization method for the belief state system.
Dummy deinitialization method, does not deinitialize any components. Implemented for the sake of completeness and to make subclassing easier in which actual deinitialization mechanisms might occur.
Definition at line 143 of file Beliefstate.cpp.
std::string beliefstate::Beliefstate::findPrefixPath | ( | std::string | strPathList, |
std::string | strMatchingSuffix, | ||
std::string | strDelimiter = ":" |
||
) |
Definition at line 814 of file Beliefstate.cpp.
std::string beliefstate::Beliefstate::findTokenReplacement | ( | std::string | strToken | ) | [virtual] |
Reimplemented in beliefstate::BeliefstateROS.
Definition at line 788 of file Beliefstate.cpp.
bool beliefstate::Beliefstate::handleUnhandledEvent | ( | Event | evEvent | ) |
Definition at line 798 of file Beliefstate.cpp.
std::string beliefstate::Beliefstate::homeDirectory | ( | ) |
Returns the current user's home directory.
Returns whatever is stored in the environmental variable '${HOME}'.
Definition at line 715 of file Beliefstate.cpp.
Result beliefstate::Beliefstate::init | ( | std::string | strConfigFile = "" | ) |
Main initialization method for the belief state system.
Initializes the default search paths for configuration files, creates instances for the PluginSystem and triggers the loading of configuration files and plugins (as configured).
strConfigFile | Overrides the default plugin search mechanism and uses the file specified in this parameter. If this fails, the function falls back to the default mechanism. |
Definition at line 69 of file Beliefstate.cpp.
bool beliefstate::Beliefstate::loadConfigFile | ( | std::string | strConfigFile | ) |
Loads the specified configuration file.
Loads the libconfig-styled configuration file specified in the parameter. Will update all components in the main belief state system instance that are affected by the configured options.
strConfigFile | Configuration file path to open for loading configuration |
Definition at line 153 of file Beliefstate.cpp.
bool beliefstate::Beliefstate::loadIndividualPluginConfigurationBranch | ( | libconfig::Setting & | sBranch, |
CKeyValuePair * | ckvpInto, | ||
std::string | strConfigPath = "" , |
||
bool | bIgnorePluginField = false |
||
) |
Loads the plugin-specific configuration portion of the configuration file.
Every named plugin can be configured individually from the main configuration file. This function (recursively) evaluates the specified options to allow for arbitrary tree-like configuration of every plugin.
sBranch | The libconfig Setting which denotes the current configuration group for the current plugin. |
ckvpInto | The CKeyValuePair instance into which the loaded configuration branch should be parsed. |
strConfigPath | The current path in the nested configuration groups. This is for displaying nice output only. |
bIgnorePluginField | Ignore the 'plugin' field in the current branch. This is only used on the first level, as that level holds the plugin name of the plugin to configure. |
Definition at line 391 of file Beliefstate.cpp.
std::string beliefstate::Beliefstate::resolveDirectoryTokens | ( | std::string | strPath | ) |
Definition at line 726 of file Beliefstate.cpp.
void beliefstate::Beliefstate::setBaseDataDirectory | ( | std::string | strBaseDataDirectory | ) |
Definition at line 700 of file Beliefstate.cpp.
bool beliefstate::Beliefstate::spreadEvent | ( | Event | evEvent | ) |
Spreads incoming system events to all subscribing plugins.
System events are being accumulated in the system event queue within the main Beliefstate class instance. They are then distributed among the plugins that subscribed to their specific event type.
evEvent | The event to spread among subscribers |
Definition at line 483 of file Beliefstate.cpp.
void beliefstate::Beliefstate::spreadServiceEvent | ( | ServiceEvent | seServiceEvent | ) |
Spread incoming system service events to all subscribing plugins.
System service events are special events that require a reply from potential receivers. This function spreads a service event request, and its corresponding reply, to the respective plugin instances.
seServiceEvent | The service event to spread among subscribers (and receivers of replies). |
Definition at line 507 of file Beliefstate.cpp.
Triggers the belief state system shutdown.
Sets the m_bRun class member to false, effectively letting the main loop cycle() method stop execution and return from its blocking call.
Definition at line 690 of file Beliefstate.cpp.
Triggers the processing of a terminal resize event.
Definition at line 694 of file Beliefstate.cpp.
std::string beliefstate::Beliefstate::version | ( | ) |
Returns the current version of the belief state system software.
The version string can contain a version number, and additional content, describing the exact version present.
Definition at line 65 of file Beliefstate.cpp.
std::string beliefstate::Beliefstate::workspaceDirectory | ( | ) | [virtual] |
Returns the current set workspace directory.
The workspace directory is a globally set path that can be used as a reference point for directory tokens. It is referenced as $WORKSPACE. In this function, the directory manually set in the config.cfg file is returned, or an empty string if it is not set there.
Reimplemented in beliefstate::BeliefstateROS.
Definition at line 711 of file Beliefstate.cpp.
int beliefstate::Beliefstate::m_argc [private] |
Internal copy of the global argc parameter holding the number of command line parameters supplied when starting the system. This parameter, together with m_argv, is handed to all plugins during initialization.
Definition at line 77 of file Beliefstate.h.
char** beliefstate::Beliefstate::m_argv [private] |
Internal copy of the global argv parameter holding the command line parameter values supplied when starting the system. This parameter, together with m_argc, is handed to all plugins during initialization.
Definition at line 82 of file Beliefstate.h.
bool beliefstate::Beliefstate::m_bCommandLineOutput [private] |
Flag that signals whether command line output should be printed or not.
Definition at line 113 of file Beliefstate.h.
bool beliefstate::Beliefstate::m_bOnlyDisplayImportant [private] |
Flag that signals whether all, or only important messages should be printed to the console.
Reimplemented from beliefstate::UtilityBase.
Definition at line 116 of file Beliefstate.h.
bool beliefstate::Beliefstate::m_bRun [private] |
Flag representing the current run state of the main loop cycle. If true, the main loop will continue to run; if false, will stop execution of the main loop and quit.
Definition at line 72 of file Beliefstate.h.
bool beliefstate::Beliefstate::m_bTerminalWindowResize [private] |
Flag that signals whether the terminal window is currently being resized.
Definition at line 110 of file Beliefstate.h.
std::list<std::string> beliefstate::Beliefstate::m_lstConfigFileLocations [protected] |
Definition at line 122 of file Beliefstate.h.
std::list<Event> beliefstate::Beliefstate::m_lstGlobalEvents [private] |
List of currently available global events to process. The entries in this list only last one cycle of the main loop. They are dropped afterwards, but are handed to all plugins that subscribed to the respective event type beforehand. This is the main communication mechanism between the belief state system and loaded plugins.
Definition at line 93 of file Beliefstate.h.
std::list<std::string> beliefstate::Beliefstate::m_lstPluginsToLoad [private] |
List of plugins to load. This list is populated by the plugins/load configuration section in the configuration file.
Definition at line 86 of file Beliefstate.h.
std::mutex beliefstate::Beliefstate::m_mtxTerminalResize [private] |
Mutex that controls whether terminal window resizes are currently being processed.
Terminal resize events can be received very qickly after another. When one of these events is being processed, it should not be interrupted by a new event following it, as system calls and non-thread-safe operations are involved.
Definition at line 107 of file Beliefstate.h.
Internal pointer to the PluginSystem class instance used for loading and managing plugin instances.
Definition at line 68 of file Beliefstate.h.
std::string beliefstate::Beliefstate::m_strVersion [private] |
Variable holding the current version of the belief state system core software.
Definition at line 119 of file Beliefstate.h.
std::string beliefstate::Beliefstate::m_strWorkspaceDirectory [private] |
In case a static workspace directory was specified in the configuration file, its value is stored here. This value, if not empty, takes precedence over the dynamically resolved return value of workspaceDirectory().
Definition at line 98 of file Beliefstate.h.