Classes | Public Types | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
RTT::ComponentLoader Class Reference

#include <ComponentLoader.hpp>

Classes

struct  ComponentData
 
class  LoadedLib
 

Public Types

typedef boost::shared_ptr< ComponentLoadershared_ptr
 

Public Member Functions

void addFactory (std::string const &name, ComponentLoaderSignature factory)
 
std::string getComponentPath () const
 
const FactoryMapgetFactories () const
 
bool import (std::string const &path_list)
 
bool import (std::string const &name, std::string const &path_list)
 
bool isImported (std::string type_name)
 
std::vector< std::string > listComponents () const
 
std::vector< std::string > listComponentTypes () const
 
RTT::TaskContextloadComponent (std::string const &name, std::string const &type)
 
bool loadLibrary (std::string const &path)
 
bool reloadLibrary (std::string const &filepath)
 
void setComponentPath (std::string const &newpath)
 
bool unloadComponent (RTT::TaskContext *tc)
 

Static Public Member Functions

static boost::shared_ptr< ComponentLoaderInstance ()
 
static void Release ()
 

Private Types

typedef std::map< std::string, ComponentDataCompList
 

Private Member Functions

bool importInstalledPackage (std::string const &package, std::string const &path_list)
 
bool isCompatibleComponent (std::string const &filepath)
 
bool loadInProcess (std::string filename, std::string shortname, bool log_error)
 
bool reloadInProcess (std::string filename, std::string shortname)
 

Private Attributes

std::string component_path
 
CompList comps
 
std::vector< LoadedLibloadedLibs
 
std::vector< std::string > loadedPackages
 

Detailed Description

Definition at line 60 of file ComponentLoader.hpp.

Member Typedef Documentation

typedef std::map<std::string, ComponentData> RTT::ComponentLoader::CompList
private

This vector holds the dynamically loaded components.

Definition at line 103 of file ComponentLoader.hpp.

Definition at line 149 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 823 of file ComponentLoader.cpp.

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 714 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 818 of file ComponentLoader.cpp.

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 317 of file ComponentLoader.cpp.

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 387 of file ComponentLoader.cpp.

bool ComponentLoader::importInstalledPackage ( std::string const &  package,
std::string const &  path_list 
)
private

Returns true if package is a subdir of the RTT_COMPONENT_PATH

Definition at line 425 of file ComponentLoader.cpp.

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 305 of file ComponentLoader.cpp.

bool ComponentLoader::isCompatibleComponent ( std::string const &  filepath)
private

Internal helper function that validate if a component is compatible with the current target. Currently, there's a validation only on the win32 platform to avoid mixing debug/release runtime libraries.

Parameters
filepathFull path of component to validate (with extension).
Returns
true if the component is compatible

Definition at line 788 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 561 of file ComponentLoader.cpp.

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

Lists all Component created by loadComponent().

Returns
A list of Component names

Definition at line 780 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 705 of file ComponentLoader.cpp.

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 727 of file ComponentLoader.cpp.

bool ComponentLoader::loadInProcess ( std::string  filename,
std::string  shortname,
bool  log_error 
)
private

Internal function that does all library loading.

Parameters
filenameThe path+filename to open
shortnameThe short name of this file
log_errorLog errors to users. Set to false in case you are poking files to see if they can be loaded.
Returns
true if a new library was loaded or if this library was already loaded.

Definition at line 618 of file ComponentLoader.cpp.

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 511 of file ComponentLoader.cpp.

void ComponentLoader::Release ( )
static

Release the ComponentLoader, erasing all knowledge of loaded libraries. No libraries will be unloaded from the process.

Definition at line 311 of file ComponentLoader.cpp.

bool ComponentLoader::reloadInProcess ( std::string  filename,
std::string  shortname 
)
private

Internal function that does try to reload a previously loaded library by first dl_close'ing the library.

Parameters
filenameThe path+filename to open
shortnameThe short name of this file
Returns
true if this library was reloaded.

Definition at line 575 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 497 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 722 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 763 of file ComponentLoader.cpp.

Member Data Documentation

std::string RTT::ComponentLoader::component_path
private

Path to look for if all else fails.

Definition at line 115 of file ComponentLoader.hpp.

CompList RTT::ComponentLoader::comps
private

Definition at line 105 of file ComponentLoader.hpp.

std::vector< LoadedLib > RTT::ComponentLoader::loadedLibs
private

Definition at line 108 of file ComponentLoader.hpp.

std::vector< std::string > RTT::ComponentLoader::loadedPackages
private

Definition at line 110 of file ComponentLoader.hpp.


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


rtt
Author(s): RTT Developers
autogenerated on Fri Oct 25 2019 03:59:46