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 {
00009 namespace deployment {
00022 class ComponentLoader
00023 {
00024 static boost::shared_ptr<ComponentLoader> minstance;
00025
00030 class LoadedLib{
00031 public:
00032 LoadedLib(std::string n, std::string short_name, void* h)
00033 : filename(n), shortname(short_name), handle(h)
00034 {
00035 }
00039 std::string filename;
00043 std::string shortname;
00044
00048 void* handle;
00049
00050 std::vector<std::string> components_type;
00051 };
00052
00053 struct ComponentData {
00054 ComponentData()
00055 : instance(0), type("")
00056 {}
00060 RTT::TaskContext* instance;
00061 std::string type;
00062 };
00063
00067 typedef std::map<std::string, ComponentData> CompList;
00068
00069 CompList comps;
00070
00071
00072 std::vector< LoadedLib > loadedLibs;
00073
00077 std::string component_path;
00078
00087 bool loadInProcess(std::string filename, std::string shortname, bool log_error );
00088 public:
00089 typedef boost::shared_ptr<ComponentLoader> shared_ptr;
00095 static boost::shared_ptr<ComponentLoader> Instance();
00096
00101 static void Release();
00102
00110 void import(std::string const& path_list);
00111
00119 bool isImported(std::string type_name);
00120
00127 bool import(std::string const& name, std::string const& path_list);
00128
00135 RTT::TaskContext* loadComponent(std::string const& name, std::string const& type);
00136
00143 bool unloadComponent( RTT::TaskContext* tc );
00144
00149 std::vector<std::string> listComponents() const;
00150
00155 std::vector<std::string> listComponentTypes() const;
00156
00163 std::string getComponentPath() const;
00164
00171 void setComponentPath( std::string const& newpath );
00172 };
00173 }
00174 }
00175
00176
00177 #endif