public/IShareSys.h
branchsourcemod-1.1.0
changeset 2283 03a67e41afbc
parent 1951 c7b4237fff50
child 2287 017a725c9d17
     1.1 --- a/public/IShareSys.h	Fri Mar 28 06:21:34 2008 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,229 +0,0 @@
     1.4 -/**
     1.5 - * vim: set ts=4 :
     1.6 - * =============================================================================
     1.7 - * SourceMod
     1.8 - * Copyright (C) 2004-2007 AlliedModders LLC.  All rights reserved.
     1.9 - * =============================================================================
    1.10 - *
    1.11 - * This program is free software; you can redistribute it and/or modify it under
    1.12 - * the terms of the GNU General Public License, version 3.0, as published by the
    1.13 - * Free Software Foundation.
    1.14 - * 
    1.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
    1.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    1.17 - * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
    1.18 - * details.
    1.19 - *
    1.20 - * You should have received a copy of the GNU General Public License along with
    1.21 - * this program.  If not, see <http://www.gnu.org/licenses/>.
    1.22 - *
    1.23 - * As a special exception, AlliedModders LLC gives you permission to link the
    1.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
    1.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
    1.26 - * by the Valve Corporation.  You must obey the GNU General Public License in
    1.27 - * all respects for all other code used.  Additionally, AlliedModders LLC grants
    1.28 - * this exception to all derivative works.  AlliedModders LLC defines further
    1.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
    1.30 - * or <http://www.sourcemod.net/license.php>.
    1.31 - *
    1.32 - * Version: $Id$
    1.33 - */
    1.34 -
    1.35 -#ifndef _INCLUDE_SOURCEMOD_IFACE_SHARE_SYS_H_
    1.36 -#define _INCLUDE_SOURCEMOD_IFACE_SHARE_SYS_H_
    1.37 -
    1.38 -/**
    1.39 - * @file IShareSys.h
    1.40 - * @brief Defines the Share System, responsible for shared resources and dependencies.
    1.41 - *
    1.42 - *  The Share System also manages the Identity_t data type, although this is internally
    1.43 - * implemented with the Handle System.
    1.44 - */
    1.45 -
    1.46 -#include <sp_vm_types.h>
    1.47 -
    1.48 -
    1.49 -namespace SourceMod
    1.50 -{
    1.51 -	class IExtension;
    1.52 -	struct IdentityToken_t;
    1.53 -
    1.54 -	/** Forward declaration from IHandleSys.h */
    1.55 -	typedef unsigned int		HandleType_t;
    1.56 -
    1.57 -	/** Forward declaration from IHandleSys.h */
    1.58 -	typedef HandleType_t		IdentityType_t;
    1.59 -
    1.60 -	/**
    1.61 -	 * @brief Defines the base functionality required by a shared interface.
    1.62 -	 */
    1.63 -	class SMInterface
    1.64 -	{
    1.65 -	public:
    1.66 -		/**
    1.67 -		 * @brief Must return an integer defining the interface's version.
    1.68 -		 */
    1.69 -		virtual unsigned int GetInterfaceVersion() =0;
    1.70 -
    1.71 -		/**
    1.72 -		 * @brief Must return a string defining the interface's unique name.
    1.73 -		 */
    1.74 -		virtual const char *GetInterfaceName() =0;
    1.75 -
    1.76 -		/**
    1.77 -		 * @brief Must return whether the requested version number is backwards compatible.
    1.78 -		 * Note: This can be overridden for breaking changes or custom versioning.
    1.79 -		 * 
    1.80 -		 * @param version		Version number to compare against.
    1.81 -		 * @return				True if compatible, false otherwise.
    1.82 -		 */
    1.83 -		virtual bool IsVersionCompatible(unsigned int version)
    1.84 -		{
    1.85 -			if (version > GetInterfaceVersion())
    1.86 -			{
    1.87 -				return false;
    1.88 -			}
    1.89 -
    1.90 -			return true;
    1.91 -		}
    1.92 -	};
    1.93 -
    1.94 -	/**
    1.95 -	 * @brief Tracks dependencies and fires dependency listeners.
    1.96 -	 */
    1.97 -	class IShareSys
    1.98 -	{
    1.99 -	public:
   1.100 -		/**
   1.101 -		 * @brief Adds an interface to the global interface system.
   1.102 -		 *
   1.103 -		 * @param myself		Object adding this interface, in order to track dependencies.
   1.104 -		 * @param iface			Interface pointer (must be unique).
   1.105 -		 * @return				True on success, false otherwise.
   1.106 -		 */
   1.107 -		virtual bool AddInterface(IExtension *myself, SMInterface *iface) =0;
   1.108 -
   1.109 -		/**
   1.110 -		 * @brief Requests an interface from the global interface system.
   1.111 -		 * If found, the interface's internal reference count will be increased.
   1.112 -		 *
   1.113 -		 * @param iface_name	Interface name.
   1.114 -		 * @param iface_vers	Interface version to attempt to match.
   1.115 -		 * @param myself		Object requesting this interface, in order to track dependencies.
   1.116 -		 * @param pIface		Pointer to store the return value in.
   1.117 -		 */
   1.118 -		virtual bool RequestInterface(const char *iface_name, 
   1.119 -										unsigned int iface_vers,
   1.120 -										IExtension *myself,
   1.121 -										SMInterface **pIface) =0;
   1.122 -
   1.123 -		/**
   1.124 -		 * @brief Adds a list of natives to the global native pool, to be 
   1.125 -		 * bound on plugin load.
   1.126 -		 *
   1.127 -		 * Adding natives does not bind them to any loaded plugins; the 
   1.128 -		 * plugins must be reloaded for new natives to take effect.  
   1.129 -		 * 
   1.130 -		 * @param myself		Identity token of parent object.
   1.131 -		 * @param natives		Array of natives to add.  The last entry in 
   1.132 -		 *						the array must be filled with NULLs to 
   1.133 -		 *						terminate the array.  The array must be static 
   1.134 -		 *						as Core will cache the pointer for the 
   1.135 -		 *						lifetime of the extension.
   1.136 -		 */
   1.137 -		virtual void AddNatives(IExtension *myself, const sp_nativeinfo_t *natives) =0;
   1.138 -
   1.139 -		/**
   1.140 -		 * @brief Creates a new identity type.
   1.141 -		 * NOTE: Module authors should never need to use this.  Due to the current implementation,
   1.142 -		 * there is a hardcoded limit of 15 types.  Core uses up a few, so think carefully!
   1.143 -		 *
   1.144 -		 * @param name			String containing type name.  Must not be empty or NULL.
   1.145 -		 * @return				A new HandleType_t identifier, or 0 on failure.
   1.146 -		 */
   1.147 -		virtual IdentityType_t CreateIdentType(const char *name) =0;
   1.148 -
   1.149 -		/**
   1.150 -		 * @brief Finds an identity type by name.
   1.151 -		 * DEFAULT IDENTITY TYPES:
   1.152 -		 *  "PLUGIN"	- An IPlugin object.
   1.153 -		 *  "MODULE"	- An IModule object.
   1.154 -		 *  "CORE"		- An SMGlobalClass or other singleton.
   1.155 -		 * 
   1.156 -		 * @param name			String containing type name to search for.
   1.157 -		 * @return				A HandleType_t identifier if found, 0 otherwise.
   1.158 -		 */
   1.159 -		virtual IdentityType_t FindIdentType(const char *name) =0;
   1.160 -
   1.161 -		/**
   1.162 -		 * @brief Creates a new identity token.  This token is guaranteed to be 
   1.163 -		 * unique amongst all other open identities.
   1.164 -		 *
   1.165 -		 * @param type			Identity type.
   1.166 -		 * @param ptr			Private data pointer (cannot be NULL).
   1.167 -		 * @return				A new IdentityToken_t pointer, or NULL on failure.
   1.168 -		 */
   1.169 -		virtual IdentityToken_t *CreateIdentity(IdentityType_t type, void *ptr) =0;
   1.170 -
   1.171 -		/** 
   1.172 -		 * @brief Destroys an identity type.  Note that this will delete any identities
   1.173 -		 * that are under this type.  
   1.174 -		 *
   1.175 -		 * @param type			Identity type.
   1.176 -		 */
   1.177 -		virtual void DestroyIdentType(IdentityType_t type) =0;
   1.178 -
   1.179 -		/**
   1.180 -		 * @brief Destroys an identity token.  Any handles being owned by this token, or
   1.181 -		 * any handles being 
   1.182 -		 *
   1.183 -		 * @param identity		Identity to remove.
   1.184 -		 */
   1.185 -		virtual void DestroyIdentity(IdentityToken_t *identity) =0;
   1.186 -
   1.187 -		/**
   1.188 -		 * @brief Requires an extension.  This tells SourceMod that without this extension,
   1.189 -		 * your extension should not be loaded.  The name should not include the ".dll" or
   1.190 -		 * the ".so" part of the file name.
   1.191 -		 *
   1.192 -		 * @param myself		IExtension pointer to yourself.
   1.193 -		 * @param filename		File of extension to require.
   1.194 -		 * @param require		Whether or not this extension is a required dependency.
   1.195 -		 * @param autoload		Whether or not to autoload this extension.
   1.196 -		 */
   1.197 -		virtual void AddDependency(IExtension *myself, const char *filename, bool require, bool autoload) =0;
   1.198 -
   1.199 -		/**
   1.200 -		 * @brief Registers a library name to an extension.
   1.201 -		 *
   1.202 -		 * @param myself		Extension to register library to.
   1.203 -		 * @param name			Library name.
   1.204 -		 */
   1.205 -		virtual void RegisterLibrary(IExtension *myself, const char *name) =0;
   1.206 -
   1.207 -		/**
   1.208 -		 * @brief Adds a list of natives to the global native pool, to be 
   1.209 -		 * bound on plugin load.
   1.210 -		 *
   1.211 -		 * Unlike AddNatives(), this function implements natives that are 
   1.212 -		 * ALWAYS bound, regardless of whether a previous function is bound. 
   1.213 -		 * That means extensions can override Core natives.
   1.214 -		 *
   1.215 -		 * A Core version of each native must exist.  If one does not, then 
   1.216 -		 * Core will simply ignore that entry.
   1.217 -		 *
   1.218 -		 * Override natives represent a weak coupling.  If the extension is 
   1.219 -		 * unloaded, the native will be re-bound to the Core version.
   1.220 -		 * 
   1.221 -		 * @param myself		Identity token of parent object.
   1.222 -		 * @param natives		Array of natives to add.  The last entry in 
   1.223 -		 *						the array must be filled with NULLs to 
   1.224 -		 *						terminate the array.  The array must be static 
   1.225 -		 *						as Core will cache the pointer for the 
   1.226 -		 *						lifetime of the extension.
   1.227 -		 */
   1.228 -		virtual void OverrideNatives(IExtension *myself, const sp_nativeinfo_t *natives) =0;
   1.229 -	};
   1.230 -}
   1.231 -
   1.232 -#endif //_INCLUDE_SOURCEMOD_IFACE_SHARE_SYS_H_