mc_control::fsm::StateFactory Class Reference

#include <mc_control/fsm/StateFactory.h>

Inheritance diagram for mc_control::fsm::StateFactory:
Collaboration diagram for mc_control::fsm::StateFactory:

Classes

struct  StateConfiguration
 

Public Member Functions

 StateFactory (const std::vector< std::string > &paths, const std::vector< std::string > &files, bool verbose)
 
void load_libraries (const std::vector< std::string > &paths)
 
void load_files (const std::vector< std::string > &files)
 
void load (const std::map< std::string, mc_rtc::Configuration > &states)
 
void load (const std::string &name, const std::string &base, const mc_rtc::Configuration &config)
 
StatePtr create (const std::string &state, Controller &ctl, const mc_rtc::Configuration &config)
 
StatePtr create (const std::string &state, Controller &ctl)
 
StatePtr create (const std::string &state, const mc_rtc::Configuration &config)
 
StatePtr create (const std::string &state)
 
bool hasState (const std::string &state) const
 
const std::vector< std::string > & states () const
 
bool load_with_loader (const std::string &state)
 
template<typename RetT , typename... Args>
void register_object (const std::string &name, std::function< RetT *(const Args &...)> callback)
 
const StateConfigurationconfiguration (const std::string &state) const
 
- Public Member Functions inherited from mc_rtc::ObjectLoader< State >
 ObjectLoader (const std::string &class_name, const std::vector< std::string > &paths, bool verbose, Loader::callback_t cb=Loader::default_cb)
 
 ~ObjectLoader ()
 
bool has_object (const std::string &name) const
 
std::vector< std::string > objects () const
 
void load_libraries (const std::vector< std::string > &paths, Loader::callback_t cb=Loader::default_cb)
 
void clear ()
 
void set_verbosity (bool verbose)
 
void register_object (const std::string &name, std::function< RetT *(const Args &...)> callback)
 
std::shared_ptr< T > create_object (const std::string &name, Args... args)
 
std::string get_object_runtime_directory (const std::string &name) const noexcept
 
unique_ptr create_unique_object (const std::string &name, Args... args)
 

Additional Inherited Members

- Public Types inherited from mc_rtc::ObjectLoader< State >
using unique_ptr = std::unique_ptr< T, ObjectDeleter >
 
- Protected Member Functions inherited from mc_rtc::ObjectLoader< State >
T * create (const std::string &name, Args... args)
 
T * create_from_handles (const std::string &name, Args... args)
 
T * create_from_callbacks (const std::string &name, Args... args)
 
- Protected Attributes inherited from mc_rtc::ObjectLoader< State >
std::string class_name
 
bool verbose
 
Loader::handle_map_t handles_
 
mc_rtc::DataStore callbacks_
 
std::unordered_map< std::string, ObjectDeleter > deleters_
 

Detailed Description

Creates State objects based on name and configuration entries.

Also maintains a list of available states.

Constructor & Destructor Documentation

◆ StateFactory()

mc_control::fsm::StateFactory::StateFactory ( const std::vector< std::string > &  paths,
const std::vector< std::string > &  files,
bool  verbose 
)

Constructor

Parameters
pathsList of paths to load states libraries from
statesList of states files (json/yaml) to read states from

\bool verbose If true, output some warning information

Member Function Documentation

◆ configuration()

const StateConfiguration& mc_control::fsm::StateFactory::configuration ( const std::string &  state) const
inline

Returns the configuration of a specific state

◆ create() [1/4]

StatePtr mc_control::fsm::StateFactory::create ( const std::string &  state)

Creates a state but does not start it

This is meant for tools working with the FSM

◆ create() [2/4]

StatePtr mc_control::fsm::StateFactory::create ( const std::string &  state,
const mc_rtc::Configuration config 
)

Creates a and configures a state but does not start it

This is meant for tools working with the FSM

◆ create() [3/4]

StatePtr mc_control::fsm::StateFactory::create ( const std::string &  state,
Controller ctl 
)

Creates a state without extra configuration

◆ create() [4/4]

StatePtr mc_control::fsm::StateFactory::create ( const std::string &  state,
Controller ctl,
const mc_rtc::Configuration config 
)

Creates a state given its name, the owning controller and configuration

The state must have been loaded previously (either as a library or through a state file. Otherwise the returned pointer is nullptr.

◆ hasState()

bool mc_control::fsm::StateFactory::hasState ( const std::string &  state) const

Query existence of a state

◆ load() [1/2]

void mc_control::fsm::StateFactory::load ( const std::map< std::string, mc_rtc::Configuration > &  states)

Load from an mc_rtc::Configuration entry

◆ load() [2/2]

void mc_control::fsm::StateFactory::load ( const std::string &  name,
const std::string &  base,
const mc_rtc::Configuration config 
)

Load one state from a configuration entry

Can be used to build a state programatically

Parameters
nameName of the new state provided by this configuration
baseName of the state upon which this state should be based
configNew parameters' values

◆ load_files()

void mc_control::fsm::StateFactory::load_files ( const std::vector< std::string > &  files)

Load more states files

◆ load_libraries()

void mc_control::fsm::StateFactory::load_libraries ( const std::vector< std::string > &  paths)

Load more states libraries

◆ load_with_loader()

bool mc_control::fsm::StateFactory::load_with_loader ( const std::string &  state)

Load state using a loader state, returns true if a state was loaded

◆ register_object()

template<typename RetT , typename... Args>
void mc_control::fsm::StateFactory::register_object ( const std::string &  name,
std::function< RetT *(const Args &...)>  callback 
)
inline

Register a new loading function

Parameters
nameName that will be used to create new instance
callbackCallback that will be used to create the object
Template Parameters
RetTMust be derived from T
Exceptions
LoaderExceptionif the object is already registered

◆ states()

const std::vector<std::string>& mc_control::fsm::StateFactory::states ( ) const

Returns the list of loaded states


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