Orocos Real-Time Toolkit
2.6.0
|
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 importRosPackage(std::string const& package); 00110 00114 bool importInstalledPackage(std::string const& package, std::string const& path_list); 00115 public: 00116 typedef boost::shared_ptr<ComponentLoader> shared_ptr; 00122 static boost::shared_ptr<ComponentLoader> Instance(); 00123 00128 static void Release(); 00129 00137 bool import(std::string const& path_list); 00138 00148 bool isImported(std::string type_name); 00149 00157 bool import(std::string const& name, std::string const& path_list); 00158 00164 bool loadLibrary(std::string const& path); 00165 00170 bool reloadLibrary(std::string const& filepath); 00171 00178 RTT::TaskContext* loadComponent(std::string const& name, std::string const& type); 00179 00186 bool unloadComponent( RTT::TaskContext* tc ); 00187 00192 std::vector<std::string> listComponents() const; 00193 00198 std::vector<std::string> listComponentTypes() const; 00199 00206 std::string getComponentPath() const; 00207 00214 void setComponentPath( std::string const& newpath ); 00215 00220 const FactoryMap& getFactories() const; 00221 00225 void addFactory( std::string const& name, ComponentLoaderSignature factory ); 00226 }; 00227 } 00228 00229 00230 #endif /* ORO_COMPONENTLOADER_HPP_ */