core/interfaces/IExtensionSys.h
changeset 324 e23aca731e37
parent 323 e12c1cd285e2
child 325 66fa86233688
     1.1 --- a/core/interfaces/IExtensionSys.h	Fri Jan 19 05:25:43 2007 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,217 +0,0 @@
     1.4 -#ifndef _INCLUDE_SOURCEMOD_MODULE_INTERFACE_H_
     1.5 -#define _INCLUDE_SOURCEMOD_MODULE_INTERFACE_H_
     1.6 -
     1.7 -#include <IShareSys.h>
     1.8 -#include <ILibrarySys.h>
     1.9 -
    1.10 -namespace SourceMod
    1.11 -{
    1.12 -	class IExtensionInterface;
    1.13 -	typedef void *		ITERATOR;
    1.14 -
    1.15 -	/** 
    1.16 -	 * @brief Encapsulates an IExtension.
    1.17 -	 */
    1.18 -	class IExtension
    1.19 -	{
    1.20 -	public:
    1.21 -		/**
    1.22 -		 * @brief Returns whether or not the extension is properly loaded.
    1.23 -		 */
    1.24 -		virtual bool IsLoaded() =0;
    1.25 -
    1.26 -		/**
    1.27 -		 * @brief Returns the extension's API interface
    1.28 -		 *
    1.29 -		 * @return			An IExtensionInterface pointer.
    1.30 -		 */
    1.31 -		virtual IExtensionInterface *GetAPI() =0;
    1.32 -
    1.33 -		/**
    1.34 -		 * @brief Returns the filename of the extension, relative to the
    1.35 -		 * extension folder.
    1.36 -		 *
    1.37 -		 * @return			A string containing the extension file name.
    1.38 -		 */
    1.39 -		virtual const char *GetFilename() =0;
    1.40 -
    1.41 -		/**
    1.42 -		 * @brief Returns the extension's identity token.
    1.43 -		 *
    1.44 -		 * @return			An IdentityToken_t pointer.
    1.45 -		 */
    1.46 -		virtual IdentityToken_t *GetIdentity() =0;
    1.47 -
    1.48 -		/**
    1.49 -		 * @brief Retrieves the extension dependency list for this extension.
    1.50 -		 *
    1.51 -		 * @param pOwner		Optional pointer to store the first interface's owner.
    1.52 -		 * @param pInterface	Optional pointer to store the first interface.
    1.53 -		 * @return				An ITERATOR pointer for the results, or NULL if no results at all.
    1.54 -		 */
    1.55 -		virtual ITERATOR *FindFirstDependency(IExtension **pOwner, SMInterface **pInterface) =0;
    1.56 -
    1.57 -		/**
    1.58 -		 * @brief Finds the next dependency in the dependency list.
    1.59 -		 *
    1.60 -		 * @param iter			Pointer to iterator from FindFirstDependency.
    1.61 -		 * @param pOwner		Optional pointer to store the interface's owner.
    1.62 -		 * @param pInterface	Optional pointer to store the interface.
    1.63 -		 * @return				True if there are more results after this, false otherwise.
    1.64 -		 */
    1.65 -		virtual bool FindNextDependency(ITERATOR *iter, IExtension **pOwner, SMInterface **pInterface) =0;
    1.66 -
    1.67 -		/**
    1.68 -		 * @brief Frees an ITERATOR handle from FindFirstDependency.
    1.69 -		 *
    1.70 -		 * @param iter			Pointer to iterator to free.
    1.71 -		 */
    1.72 -		virtual void FreeDependencyIterator(ITERATOR *iter) =0;
    1.73 -
    1.74 -		/**
    1.75 -		 * @brief Queries the extension to see its run state.
    1.76 -		 *
    1.77 -		 * @param error			Error buffer (may be NULL).
    1.78 -		 * @param maxlength		Maximum length of buffer.
    1.79 -		 * @return				True if extension is okay, false if not okay.
    1.80 -		 */
    1.81 -		virtual bool IsRunning(char *error, size_t maxlength) =0;
    1.82 -	};
    1.83 -
    1.84 -	#define SMINTERFACE_EXTENSIONAPI_VERSION	1
    1.85 -
    1.86 -	/**
    1.87 -	 * @brief The interface an extension must expose.
    1.88 -	 */
    1.89 -	class IExtensionInterface
    1.90 -	{
    1.91 -	public:
    1.92 -		virtual unsigned int GetExtensionVersion()
    1.93 -		{
    1.94 -			return SMINTERFACE_EXTENSIONAPI_VERSION;
    1.95 -		}
    1.96 -	public:
    1.97 -		/**
    1.98 -		 * @brief Called when the extension is loaded.
    1.99 -		 * 
   1.100 -		 * @param me		Pointer back to extension.
   1.101 -		 * @param sys		Pointer to interface sharing system of SourceMod.
   1.102 -		 * @param error		Error buffer to print back to, if any.
   1.103 -		 * @param err_max	Maximum size of error buffer.
   1.104 -		 * @param late		If this extension was loaded "late" (i.e. manually).
   1.105 -		 * @return			True if load should continue, false otherwise.
   1.106 -		 */
   1.107 -		virtual bool OnExtensionLoad(IExtension *me,
   1.108 -								  IShareSys *sys, 
   1.109 -								  char *error, 
   1.110 -								  size_t err_max, 
   1.111 -								  bool late) =0;
   1.112 -
   1.113 -		/**
   1.114 -		 * @brief Called when the extension is about to be unloaded.
   1.115 -		 */
   1.116 -		virtual void OnExtensionUnload() =0;
   1.117 -
   1.118 -		/**
   1.119 -		 * @brief Called when all extensions are loaded (loading cycle is done).
   1.120 -		 * If loaded late, this will be called right after OnExtensionLoad().
   1.121 -		 */
   1.122 -		virtual void OnExtensionsAllLoaded() =0;
   1.123 -
   1.124 -		/**
   1.125 -		 * @brief Called when your pause state is about to change.
   1.126 -		 * 
   1.127 -		 * @param pause		True if pausing, false if unpausing.
   1.128 -		 */
   1.129 -		virtual void OnExtensionPauseChange(bool pause) =0;
   1.130 -
   1.131 -		/**
   1.132 -		 * @brief Asks the extension whether it's safe to remove an external interface it's using.
   1.133 -		 * If it's not safe, return false, and the extension will be unloaded afterwards.
   1.134 -		 * NOTE: It is important to also hook NotifyInterfaceDrop() in order to clean up resources.
   1.135 -		 *
   1.136 -		 * @param pInterface		Pointer to interface being dropped.
   1.137 -		 * @return					True to continue, false to unload this extension afterwards.
   1.138 -		 */
   1.139 -		virtual bool QueryInterfaceDrop(SMInterface *pInterface)
   1.140 -		{
   1.141 -			return true;
   1.142 -		}
   1.143 -
   1.144 -		/**
   1.145 -		 * @brief Notifies the extension that an external interface it uses is being removed.
   1.146 -		 *
   1.147 -		 * @param pInterface		Pointer to interface being dropped.
   1.148 -		 */
   1.149 -		virtual void NotifyInterfaceDrop(SMInterface *pInterface)
   1.150 -		{
   1.151 -		}
   1.152 -
   1.153 -		/**
   1.154 -		 * @brief Return false to tell Core that your extension should be considered unsable.
   1.155 -		 *
   1.156 -		 * @param error				Error buffer.
   1.157 -		 * @param maxlength			Size of error buffer.
   1.158 -		 * @return					True on success, false otherwise.
   1.159 -		 */
   1.160 -		virtual bool QueryRunning(char *error, size_t maxlength)
   1.161 -		{
   1.162 -			return true;
   1.163 -		}
   1.164 -	public:
   1.165 -		virtual bool IsMetamodExtension() =0;
   1.166 -		virtual const char *GetExtensionName() =0;
   1.167 -		virtual const char *GetExtensionURL() =0;
   1.168 -		virtual const char *GetExtensionTag() =0;
   1.169 -		virtual const char *GetExtensionAuthor() =0;
   1.170 -		virtual const char *GetExtensionVerString() =0;
   1.171 -		virtual const char *GetExtensionDescription() =0;
   1.172 -		virtual const char *GetExtensionDateString() =0;
   1.173 -	};
   1.174 -
   1.175 -	#define SMINTERFACE_EXTENSIONMANAGER_NAME			"IExtensionManager"
   1.176 -	#define SMINTERFACE_EXTENSIONMANAGER_VERSION		1
   1.177 -
   1.178 -	enum ExtensionLifetime
   1.179 -	{
   1.180 -		ExtLifetime_Forever,			//Extension will never be unloaded automatically
   1.181 -		ExtLifetime_Map,				//Extension will be unloaded at the end of the map
   1.182 -	};
   1.183 -
   1.184 -	class IExtensionManager : public SMInterface
   1.185 -	{
   1.186 -	public:
   1.187 -		virtual const char *GetInterfaceName()
   1.188 -		{
   1.189 -			return SMINTERFACE_EXTENSIONMANAGER_NAME;
   1.190 -		}
   1.191 -		virtual unsigned int GetInterfaceVersion()
   1.192 -		{
   1.193 -			return SMINTERFACE_EXTENSIONMANAGER_VERSION;
   1.194 -		}
   1.195 -	public:
   1.196 -		/**
   1.197 -		 * @brief Loads a extension into the extension system.
   1.198 -		 *
   1.199 -		 * @param path		Path to extension file, relative to the extensions folder.
   1.200 -		 * @param lifetime	Lifetime of the extension.
   1.201 -		 * @param error		Error buffer.
   1.202 -		 * @param err_max	Maximum error buffer length.
   1.203 -		 * @return			New IExtension on success, NULL on failure.
   1.204 -		 */
   1.205 -		virtual IExtension *LoadExtension(const char *path, 
   1.206 -									ExtensionLifetime lifetime, 
   1.207 -									char *error,
   1.208 -									size_t err_max) =0;
   1.209 -
   1.210 -		/**
   1.211 -		 * @brief Attempts to unload a module.
   1.212 -		 *
   1.213 -		 * @param pExt		IExtension pointer.
   1.214 -		 * @return			True if successful, false otherwise.
   1.215 -		 */
   1.216 -		virtual bool UnloadExtension(IExtension *pExt) =0;
   1.217 -	};
   1.218 -};
   1.219 -
   1.220 -#endif //_INCLUDE_SOURCEMOD_MODULE_INTERFACE_H_