Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #ifndef ORO_PLUGINLOADER_HPP_
00040 #define ORO_PLUGINLOADER_HPP_
00041
00042 #include <string>
00043 #include <vector>
00044 #include <boost/shared_ptr.hpp>
00045
00046 #include "../rtt-fwd.hpp"
00047 #include "../rtt-config.h"
00048 #include "../os/Mutex.hpp"
00049
00050 namespace RTT {
00051 namespace plugin {
00068 class RTT_API PluginLoader
00069 {
00074 class LoadedLib{
00075 public:
00076 LoadedLib(std::string n, std::string short_name, void* h)
00077 : filename(n), shortname(short_name), handle(h), loadPlugin(0), is_typekit(false), is_service(false)
00078 {
00079 }
00083 std::string filename;
00087 std::string shortname;
00091 std::string plugname;
00092 void* handle;
00093 bool (*loadPlugin)(RTT::TaskContext*);
00094 RTT::ServicePtr (*createService)(void);
00095 bool is_typekit, is_service;
00096 };
00097
00098 std::vector< LoadedLib > loadedLibs;
00099
00103 std::string plugin_path;
00104
00108 mutable os::MutexRecursive listlock;
00109
00119 bool loadInProcess(std::string filename, std::string shortname, std::string kind, bool log_error );
00129 bool loadPluginInternal( std::string const& name, std::string const& path_list, std::string const& subdir, std::string const& kind );
00138 bool loadPluginsInternal( std::string const& path_list, std::string const& subdir, std::string const& kind );
00143 bool isLoadedInternal(std::string name);
00151 bool isCompatiblePlugin(std::string const& filepath);
00152
00153 public:
00154 PluginLoader();
00155 ~PluginLoader();
00156
00157 typedef boost::shared_ptr<PluginLoader> shared_ptr;
00163 static boost::shared_ptr<PluginLoader> Instance();
00164
00169 static void Release();
00170
00176 bool loadLibrary(std::string const& path);
00177
00187 bool loadTypekits(std::string const& path_list);
00188
00197 bool loadTypekit(std::string const& name, std::string const& path_list);
00198
00206 bool loadPlugins(std::string const& path_list);
00207
00215 bool isLoaded(std::string name);
00216
00224 bool loadPlugin(std::string const& name, std::string const& path_list);
00225
00233 bool loadService(std::string const& servicename, TaskContext* tc);
00234
00239 std::vector<std::string> listServices() const;
00240
00245 std::vector<std::string> listPlugins() const;
00246
00251 std::vector<std::string> listTypekits() const;
00252
00259 std::string getPluginPath() const;
00260
00267 void setPluginPath( std::string const& newpath );
00268 };
00269 }
00270 }
00271
00272
00273 #endif