ComponentLoader.hpp
Go to the documentation of this file.
00001 #ifndef ORO_COMPONENTLOADER_HPP_
00002 #define ORO_COMPONENTLOADER_HPP_
00003 
00004 #include <string>
00005 #include <vector>
00006 #include <boost/shared_ptr.hpp>
00007 #include <rtt/Component.hpp>
00008 
00009 namespace RTT {
00022         class ComponentLoader
00023         {
00028             class LoadedLib{
00029             public:
00030                 LoadedLib(std::string n, std::string short_name, void* h)
00031                 : filename(n), shortname(short_name), handle(h)
00032                 {
00033                 }
00037                 std::string filename;
00041                 std::string shortname;
00042 
00046                 void* handle;
00047 
00048                 std::vector<std::string> components_type;
00049             };
00050 
00051             struct ComponentData {
00052                 ComponentData()
00053                     : instance(0), type("")
00054                 {}
00058                 RTT::TaskContext* instance;
00059                 std::string type;
00060             };
00061 
00065             typedef std::map<std::string, ComponentData> CompList;
00066 
00067             CompList comps;
00068 
00069 
00070             std::vector< LoadedLib > loadedLibs;
00071 
00072             std::vector< std::string > loadedPackages;
00073 
00077             std::string component_path;
00078 
00087             bool loadInProcess(std::string filename, std::string shortname, bool log_error );
00088 
00095             bool reloadInProcess(std::string filename, std::string shortname);
00096 
00104             bool isCompatibleComponent(std::string const& filepath);
00105 
00109             bool importInstalledPackage(std::string const& package, std::string const& path_list);
00110         public:
00111             typedef boost::shared_ptr<ComponentLoader> shared_ptr;
00117             static boost::shared_ptr<ComponentLoader> Instance();
00118 
00123             static void Release();
00124 
00132             bool import(std::string const& path_list);
00133 
00143             bool isImported(std::string type_name);
00144 
00152             bool import(std::string const& name, std::string const& path_list);
00153 
00159             bool loadLibrary(std::string const& path);
00160 
00165             bool reloadLibrary(std::string const& filepath);
00166 
00173             RTT::TaskContext* loadComponent(std::string const& name, std::string const& type);
00174 
00181             bool unloadComponent( RTT::TaskContext* tc );
00182 
00187             std::vector<std::string> listComponents() const;
00188 
00193             std::vector<std::string> listComponentTypes() const;
00194 
00201             std::string getComponentPath() const;
00202 
00209             void setComponentPath( std::string const& newpath );
00210 
00215             const FactoryMap& getFactories() const;
00216 
00220             void addFactory( std::string const& name, ComponentLoaderSignature factory );
00221         };
00222 }
00223 
00224 
00225 #endif /* ORO_COMPONENTLOADER_HPP_ */


rtt
Author(s): RTT Developers
autogenerated on Thu Jan 2 2014 11:35:19