00001 #ifndef ORO_COMPONENTLOADER_HPP_
00002 #define ORO_COMPONENTLOADER_HPP_
00003
00004 #include <string>
00005 #include <vector>
00006 #include <boost/shared_ptr.hpp>
00007
00008 namespace OCL {
00021 class ComponentLoader
00022 {
00023 static boost::shared_ptr<ComponentLoader> minstance;
00024
00029 class LoadedLib{
00030 public:
00031 LoadedLib(std::string n, std::string short_name, void* h)
00032 : filename(n), shortname(short_name), handle(h)
00033 {
00034 }
00038 std::string filename;
00042 std::string shortname;
00043
00047 void* handle;
00048
00049 std::vector<std::string> components_type;
00050 };
00051
00052 struct ComponentData {
00053 ComponentData()
00054 : instance(0), type("")
00055 {}
00059 RTT::TaskContext* instance;
00060 std::string type;
00061 };
00062
00066 typedef std::map<std::string, ComponentData> CompList;
00067
00068 CompList comps;
00069
00070
00071 std::vector< LoadedLib > loadedLibs;
00072
00073 std::vector< string > loadedPackages;
00074
00078 std::string component_path;
00079
00088 bool loadInProcess(std::string filename, std::string shortname, bool log_error );
00096 bool isCompatibleComponent(std::string const& filepath);
00097
00098 public:
00099 typedef boost::shared_ptr<ComponentLoader> shared_ptr;
00105 static boost::shared_ptr<ComponentLoader> Instance();
00106
00111 static void Release();
00112
00120 bool import(std::string const& path_list);
00121
00131 bool isImported(std::string type_name);
00132
00140 bool import(std::string const& name, std::string const& path_list);
00141
00147 bool loadLibrary(std::string const& path);
00148
00155 RTT::TaskContext* loadComponent(std::string const& name, std::string const& type);
00156
00163 bool unloadComponent( RTT::TaskContext* tc );
00164
00169 std::vector<std::string> listComponents() const;
00170
00175 std::vector<std::string> listComponentTypes() const;
00176
00183 std::string getComponentPath() const;
00184
00191 void setComponentPath( std::string const& newpath );
00192 };
00193 }
00194
00195
00196 #endif