#include <ComponentLoader.hpp>
Classes | |
struct | ComponentData |
class | LoadedLib |
Public Types | |
typedef boost::shared_ptr < ComponentLoader > | shared_ptr |
Public Member Functions | |
std::string | getComponentPath () const |
bool | import (std::string const &name, std::string const &path_list) |
bool | import (std::string const &path_list) |
bool | isImported (std::string type_name) |
std::vector< std::string > | listComponents () const |
std::vector< std::string > | listComponentTypes () const |
RTT::TaskContext * | loadComponent (std::string const &name, std::string const &type) |
bool | loadLibrary (std::string const &path) |
void | setComponentPath (std::string const &newpath) |
bool | unloadComponent (RTT::TaskContext *tc) |
Static Public Member Functions | |
static boost::shared_ptr < ComponentLoader > | Instance () |
static void | Release () |
Private Types | |
typedef std::map< std::string, ComponentData > | CompList |
Private Member Functions | |
bool | isCompatibleComponent (std::string const &filepath) |
bool | loadInProcess (std::string filename, std::string shortname, bool log_error) |
Private Attributes | |
std::string | component_path |
CompList | comps |
std::vector< LoadedLib > | loadedLibs |
std::vector< string > | loadedPackages |
Static Private Attributes | |
static boost::shared_ptr < ComponentLoader > | minstance |
Definition at line 21 of file ComponentLoader.hpp.
typedef std::map<std::string, ComponentData> OCL::ComponentLoader::CompList [private] |
This vector holds the dynamically loaded components.
Definition at line 66 of file ComponentLoader.hpp.
typedef boost::shared_ptr<ComponentLoader> OCL::ComponentLoader::shared_ptr |
Definition at line 99 of file ComponentLoader.hpp.
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.
Definition at line 601 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.
name | The name of the (package) directory to import | |
path_list | A 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 231 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.
path_list | A colon or semi-colon seperated list of paths to look for Components. May be the empty string. |
Definition at line 132 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.
Definition at line 120 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.
filepath | Full path of component to validate (with extension). |
Definition at line 673 of file ComponentLoader.cpp.
bool OCL::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 ('AppComponent'), or a package name ('myrobot')
type_name | name of a file, package directory or the Component type. |
std::vector< std::string > ComponentLoader::listComponents | ( | ) | const |
Lists all Component created by loadComponent().
Definition at line 665 of file ComponentLoader.cpp.
std::vector< std::string > ComponentLoader::listComponentTypes | ( | ) | const |
Lists all Component types discovered by the ComponentLoader.
Definition at line 592 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.
name | The name of the to be created Component | |
type | The type of component to be created. |
Definition at line 614 of file ComponentLoader.cpp.
bool OCL::ComponentLoader::loadInProcess | ( | std::string | filename, | |
std::string | shortname, | |||
bool | log_error | |||
) | [private] |
Internal function that does all library loading.
filename | The path+filename to open | |
shortname | The short name of this file | |
log_error | Log errors to users. Set to false in case you are poking files to see if they can be loaded. |
bool ComponentLoader::loadLibrary | ( | std::string const & | path | ) |
Loads a library as component library.
path | an absolute or relative path to a library. Relative paths are interpreted with regard to the plugin path. |
Definition at line 405 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 126 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.
newpath | The new paths to look for Components. |
Definition at line 609 of file ComponentLoader.cpp.
bool ComponentLoader::unloadComponent | ( | RTT::TaskContext * | tc | ) |
Destroys an earlier created component.
tc | The TaskContext to be destroyed. tc may no longer be used after this function returns true. |
Definition at line 650 of file ComponentLoader.cpp.
std::string OCL::ComponentLoader::component_path [private] |
Path to look for if all else fails.
Definition at line 78 of file ComponentLoader.hpp.
CompList OCL::ComponentLoader::comps [private] |
Definition at line 68 of file ComponentLoader.hpp.
std::vector< LoadedLib > OCL::ComponentLoader::loadedLibs [private] |
Definition at line 71 of file ComponentLoader.hpp.
std::vector< string > OCL::ComponentLoader::loadedPackages [private] |
Definition at line 73 of file ComponentLoader.hpp.
boost::shared_ptr< ComponentLoader > ComponentLoader::minstance [static, private] |
Definition at line 23 of file ComponentLoader.hpp.