iLab Neuromorphic Robotics Toolkit  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
nrt::BlackboardManager Class Reference

#include <nrt/Core/Blackboard/BlackboardManager.H>

The BlackboardManager component can be inserted into an nrt::Manager hierarchy to expose Blackboard options.

Users are strongly encouraged to create a BlackboardManager Component in every executable to expose some crucial parameters for configuring the global Blackboard, such as the network address of the master Blackboard, etc. See the Blackboard Parameters for more details.

Note that when and only when BlackboardManager is in initialized state, the Blackboard is in operational state.

Definition at line 97 of file BlackboardManager.H.

Inheritance diagram for nrt::BlackboardManager:
nrt::Manager nrt::Parameter< blackboardmanager::masterip, blackboardmanager::masterport, blackboardmanager::master, blackboardmanager::nick > nrt::Component nrt::Parameter< manager::help, manager::profilebb, manager::profilelog, manager::onlineprofile, manager::profilesaveto, manager::loglevel > nrt::ParameterRegistry nrt::Blackboard

Public Member Functions

 BlackboardManager (std::string const &instanceName="Blackboard")
 Constructor.
 
virtual ~BlackboardManager ()
 Destructor.
 
Blackboard federation runstate management
void fedinit ()
 Initialization. More...
 
void fedstart ()
 Starts the component, and its subtree, recursively. More...
 
void fedlaunch ()
 Launch the run() function, and propagate to subcomponents. More...
 
void fedendrun ()
 Switch out of running state and then call waitendrun() to wait for all run() threads to complete. More...
 
void fedstop ()
 Stops the component and its subtree, recursively. More...
 
void feduninit ()
 Un-initialize. More...
 
Local blackboard runstate management
void setRunStateFromMaster ()
 Set our runstate up/down to match the Blackboard federation master. More...
 
virtual void init ()
 Local initialization.
 
virtual void start ()
 Local start. More...
 
virtual void launch ()
 Local launch. More...
 
virtual void endrun ()
 Local endrun. More...
 
virtual void stop ()
 Local stop. More...
 
virtual void uninit ()
 Local un-init. More...
 
- Public Member Functions inherited from nrt::Manager
 Manager (std::string const &instanceID="TheManager")
 Constructor without command-line args. More...
 
 Manager (int argc, char const *argv[], std::string const &instanceID="TheManager")
 Constructor. More...
 
void setCommandLineArgs (int argc, char const *argv[])
 Set the command-line arguments, call this before start() if args were not passed at construction.
 
virtual ~Manager ()
 Destructor.
 
std::vector< std::string > const & remainingArgs () const
 Get the remaining arguments that were not parsed by the command line. More...
 
void delayParseCommandLine ()
 Do not parse command-line arguments during preInit() More...
 
template<>
std::shared_ptr< ComponentgetComponent (std::string const &instanceName) const
 
template<class Comp >
std::shared_ptr< Comp > addComponent (std::string const &instanceName="")
 Pseudo-constructor: construct a top-level Component. More...
 
template<class Comp >
std::shared_ptr< Comp > addSubComponent (std::string const &instanceName)=delete
 Use addComponent() on the Manager as opposed to nrt::Component::addSubComponent()
 
template<class Comp >
void removeComponent (std::shared_ptr< Comp > &component)
 Remove a top-level Component from the Manager, by shared_ptr. More...
 
template<class Comp >
void removeSubComponent (std::shared_ptr< Comp > &component)=delete
 Use removeComponent() on the Manager as opposed to nrt::Component::removeSubComponent()
 
void removeComponent (std::string const &instanceName)
 Remove a top-level Component from the Manager, by instance name.
 
void removeSubComponent (std::string const &instanceName)=delete
 Use removeComponent() on the Manager as opposed to nrt::Component::removeSubComponent()
 
template<class Comp = nrt::Component>
std::shared_ptr< Comp > getComponent (std::string const &instanceName) const
 Get a top-level component by instance name. More...
 
template<class Comp >
std::shared_ptr< Comp > getSubComponent (std::string const &instanceName) const =delete
 Use getComponent() on the Manager as opposed to nrt::Component::getSubComponent()
 
