Orocos Real-Time Toolkit  2.8.3
Public Types | Public Member Functions | Static Public Member Functions | List of all members
RTT::ComponentLoader Class Reference

#include <rtt/deployment/ComponentLoader.hpp>

Public Types

typedef boost::shared_ptr< ComponentLoadershared_ptr
 

Public Member Functions

bool import (std::string const &path_list)
 Imports any Component library found in each path in path_list in the current process. More...
 
bool isImported (std::string type_name)
 Checks if a given Component type, filename or package name has been imported. More...
 
bool import (std::string const &name, std::string const &path_list)
 Imports a package found in each path in path_list in the current process. More...
 
bool loadLibrary (std::string const &path)
 Loads a library as component library. More...
 
bool reloadLibrary (std::string const &filepath)
 Reloads a component library. More...
 
RTT::TaskContextloadComponent (std::string const &name, std::string const &type)
 Creates a new component an earlier discovered component type. More...
 
bool unloadComponent (RTT::TaskContext *tc)
 Destroys an earlier created component. More...
 
std::vector< std::string > listComponents () const
 Lists all Component created by loadComponent(). More...
 
std::vector< std::string > listComponentTypes () const
 Lists all Component types discovered by the ComponentLoader. More...
 
std::string getComponentPath () const
 Returns the current Component path list. More...
 
void setComponentPath (std::string const &newpath)
 Sets the Component path list. More...
 
const FactoryMapgetFactories () const
 Returns the factory singleton which creates all types of components for the ComponentLoader. More...
 
void addFactory (std::string const &name, ComponentLoaderSignature factory)
 Adds a factory to the component factory map. More...
 

Static Public Member Functions

static boost::shared_ptr< ComponentLoaderInstance ()
 Create the instance of the ComponentLoader. More...
 
static void Release ()
 Release the ComponentLoader, erasing all knowledge of loaded libraries. More...
 

Detailed Description

Definition at line 22 of file ComponentLoader.hpp.

Member Typedef Documentation

Definition at line 111 of file ComponentLoader.hpp.

Member Function Documentation

void ComponentLoader::addFactory ( std::string const &  name,
ComponentLoaderSignature  factory 
)

Adds a factory to the component factory map.

Definition at line 827 of file ComponentLoader.cpp.

References RTT::ComponentFactories::Instance().

std::string ComponentLoader::getComponentPath ( ) const

Returns the current Component path list.

Defaults to the value of RTT_COMPONENT_PATH, when the RTT was started for the current process.

Returns
A colon separated list of paths or the empty string if not set.

Definition at line 718 of file ComponentLoader.cpp.

const FactoryMap & ComponentLoader::getFactories ( ) const

Returns the factory singleton which creates all types of components for the ComponentLoader.

Definition at line 822 of file ComponentLoader.cpp.

References RTT::ComponentFactories::Instance().

bool ComponentLoader::import ( std::string const &  path_list)

Imports any Component library found in each path in path_list in the current process.

Parameters
path_listA colon or semi-colon seperated list of paths to look for Components. May be the empty string.
Returns
true if all paths were valid and contained components. If at least one path did not exist or did not contain any components or plugins, returns false.

Definition at line 288 of file ComponentLoader.cpp.

References RTT::Debug, RTT::Error, RTT::Info, RTT::plugin::PluginLoader::Instance(), isLoadableLibrary(), and OROCOS_TARGET_NAME.

bool ComponentLoader::import ( std::string const &  name,
std::string const &  path_list 
)

Imports a package found in each path in path_list in the current process.

Parameters
nameThe name of the (package) directory to import
path_listA colon or semi-colon seperated list of paths to look for Components. May be the empty string. In that case, the default component search path is used.

Definition at line 391 of file ComponentLoader.cpp.

References RTT::Error, RTT::Info, isLoadableLibrary(), and OROCOS_TARGET_NAME.

boost::shared_ptr< ComponentLoader > ComponentLoader::Instance ( )
static

Create the instance of the ComponentLoader.

It will keep track of the loaded libraries for this process.

Returns
A singleton.

Definition at line 276 of file ComponentLoader.cpp.

bool ComponentLoader::isImported ( std::string  type_name)

Checks if a given Component type, filename or package name has been imported.

This function accepts full filenames ('libthe_Component.so.1.99.0'), short names ('the_Component'), the name provided by the Component Factory ('App::Component'), or a package name ('myrobot')

Parameters
type_namename of a file, package directory or the Component type.
Returns
true if so.

Definition at line 565 of file ComponentLoader.cpp.

References RTT::Debug, dlclose(), dlerror(), dlopen(), dlsym(), RTT::Error, RTT::types::TypekitRepository::hasTypekit(), RTT::Info, RTT::ComponentFactories::Instance(), RTLD_NOW, and RTT::Warning.

std::vector< std::string > ComponentLoader::listComponents ( ) const

Lists all Component created by loadComponent().

Returns
A list of Component names

Definition at line 784 of file ComponentLoader.cpp.

std::vector< std::string > ComponentLoader::listComponentTypes ( ) const

Lists all Component types discovered by the ComponentLoader.

Returns
A list of Component type names

Definition at line 709 of file ComponentLoader.cpp.

References RTT::ComponentFactories::Instance().

RTT::TaskContext * ComponentLoader::loadComponent ( std::string const &  name,
std::string const &  type 
)

Creates a new component an earlier discovered component type.

Parameters
nameThe name of the to be created Component
typeThe type of component to be created.
Returns
null on error or a new component.

Definition at line 731 of file ComponentLoader.cpp.

References RTT::Debug, RTT::Error, and RTT::ComponentFactories::Instance().

bool ComponentLoader::loadLibrary ( std::string const &  path)

Loads a library as component library.

Parameters
pathan absolute or relative path to a library. Relative paths are interpreted with regard to the plugin path.

Definition at line 515 of file ComponentLoader.cpp.

References RTT::Debug, and OROCOS_TARGET_NAME.

void ComponentLoader::Release ( )
static

Release the ComponentLoader, erasing all knowledge of loaded libraries.

No libraries will be unloaded from the process.

Definition at line 282 of file ComponentLoader.cpp.

bool ComponentLoader::reloadLibrary ( std::string const &  filepath)

Reloads a component library.

Parameters
filepathan absolute path to a library.

Definition at line 501 of file ComponentLoader.cpp.

void ComponentLoader::setComponentPath ( std::string const &  newpath)

Sets the Component path list.

This is typically done by RTT startup code with the contents of the RTT_COMPONENT_PATH variable.

Parameters
newpathThe new paths to look for Components.

Definition at line 726 of file ComponentLoader.cpp.

bool ComponentLoader::unloadComponent ( RTT::TaskContext tc)

Destroys an earlier created component.

Parameters
tcThe TaskContext to be destroyed. tc may no longer be used after this function returns true.
Returns
false if tc was not loaded by this ComponentLoader.

Definition at line 767 of file ComponentLoader.cpp.

References RTT::Error.


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