core/sm_globals.h
author Scott Ehlert <ds@alliedmods.net>
Thu Apr 05 03:02:00 2007 +0000 (2007-04-05)
changeset 661 5c0988b9bf0c
parent 653 ef60870067ff
child 663 b526b82e256e
permissions -rw-r--r--
Ugh, initial import of core config file stuff
Warning: This is positively terrible code.
It works, but needs A LOT of work still :\
     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 CoreConfigErr
    34 {
    35 	CoreConfig_Okay = 0,			/**< No error */
    36 	CoreConfig_NoRuntime = 1,		/**< Cannot set config option while SourceMod is running */
    37 	CoreConfig_InvalidValue = 2,	/**< Invalid value specified for config option */
    38 	CoreConfig_InvalidOption = 3,	/**< Invalid config option specified */
    39 	/* -------------------- */
    40 	CoreConfig_TOTAL				/**< Total number of core config error codes */
    41 };
    42 
    43 /** 
    44  * @brief Any class deriving from this will be automatically initiated/shutdown by SourceMod
    45  */
    46 class SMGlobalClass
    47 {
    48 	friend class SourceModBase;
    49 	friend class CoreConfig;
    50 public:
    51 	SMGlobalClass();
    52 public:
    53 	/**
    54 	 * @brief Called when SourceMod is initially loading
    55 	 */
    56 	virtual void OnSourceModStartup(bool late)
    57 	{
    58 	}
    59 
    60 	/**
    61 	 * @brief Called after all global classes have initialized
    62 	 */
    63 	virtual void OnSourceModAllInitialized()
    64 	{
    65 	}
    66 
    67 	/**
    68 	 * @brief Called when SourceMod is shutting down
    69 	 */
    70 	virtual void OnSourceModShutdown()
    71 	{
    72 	}
    73 
    74 	/**
    75 	 * @brief Called after SourceMod is completely shut down
    76 	 */
    77 	virtual void OnSourceModAllShutdown()
    78 	{
    79 	}
    80 
    81 	/**
    82 	 * @brief Called when a core config option is changed.
    83 	 * @note This is called once BEFORE OnSourceModStartup() when SourceMod is loading
    84 	 * @note It can then be called again when the 'sm config' command is used
    85 	 */
    86 	virtual CoreConfigErr OnSourceModConfigChanged(const char *option, const char *value)
    87 	{
    88 		return CoreConfig_InvalidOption;
    89 	}
    90 private:
    91 	SMGlobalClass *m_pGlobalClassNext;
    92 	static SMGlobalClass *head;
    93 };
    94 
    95 extern ISourcePawnEngine *g_pSourcePawn;
    96 extern IVirtualMachine *g_pVM;
    97 extern IdentityToken_t *g_pCoreIdent;
    98 
    99 #include "sm_autonatives.h"
   100 
   101 #endif //_INCLUDE_SOURCEMOD_GLOBALS_H_