core/interfaces/IShareSys.h
changeset 324 e23aca731e37
parent 323 e12c1cd285e2
child 325 66fa86233688
     1.1 --- a/core/interfaces/IShareSys.h	Fri Jan 19 05:25:43 2007 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,149 +0,0 @@
     1.4 -#ifndef _INCLUDE_SOURCEMOD_IFACE_SHARE_SYS_H_
     1.5 -#define _INCLUDE_SOURCEMOD_IFACE_SHARE_SYS_H_
     1.6 -
     1.7 -#include <sp_vm_types.h>
     1.8 -
     1.9 -#define	NO_IDENTITY		0
    1.10 -
    1.11 -namespace SourceMod
    1.12 -{
    1.13 -	class IExtension;
    1.14 -	struct IdentityToken_t;
    1.15 -	typedef unsigned int		HandleType_t;
    1.16 -	typedef HandleType_t		IdentityType_t;
    1.17 -	/**
    1.18 -	 * @brief Defines the base functionality required by a shared interface.
    1.19 -	 */
    1.20 -	class SMInterface
    1.21 -	{
    1.22 -	public:
    1.23 -		/**
    1.24 -		 * @brief Must return an integer defining the interface's version.
    1.25 -		 */
    1.26 -		virtual unsigned int GetInterfaceVersion() =0;
    1.27 -
    1.28 -		/**
    1.29 -		 * @brief Must return a string defining the interface's unique name.
    1.30 -		 */
    1.31 -		virtual const char *GetInterfaceName() =0;
    1.32 -
    1.33 -		/**
    1.34 -		 * @brief Must return whether the requested version number is backwards comaptible.
    1.35 -		 * Note: This can be overridden for breaking changes or custom versioning.
    1.36 -		 * 
    1.37 -		 * @param version		Version number to compare against.
    1.38 -		 * @return				True if compatible, false otherwise.
    1.39 -		 */
    1.40 -		virtual bool IsVersionCompatible(unsigned int version)
    1.41 -		{
    1.42 -			if (version > GetInterfaceVersion())
    1.43 -			{
    1.44 -				return false;
    1.45 -			}
    1.46 -
    1.47 -			return true;
    1.48 -		}
    1.49 -	};
    1.50 -
    1.51 -	/**
    1.52 -	 * @brief Tracks dependencies and fires dependency listeners.
    1.53 -	 */
    1.54 -	class IShareSys
    1.55 -	{
    1.56 -	public:
    1.57 -		/**
    1.58 -		 * @brief Adds an interface to the global interface system.
    1.59 -		 *
    1.60 -		 * @param myself		Object adding this interface, in order to track dependencies.
    1.61 -		 * @param iface			Interface pointer (must be unique).
    1.62 -		 * @return				True on success, false otherwise.
    1.63 -		 */
    1.64 -		virtual bool AddInterface(IExtension *myself, SMInterface *iface) =0;
    1.65 -
    1.66 -		/**
    1.67 -		 * @brief Requests an interface from the global interface system.
    1.68 -		 * If found, the interface's internal reference count will be increased.
    1.69 -		 *
    1.70 -		 * @param iface_name	Interface name.
    1.71 -		 * @param iface_vers	Interface version to attempt to match.
    1.72 -		 * @param myself		Object requesting this interface, in order to track dependencies.
    1.73 -		 * @param pIface		Pointer to store the return value in.
    1.74 -		 */
    1.75 -		virtual bool RequestInterface(const char *iface_name, 
    1.76 -										unsigned int iface_vers,
    1.77 -										IExtension *myself,
    1.78 -										SMInterface **pIface) =0;
    1.79 -
    1.80 -		/**
    1.81 -		 * @brief Adds a list of natives to the global native pool, to be bound on plugin load.
    1.82 -		 * NOTE: Adding natives currently does not bind them to any loaded plugins.
    1.83 -		 * You must manually bind late natives.
    1.84 -		 * 
    1.85 -		 * @param token			Identity token of parent object.
    1.86 -		 * @param natives		Array of natives to add.  The last entry must have NULL members.
    1.87 -		 */
    1.88 -		virtual void AddNatives(IExtension *myself, const sp_nativeinfo_t *natives) =0;
    1.89 -
    1.90 -		/**
    1.91 -		 * @brief Creates a new identity type.
    1.92 -		 * NOTE: Module authors should never need to use this.  Due to the current implementation,
    1.93 -		 * there is a hardcoded limit of 15 types.  Core uses up a few, so think carefully!
    1.94 -		 *
    1.95 -		 * @param name			String containing type name.  Must not be empty or NULL.
    1.96 -		 * @return				A new HandleType_t identifier, or 0 on failure.
    1.97 -		 */
    1.98 -		virtual IdentityType_t CreateIdentType(const char *name) =0;
    1.99 -
   1.100 -		/**
   1.101 -		 * @brief Finds an identity type by name.
   1.102 -		 * DEFAULT IDENTITY TYPES:
   1.103 -		 *  "PLUGIN"	- An IPlugin object.
   1.104 -		 *  "MODULE"	- An IModule object.
   1.105 -		 *  "CORE"		- An SMGlobalClass or other singleton.
   1.106 -		 * 
   1.107 -		 * @param name			String containing type name to search for.
   1.108 -		 * @return				A HandleType_t identifier if found, 0 otherwise.
   1.109 -		 */
   1.110 -		virtual IdentityType_t FindIdentType(const char *name) =0;
   1.111 -
   1.112 -		/**
   1.113 -		 * @brief Creates a new identity token.  This token is guaranteed to be unique
   1.114 -		 * amongst all other open identities.
   1.115 -		 *
   1.116 -		 * @param type			Identity type.
   1.117 -		 * @return				A new IdentityToken_t identifier.
   1.118 -		 */
   1.119 -		virtual IdentityToken_t *CreateIdentity(IdentityType_t type) =0;
   1.120 -
   1.121 -		/** 
   1.122 -		 * @brief Destroys an identity type.  Note that this will delete any identities
   1.123 -		 * that are under this type.  
   1.124 -		 *
   1.125 -		 * @param type			Identity type.
   1.126 -		 */
   1.127 -		virtual void DestroyIdentType(IdentityType_t type) =0;
   1.128 -
   1.129 -		/**
   1.130 -		 * @brief Destroys an identity token.  Any handles being owned by this token, or
   1.131 -		 * any handles being 
   1.132 -		 *
   1.133 -		 * @param identity		Identity to remove.
   1.134 -		 */
   1.135 -		virtual void DestroyIdentity(IdentityToken_t *identity) =0;
   1.136 -
   1.137 -
   1.138 -		/**
   1.139 -		 * @brief Requires an extension.  This tells SourceMod that without this extension,
   1.140 -		 * your extension should not be loaded.  The name should not include the ".dll" or
   1.141 -		 * the ".so" part of the file name.
   1.142 -		 *
   1.143 -		 * @param myself		IExtension pointer to yourself.
   1.144 -		 * @param filename		File of extension to require.
   1.145 -		 * @param require		Whether or not this extension is a required dependency.
   1.146 -		 * @param autoload		Whether or not to autoload this extension.
   1.147 -		 */
   1.148 -		virtual void AddDependency(IExtension *myself, const char *filename, bool require, bool autoload) =0;
   1.149 -	};
   1.150 -};
   1.151 -
   1.152 -#endif //_INCLUDE_SOURCEMOD_IFACE_SHARE_SYS_H_