Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages
plugin.h
Go to the documentation of this file.00001 /* 00002 Copyright (C) 2001 by Jorrit Tyberghein 00003 Copyright (C) 1999 by Andrew Zabolotny <bit@eltech.ru> 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public 00016 License along with this library; if not, write to the Free 00017 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00018 */ 00019 00020 #ifndef __CS_IUTIL_PLUGIN_H__ 00021 #define __CS_IUTIL_PLUGIN_H__ 00022 00031 #include "csutil/scf.h" 00032 #include "csutil/ref.h" 00033 #include "iutil/objreg.h" 00034 #include "ivaria/reporter.h" 00035 00036 struct iComponent; 00037 00046 #define CS_QUERY_PLUGIN_CLASS(Object,ClassID,Interface) \ 00047 csPtr<Interface> ((Interface *)((Object)->QueryPlugin \ 00048 (ClassID, #Interface, scfInterface<Interface>::GetVersion()))) 00049 00056 #define CS_LOAD_PLUGIN(Object,ClassID,Interface) \ 00057 csPtr<Interface> ((Interface *)((Object)->LoadPlugin \ 00058 (ClassID, #Interface, scfInterface<Interface>::GetVersion()))) 00059 00064 #define CS_LOAD_PLUGIN_ALWAYS(Object,ClassID) \ 00065 csPtr<iBase> ((Object)->LoadPlugin (ClassID, 0, 0)) 00066 00090 #define CS_QUERY_REGISTRY_PLUGIN(obj,object_reg,scf_id,interface) \ 00091 do { \ 00092 obj = CS_QUERY_REGISTRY(object_reg, interface); \ 00093 if (!obj.IsValid()) \ 00094 { \ 00095 csRef<iPluginManager> mgr = CS_QUERY_REGISTRY(object_reg,iPluginManager); \ 00096 if (!mgr.IsValid()) \ 00097 { \ 00098 csReport(object_reg, CS_REPORTER_SEVERITY_ERROR, \ 00099 "crystalspace.plugin.query", "Plugin manager missing from " \ 00100 "object-registry when attempting to query/load class: %s", scf_id); \ 00101 } \ 00102 obj = CS_LOAD_PLUGIN(mgr, scf_id, interface); \ 00103 if (!obj.IsValid()) \ 00104 { \ 00105 csReport(object_reg, CS_REPORTER_SEVERITY_WARNING, \ 00106 "crystalspace.plugin.query", "Failed to load class \"%s\" with " \ 00107 "interface \"" #interface "\"", scf_id); \ 00108 } \ 00109 if (!object_reg->Register(obj, #interface)) \ 00110 { \ 00111 csReport(object_reg, CS_REPORTER_SEVERITY_WARNING, \ 00112 "crystalspace.plugin.query", "Failed to register class \"%s\" with " \ 00113 "tag \"" #interface "\" in the object-registry.", scf_id); \ 00114 } \ 00115 } \ 00116 } while (0) 00117 00118 SCF_VERSION (iPluginIterator, 0, 0, 1); 00119 00123 struct iPluginIterator : public iBase 00124 { 00126 virtual bool HasNext () = 0; 00128 virtual iBase* Next () = 0; 00129 }; 00130 00131 SCF_VERSION (iPluginManager, 0, 2, 0); 00132 00147 struct iPluginManager : public iBase 00148 { 00154 virtual iBase *LoadPlugin (const char *classID, 00155 const char *iInterface = 0, int iVersion = 0, bool init = true) = 0; 00156 00164 virtual iBase *QueryPlugin (const char *iInterface, int iVersion) = 0; 00166 virtual iBase *QueryPlugin (const char* classID, 00167 const char *iInterface, int iVersion) = 0; 00169 virtual bool UnloadPlugin (iComponent *obj) = 0; 00171 virtual bool RegisterPlugin (const char *classID, iComponent *obj) = 0; 00172 00178 virtual csPtr<iPluginIterator> GetPlugins () = 0; 00180 virtual void Clear () = 0; 00181 00188 virtual void QueryOptions (iComponent* object) = 0; 00189 }; 00190 00193 #endif // __CS_IUTIL_PLUGIN_H__
Generated for Crystal Space by doxygen 1.3.9.1