- Public Member Functions inherited from nrt::Component
 Component (std::string const &instanceName)
 Constructor. More...
 
void prepareForDeletion ()
 Prepare for deletion: uninit and disconnect from our parent. More...
 
virtual ~Component ()
 Virtual destructor for safe inheritance. More...
 
template<>
std::shared_ptr< ComponentgetSubComponent (std::string const &instanceName) const
 
template<class Comp >
std::shared_ptr< Comp > addSubComponent (std::string const &instanceName="")
 Pseudo-constructor: construct and add another component as a subcomponent of this one. More...
 
template<class Comp >
void removeSubComponent (std::shared_ptr< Comp > &component)
 Remove a sub-Component from this Component, by shared_ptr. More...
 
void removeSubComponent (std::string const &instanceName)
 Remove a sub-Component from this Component, by instance name.
 
template<class Comp = nrt::Component>
std::shared_ptr< Comp > getSubComponent (std::string const &instanceName) const
 Get a sub-component by instance name. More...
 
bool isTopLevel () const
 Returns true if this component is top-level, i.e., its parent is an nrt::Manager (including nrt::Blackboard)
 
bool initialized () const
 Has this component been initialized yet?
 
bool started () const
 Is this component started, i.e., it has passed the start() state and not yet entered the stop() state.
 
bool running () const
 Is this component running, i.e., has passed start() and been launch()ed and not yet entered the stop() state.
 
void wait ()
 Wait until all run() functions decide on their own that they are finished. More...
 
Component::MetaInfo const & meta () const
 Get the metainfo of this Component. More...
 
template<typename T >
std::vector< std::string > setParamVal (std::string const &paramdescriptor, T const &val)
 Set a parameter value. More...
 
template<typename T >
void setParamValUnique (std::string const &paramdescriptor, T const &val)
 Set a parameter value, simple version assuming only one parameter match. More...
 
template<typename T >
std::vector< std::pair
< std::string, T > > 
getParamVal (std::string const &paramdescriptor) const
 Get parameter(s) value(s) by descriptor. More...
 
template<typename T >
getParamValUnique (std::string const &paramdescriptor) const
 Get a parameter value, simple version assuming only one parameter match. More...
 
std::vector< std::string > setParamString (std::string const &paramdescriptor, std::string const &val)
 Set a parameter value, by string. More...
 
void setParamStringUnique (std::string const &paramdescriptor, std::string const &val)
 Set a parameter value by string, simple version assuming only one parameter match. More...
 
std::vector< std::pair
< std::string, std::string > > 
getParamString (std::string const &paramdescriptor) const
 Get a parameter value, by string. More...
 
std::string getParamStringUnique (std::string const &paramdescriptor) const
 Get a parameter value by string, simple version assuming only one parameter match. More...
 
std::string descriptor () const
 Get our full descriptor (including all parents) as [Classname-Instancename]:[...]:[...].
 
std::string parentModuleUID () const
 Get the ModuleUID (as string) of this Component's nearest parent Module, or an empty string.
 
void prettyPrintTree (std::ostream &os, int indent=0) const
 Produce a nice textual hierarchy of this Component's sub-tree.
 
std::vector< std::pair
< std::string,
nrt::ParameterSummary > > 
getParamSummary (std::string const &paramdescriptor) const
 Return a list of parameter summaries for a given descriptor. More...
 
std::vector< std::pair
< std::string,
nrt::ParameterSummary > > 
getParamSummary (bool skipsubmodules=false) const
 Return a list of parameter summaries for all parameters of this Component and its subcomponents. More...
 
void setPath (std::string const &path)
 Assign a filesystem path to this component.
 
std::string absolutePath (std::string const &path)
 If given path is relative (not starting with /), prepend the Component path to it; otherwise, no-op.
 
virtual void notifyAllParamChanged (nrt::ParameterState const state) const
 This method is called by the Blackboard to refresh a ParamChangedListener.
 
virtual void getAllParamSummaries (std::vector< nrt::ParameterSummary > &ps) const
 Recursively get all param summaries.
 
- Public Member Functions inherited from nrt::ParameterRegistry
void addParameter (ParameterBase *const param)
 The parameter class uses this method to register itself on construction with it's owning Component.
 
