PluginLoader.hpp

00001 #ifndef ORO_OS_PLUGINLOADER_HPP_
00002 #define ORO_OS_PLUGINLOADER_HPP_
00003 
00004 #include <string>
00005 #include <vector>
00006 #include <boost/shared_ptr.hpp>
00007 
00008 #include "../rtt-config.h"
00009 #include "../TaskContext.hpp"
00010 
00011 namespace RTT {
00012     namespace OS {
00027         class RTT_API PluginLoader
00028         {
00029             static boost::shared_ptr<PluginLoader> minstance;
00030 
00035             class LoadedLib{
00036             public:
00037                 LoadedLib(std::string n, std::string short_name, void* h)
00038                 : filename(n), shortname(short_name), handle(h), loadPlugin(0), is_typekit(0)
00039                 {
00040                 }
00044                 std::string filename;
00048                 std::string shortname;
00052                 std::string plugname;
00053                 void* handle;
00054                 bool (*loadPlugin)(RTT::TaskContext*);
00055                 bool is_typekit;
00056             };
00057 
00058             std::vector< LoadedLib > loadedLibs;
00059 
00063             std::string plugin_path;
00064 
00074             bool loadInProcess(std::string filename, std::string shortname, std::string kind, bool log_error );
00083             bool loadPluginInternal( std::string const& name, std::string const& path_list, std::string const& subdir, std::string const& kind );
00091             void loadPluginsInternal( std::string const& path_list, std::string const& subdir, std::string const& kind );
00092         public:
00093             typedef boost::shared_ptr<PluginLoader> shared_ptr;
00099             static boost::shared_ptr<PluginLoader> Instance();
00100 
00105             static void Release();
00106 
00114             void loadTypekits(std::string const& path_list);
00115 
00121             bool loadTypekit(std::string const& name, std::string const& path_list);
00122 
00130             void loadPlugins(std::string const& path_list);
00131 
00139             bool isLoaded(std::string name);
00140 
00147             bool loadPlugin(std::string const& name, std::string const& path_list);
00148 
00153             std::vector<std::string> listPlugins() const;
00154 
00159             std::vector<std::string> listTypekits() const;
00160 
00167             std::string getPluginPath() const;
00168 
00175             void setPluginPath( std::string const& newpath );
00176         };
00177     }
00178 }
00179 
00180 
00181 #endif /* ORO_PLUGINLOADER_HPP_ */
Generated on Thu Dec 23 13:22:38 2010 for Orocos Real-Time Toolkit by  doxygen 1.6.3