core/CoreConfig.h
author David Anderson <dvander@alliedmods.net>
Tue Feb 17 16:19:11 2009 -0500 (2009-02-17)
changeset 2574 d05c7ee81134
parent 2289 44045ead61cd
child 4070 4bd9fbf607d9
permissions -rw-r--r--
Added API to grab arbitrary kv pairs from core.cfg.
ds@661
     1
/**
ds@661
     2
 * vim: set ts=4 :
ds@1330
     3
 * =============================================================================
dvander@1231
     4
 * SourceMod
ds@1947
     5
 * Copyright (C) 2004-2008 AlliedModders LLC.  All rights reserved.
ds@1330
     6
 * =============================================================================
ds@661
     7
 *
ds@1330
     8
 * This program is free software; you can redistribute it and/or modify it under
ds@1330
     9
 * the terms of the GNU General Public License, version 3.0, as published by the
ds@1330
    10
 * Free Software Foundation.
dvander@1231
    11
 * 
ds@1330
    12
 * This program is distributed in the hope that it will be useful, but WITHOUT
ds@1330
    13
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
ds@1330
    14
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
ds@1330
    15
 * details.
dvander@1231
    16
 *
ds@1330
    17
 * You should have received a copy of the GNU General Public License along with
ds@1330
    18
 * this program.  If not, see <http://www.gnu.org/licenses/>.
dvander@1231
    19
 *
ds@1330
    20
 * As a special exception, AlliedModders LLC gives you permission to link the
ds@1330
    21
 * code of this program (as well as its derivative works) to "Half-Life 2," the
ds@1330
    22
 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
ds@1330
    23
 * by the Valve Corporation.  You must obey the GNU General Public License in
ds@1330
    24
 * all respects for all other code used.  Additionally, AlliedModders LLC grants
ds@1330
    25
 * this exception to all derivative works.  AlliedModders LLC defines further
ds@1330
    26
 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
ds@1330
    27
 * or <http://www.sourcemod.net/license.php>.
ds@661
    28
 *
ds@661
    29
 * Version: $Id$
ds@661
    30
 */
ds@661
    31
ds@661
    32
#ifndef _INCLUDE_SOURCEMOD_CORECONFIG_H_
ds@661
    33
#define _INCLUDE_SOURCEMOD_CORECONFIG_H_
ds@661
    34
ds@661
    35
#include "sm_globals.h"
ds@661
    36
#include <ITextParsers.h>
ds@661
    37
#include <IRootConsoleMenu.h>
dvander@2574
    38
#include <sm_trie_tpl.h>
dvander@2574
    39
#include "sm_memtable.h"
ds@661
    40
ds@661
    41
using namespace SourceMod;
ds@661
    42
ds@661
    43
class CoreConfig : 
ds@661
    44
	public SMGlobalClass,
ds@661
    45
	public ITextListener_SMC,
ds@661
    46
	public IRootConsoleCommand
ds@661
    47
{
dvander@2574
    48
public:
dvander@2574
    49
	CoreConfig();
dvander@2574
    50
	~CoreConfig();
ds@661
    51
public: // SMGlobalClass
ds@661
    52
	void OnSourceModAllInitialized();
ds@661
    53
	void OnSourceModShutdown();
dvander@978
    54
	void OnSourceModLevelChange(const char *mapName);
ds@661
    55
public: // ITextListener_SMC
dvander@1656
    56
	SMCResult ReadSMC_KeyValue(const SMCStates *states, const char *key, const char *value);
ds@661
    57
public: // IRootConsoleCommand
faluco@1541
    58
	void OnRootConsoleCommand(const char *cmdname, const CCommand &command);
ds@661
    59
public:
ds@661
    60
	/**
ds@661
    61
	 * Initializes CoreConfig by reading from core.cfg file
ds@661
    62
	 */
ds@661
    63
	void Initialize();
dvander@2574
    64
	const char *GetCoreConfigValue(const char *key);
ds@661
    65
private:
ds@661
    66
	/**
ds@661
    67
	 * Sets configuration option by notifying SourceMod components that rely on core.cfg
ds@661
    68
	 */
dvander@663
    69
	ConfigResult SetConfigOption(const char *option, const char *value, ConfigSource, char *Error, size_t maxlength);
dvander@2574
    70
private:
dvander@2574
    71
	BaseStringTable m_Strings;
dvander@2574
    72
	KTrie<int> m_KeyValues;
ds@661
    73
};
ds@661
    74
dvander@978
    75
extern bool SM_AreConfigsExecuted();
dvander@978
    76
extern void SM_ExecuteAllConfigs();
dvander@978
    77
extern void SM_ExecuteForPlugin(IPluginContext *ctx);
dvander@978
    78
extern void SM_ConfigsExecuted_Global();
dvander@978
    79
extern void SM_ConfigsExecuted_Plugin(unsigned int serial);
dvander@2235
    80
extern void SM_InternalCmdTrigger();
dvander@978
    81
ds@661
    82
extern CoreConfig g_CoreConfig;
ds@661
    83
ds@661
    84
#endif // _INCLUDE_SOURCEMOD_CORECONFIG_H_