core/sm_globals.h
author David Anderson <dvander@alliedmods.net>
Thu Apr 05 05:25:11 2007 +0000 (2007-04-05)
changeset 663 b526b82e256e
parent 661 5c0988b9bf0c
child 669 ce01c2eb020c
permissions -rw-r--r--
changed the API around a bit to be more flexible
removed some ghastly unneeded stuff from the Translator
added Logger::LogFatal, experimental
     1 /**
     2  * vim: set ts=4 :
     3  * ===============================================================
     4  * SourceMod (C)2004-2007 AlliedModders LLC.  All rights reserved.
     5  * ===============================================================
     6  *
     7  * This file is not open source and may not be copied without explicit
     8  * written permission of AlliedModders LLC.  This file may not be redistributed 
     9  * in whole or significant part.
    10  * For information, see LICENSE.txt or http://www.sourcemod.net/license.php
    11  *
    12  * Version: $Id$
    13  */
    14 
    15 #ifndef _INCLUDE_SOURCEMOD_GLOBALS_H_
    16 #define _INCLUDE_SOURCEMOD_GLOBALS_H_
    17 
    18 /**
    19  * @file Contains global headers that most files in SourceMod will need.
    20  */
    21 
    22 #include <sp_vm_types.h>
    23 #include <sp_vm_api.h>
    24 #include "sm_platform.h"
    25 #include <IShareSys.h>
    26 
    27 using namespace SourcePawn;
    28 using namespace SourceMod;
    29 
    30 /**
    31  * @brief Lists error codes possible from attempting to set a core configuration option.
    32  */
    33 enum ConfigResult
    34 {
    35 	ConfigResult_Accept = 0,
    36 	ConfigResult_Reject = 1,
    37 	ConfigResult_Ignore = 2
    38 };
    39 
    40 enum ConfigSource
    41 {
    42 	ConfigSource_File = 0,
    43 	ConfigSource_Console = 1,
    44 };
    45 
    46 /** 
    47  * @brief Any class deriving from this will be automatically initiated/shutdown by SourceMod
    48  */
    49 class SMGlobalClass
    50 {
    51 	friend class SourceModBase;
    52 	friend class CoreConfig;
    53 public:
    54 	SMGlobalClass();
    55 public:
    56 	/**
    57 	 * @brief Called when SourceMod is initially loading
    58 	 */
    59 	virtual void OnSourceModStartup(bool late)
    60 	{
    61 	}
    62 
    63 	/**
    64 	 * @brief Called after all global classes have initialized
    65 	 */
    66 	virtual void OnSourceModAllInitialized()
    67 	{
    68 	}
    69 
    70 	/**
    71 	 * @brief Called when SourceMod is shutting down
    72 	 */
    73 	virtual void OnSourceModShutdown()
    74 	{
    75 	}
    76 
    77 	/**
    78 	 * @brief Called after SourceMod is completely shut down
    79 	 */
    80 	virtual void OnSourceModAllShutdown()
    81 	{
    82 	}
    83 
    84 	/**
    85 	 * @brief Called when a core config option is changed.
    86 	 * @note This is called once BEFORE OnSourceModStartup() when SourceMod is loading
    87 	 * @note It can then be called again when the 'sm config' command is used
    88 	 */
    89 	virtual ConfigResult OnSourceModConfigChanged(const char *key, 
    90 												  const char *value, 
    91 												  ConfigSource source,
    92 												  char *error, 
    93 												  size_t maxlength)
    94 	{
    95 		return ConfigResult_Ignore;
    96 	}
    97 private:
    98 	SMGlobalClass *m_pGlobalClassNext;
    99 	static SMGlobalClass *head;
   100 };
   101 
   102 extern ISourcePawnEngine *g_pSourcePawn;
   103 extern IVirtualMachine *g_pVM;
   104 extern IdentityToken_t *g_pCoreIdent;
   105 
   106 #include "sm_autonatives.h"
   107 
   108 #endif //_INCLUDE_SOURCEMOD_GLOBALS_H_