void removeParameter (ParameterBase *const param)
 The parameter class uses this method to un-register itself on destruction with it's owning Component.
 

Protected Member Functions

void preInit ()
 Called before all sub-Components are init()ed.
 
void preStop ()
 Called before all sub-Components are stop()ed.
 
void onParamChange (nrt::blackboardmanager::nick const &param, std::string const &newval)
 
- Protected Member Functions inherited from nrt::Manager
void preInit ()
 Calls parseCommandLine()
 
void postInit ()
 Checks for the –help flag.
 
void preStart ()
 Resets the nrt::CentralTimer.
 
void constructHelpMessage (std::ostream &out) const
 Constructs a help message from all parameters in the model, and outputs it to 'out'.
 
void printHelpMessage () const
 Constructs a help message and tries to send it to /usr/bin/less.
 
- Protected Member Functions inherited from nrt::Component
virtual void postStart ()
 Called after all sub-Components are start()ed.
 
virtual void run ()
 Called in its own thread after all Components have been start()ed. More...
 
virtual void postStop ()
 Called after all sub-Components are stop()ed.
 
virtual void preUninit ()
 Called before all sub-Components are uninit()ed.
 
virtual void postUninit ()
 Called after all sub-Components are uninit()ed.
 
virtual void notifyParamChanged (nrt::ParameterState const state, ParameterBase const *const param) const
 This method is called by a Parameter when it has been changed. Users should never overload this method.
 
void populateHelpMessage (std::string const &cname, std::unordered_map< std::string, std::unordered_map< std::string, std::vector< std::pair< std::string, std::string > > > > &helplist) const
 

Protected Attributes

boost::shared_mutex itsRunStateMtx
 Protect init()/start()/etc.
 

Member Function Documentation

void nrt::BlackboardManager::fedinit ( )

Initialization.

Dispatches the command to the entire Blackboard federation. Note that init() is usually handled locally by each Blackboard so you should typically not have to use this.

void nrt::BlackboardManager::fedstart ( )

Starts the component, and its subtree, recursively.

Dispatches the command to the entire Blackboard federation

void nrt::BlackboardManager::fedlaunch ( )

Launch the run() function, and propagate to subcomponents.

Dispatches the command to the entire Blackboard federation

Examples:
tests/test-Module.C.

Referenced by main().

void nrt::BlackboardManager::fedendrun ( )

Switch out of running state and then call waitendrun() to wait for all run() threads to complete.

Dispatches the command to the entire Blackboard federation

void nrt::BlackboardManager::fedstop ( )

Stops the component and its subtree, recursively.

Dispatches the command to the entire Blackboard federation

Examples:
tests/test-Module.C.

Referenced by main().

void nrt::BlackboardManager::feduninit ( )

Un-initialize.

Dispatches the command to the entire Blackboard federation. You would normally not use this as each Blackboard typically handles uninit() locally.

void nrt::BlackboardManager::setRunStateFromMaster ( )

Set our runstate up/down to match the Blackboard federation master.

Use this after everything is ready to go in apps that may join a running party. For example, nrDesigner uses this function so its start/stop button is correctly displayed even when the designer joins a federation that may or may not already be running().

virtual void nrt::BlackboardManager::start ( )
virtual

Local start.

See Component.H for explanations about run states.

Reimplemented from nrt::Component.

virtual void nrt::BlackboardManager::launch ( )
virtual

Local launch.

See Component.H for explanations about run states.

Reimplemented from nrt::Component.

Examples:
tests/test-ResultsSyntax.C, tests/test-split-messages.C, and tests/test-TransformManager.C.

Referenced by main().

virtual void nrt::BlackboardManager::endrun ( )
virtual

Local endrun.

See Component.H for explanations about run states.

Reimplemented from nrt::Component.

virtual void nrt::BlackboardManager::stop ( )
virtual

Local stop.

See Component.H for explanations about run states.

Reimplemented from nrt::Component.

Examples:
tests/test-split-messages.C.

Referenced by main().

virtual void nrt::BlackboardManager::uninit ( )
virtual

Local un-init.

See Component.H for explanations about run states.

Reimplemented from nrt::Component.


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