public/ISourceMod.h
author David Anderson <dvander@alliedmods.net>
Fri Feb 16 03:47:10 2007 +0000 (2007-02-16)
changeset 501 e209a7296936
parent 484 d254e257cac2
child 653 ef60870067ff
permissions -rw-r--r--
removed this potential feature, not useful enough
     1 /**
     2  * ===============================================================
     3  * SourceMod (C)2004-2007 AlliedModders LLC.  All rights reserved.
     4  * ===============================================================
     5  *
     6  *  This file is part of the SourceMod/SourcePawn SDK.  This file may only be 
     7  * used or modified under the Terms and Conditions of its License Agreement, 
     8  * which is found in public/licenses/LICENSE.txt.  As of this notice, derivative 
     9  * works must be licensed under the GNU General Public License (version 2 or 
    10  * greater).  A copy of the GPL is included under public/licenses/GPL.txt.
    11  * 
    12  * To view the latest information, see: http://www.sourcemod.net/license.php
    13  *
    14  * Version: $Id$
    15  */
    16 
    17 #ifndef _INCLUDE_SOURCEMOD_MAIN_HELPER_INTERFACE_H_
    18 #define _INCLUDE_SOURCEMOD_MAIN_HELPER_INTERFACE_H_
    19 
    20 /**
    21  * @file ISourceMod.h
    22  * @brief Defines miscellanious helper functions useful to extensions.
    23  */
    24 
    25 #include <IShareSys.h>
    26 #include <sp_vm_api.h>
    27 #include <IDataPack.h>
    28 
    29 #define SMINTERFACE_SOURCEMOD_NAME		"ISourceMod"
    30 #define SMINTERFACE_SOURCEMOD_VERSION	1
    31 
    32 namespace SourceMod
    33 {
    34 	/**
    35 	 * @brief Describes various ways of formatting a base path.
    36 	 */
    37 	enum PathType
    38 	{
    39 		Path_None = 0,			/**< No base path */
    40 		Path_Game,				/**< Base path is absolute mod folder */
    41 		Path_SM,				/**< Base path is absolute to SourceMod */
    42 		Path_SM_Rel,			/**< Base path is relative to SourceMod */
    43 	};
    44 
    45 	/**
    46 	 * @brief Contains miscellaneous helper functions.
    47 	 */
    48 	class ISourceMod : public SMInterface
    49 	{
    50 	public:
    51 		virtual const char *GetInterfaceName()
    52 		{
    53 			return SMINTERFACE_SOURCEMOD_NAME;
    54 		}
    55 		virtual unsigned int GetInterfaceVersion()
    56 		{
    57 			return SMINTERFACE_SOURCEMOD_VERSION;
    58 		}
    59 	public:
    60 		/**
    61 		 * @brief Returns the full path to the mod directory.
    62 		 *
    63 		 * @return			A string containing the full mod path.
    64 		 */
    65 		virtual const char *GetModPath() const =0;
    66 
    67 		/**
    68 		 * @brief Returns the full path to the SourceMod directory.
    69 		 *
    70 		 * @return			A string containing the full SourceMod path.
    71 		 */
    72 		virtual const char *GetSourceModPath() const =0;
    73 
    74 		/**
    75 		 * @brief Builds a platform path for a specific target base path.
    76 		 *
    77 		 * @param type		Type of path to use as a base.
    78 		 * @param buffer	Buffer to write to.
    79 		 * @param maxlength	Size of buffer.
    80 		 * @param format	Format string.
    81 		 * @param ...		Format arguments.
    82 		 * @return			Number of bytes written.
    83 		 */
    84 		virtual size_t BuildPath(PathType type, char *buffer, size_t maxlength, char *format, ...) =0;
    85 
    86 		/**
    87 		 * @brief Logs a message to the SourceMod logs.
    88 		 *
    89 		 * @param pExt		Extension calling this function.
    90 		 * @param format	Message format.
    91 		 * @param ...		Message format parameters.
    92 		 */
    93 		virtual void LogMessage(IExtension *pExt, const char *format, ...) =0;
    94 
    95 		/**
    96 		 * @brief Logs a message to the SourceMod error logs.
    97 		 *
    98 		 * @param pExt		Extension calling this function.
    99 		 * @param format	Message format.
   100 		 * @param ...		Message format parameters.
   101 		 */
   102 		virtual void LogError(IExtension *pExt, const char *format, ...) =0;
   103 
   104 		/**
   105 		 * @brief Formats a string from a native.
   106 		 *
   107 		 * @param buffer		Buffer to store message.
   108 		 * @param maxlength		Maximum length of buffer (inculding null terminator).
   109 		 * @param pContext		Pointer to the plugin's context.
   110 		 * @param params		Parameter array that was passed to the native.
   111 		 * @param param			Parameter index where format string and variable arguments begin.
   112 		 *						Note: parameter indexes start at 1.
   113 		 * @return				Number of bytes written, not including the null terminator.
   114 		 */
   115 		virtual size_t FormatString(char *buffer, 
   116 									size_t maxlength, 
   117 									SourcePawn::IPluginContext *pContext,
   118 									const cell_t *params,
   119 									unsigned int param) =0;
   120 
   121 		/**
   122 		 * @brief Creates a data pack object.
   123 		 *
   124 		 * @return			A new IDataPack object.
   125 		 */
   126 		virtual IDataPack *CreateDataPack() =0;
   127 
   128 		/**
   129 		 * @brief Releases a data pack's resources so it can be re-used.
   130 		 *
   131 		 * @param pack		An IDataPack object to release.
   132 		 */
   133 		virtual void FreeDataPack(IDataPack *pack) =0;
   134 
   135 		/**
   136 		 * @brief Returns the automated data pack handle type.
   137 		 *
   138 		 * The readonly data type is the parent of the writable type.  
   139 		 * Note that calling CloseHandle() on either type will release the data pack.
   140 		 * The readonly type is inheritable, but due to limitations of the Handle System,
   141 		 * the writable type is not.
   142 		 *
   143 		 * @param readonly	If true, the readonly type will be returned.
   144 		 * @return			The Handle type for storing generic data packs.
   145 		 */
   146 		 virtual HandleType_t GetDataPackHandleType(bool readonly=false) =0;
   147 	};
   148 }
   149 
   150 #endif //_INCLUDE_SOURCEMOD_MAIN_HELPER_INTERFACE_H_