PluginLoader.h++
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 #ifndef __ccxx_PluginLoader_hxx
00024 #define __ccxx_PluginLoader_hxx
00025
00026 #include <commonc++/LoadableModule.h++>
00027
00028 namespace ccxx {
00029
00030 class COMMONCPP_API Plugin;
00031
00038 class COMMONCPP_API PluginLoader
00039 {
00040 public:
00041
00047 PluginLoader(const String& path = String::null);
00048
00050 ~PluginLoader();
00051
00055 inline void setPath(const String& path)
00056 { _module.setPath(path); }
00057
00059 inline String getPath() const
00060 { return(_module.getPath()); }
00061
00068 void load() throw(IOException)
00069 { _module.open(); }
00070
00074 inline void unload() throw()
00075 { _module.close(); }
00076
00078 inline bool isLoaded() const
00079 { return(_module.isOpen()); }
00080
00087 String getName();
00088
00095 String getVersion();
00096
00103 String getAuthor();
00104
00111 String getClassName();
00112
00119 String getBuildDate();
00120
00128 template<class T> T *newInstance()
00129 {
00130 Plugin *p;
00131 try
00132 {
00133 p = _newInstance();
00134 }
00135 catch(...) { }
00136
00137 if(! p)
00138 return(NULL);
00139
00140 T* plugin = NULL;
00141 plugin = dynamic_cast<T *>(p);
00142 if(! plugin)
00143 delete p;
00144
00145 return plugin;
00146 }
00147
00148 private:
00149
00150 String _fetchString(const char *symbol);
00151 Plugin *_newInstance();
00152
00153 LoadableModule _module;
00154
00155 CCXX_COPY_DECLS(PluginLoader);
00156 };
00157
00158 }
00159
00160 #endif // __ccxx_PluginLoader_hxx
00161
00162