extensions/sdktools/util.h
author David Anderson <dvander@alliedmods.net>
Wed Feb 25 20:07:12 2009 -0500 (2009-02-25)
changeset 2607 f3b8bbe17f85
parent 2289 44045ead61cd
permissions -rw-r--r--
Backed out changeset fa286305bd3f
pred@1922
     1
/**
pred@1922
     2
 * vim: set ts=4 :
pred@1922
     3
 * =============================================================================
pred@1922
     4
 * SourceMod SDKTools Extension
ds@1947
     5
 * Copyright (C) 2004-2008 AlliedModders LLC.  All rights reserved.
pred@1922
     6
 * =============================================================================
pred@1922
     7
 *
pred@1922
     8
 * This program is free software; you can redistribute it and/or modify it under
pred@1922
     9
 * the terms of the GNU General Public License, version 3.0, as published by the
pred@1922
    10
 * Free Software Foundation.
pred@1922
    11
 * 
pred@1922
    12
 * This program is distributed in the hope that it will be useful, but WITHOUT
pred@1922
    13
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
pred@1922
    14
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
pred@1922
    15
 * details.
pred@1922
    16
 *
pred@1922
    17
 * You should have received a copy of the GNU General Public License along with
pred@1922
    18
 * this program.  If not, see <http://www.gnu.org/licenses/>.
pred@1922
    19
 *
pred@1922
    20
 * As a special exception, AlliedModders LLC gives you permission to link the
pred@1922
    21
 * code of this program (as well as its derivative works) to "Half-Life 2," the
pred@1922
    22
 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
pred@1922
    23
 * by the Valve Corporation.  You must obey the GNU General Public License in
pred@1922
    24
 * all respects for all other code used.  Additionally, AlliedModders LLC grants
pred@1922
    25
 * this exception to all derivative works.  AlliedModders LLC defines further
pred@1922
    26
 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
pred@1922
    27
 * or <http://www.sourcemod.net/license.php>.
pred@1922
    28
 *
ds@1987
    29
 * Version: $Id$
pred@1922
    30
 */
pred@1922
    31
pred@1922
    32
#ifndef _INCLUDE_SOURCEMOD_UTIL_H_
pred@1922
    33
#define _INCLUDE_SOURCEMOD_UTIL_H_
pred@1922
    34
pred@1922
    35
#include "utldict.h"
pred@1922
    36
pred@1922
    37
abstract_class IEntityFactory
pred@1922
    38
{
pred@1922
    39
public:
pred@1922
    40
	virtual IServerNetworkable *Create( const char *pClassName ) = 0;
pred@1922
    41
	virtual void Destroy( IServerNetworkable *pNetworkable ) = 0;
pred@1922
    42
	virtual size_t GetEntitySize() = 0;
pred@1922
    43
};
pred@1922
    44
pred@1922
    45
abstract_class IEntityFactoryDictionary
pred@1922
    46
{
pred@1922
    47
public:
pred@1922
    48
	virtual void InstallFactory( IEntityFactory *pFactory, const char *pClassName ) = 0;
pred@1922
    49
	virtual IServerNetworkable *Create( const char *pClassName ) = 0;
pred@1922
    50
	virtual void Destroy( const char *pClassName, IServerNetworkable *pNetworkable ) = 0;
pred@1922
    51
	virtual IEntityFactory *FindFactory( const char *pClassName ) = 0;
pred@1922
    52
	virtual const char *GetCannonicalName( const char *pClassName ) = 0;
pred@1922
    53
};
pred@1922
    54
pred@1922
    55
class CEntityFactoryDictionary : public IEntityFactoryDictionary
pred@1922
    56
{
pred@1922
    57
public:
pred@1922
    58
	CEntityFactoryDictionary();
pred@1922
    59
pred@1922
    60
	virtual void InstallFactory( IEntityFactory *pFactory, const char *pClassName );
pred@1922
    61
	virtual IServerNetworkable *Create( const char *pClassName );
pred@1922
    62
	virtual void Destroy( const char *pClassName, IServerNetworkable *pNetworkable );
pred@1922
    63
	virtual const char *GetCannonicalName( const char *pClassName );
pred@1922
    64
	void ReportEntitySizes();
pred@1922
    65
pred@1922
    66
private:
pred@1922
    67
	IEntityFactory *FindFactory( const char *pClassName );
pred@1922
    68
public:
pred@1922
    69
	CUtlDict< IEntityFactory *, unsigned short > m_Factories;
pred@1922
    70
};
pred@1922
    71
pred@1922
    72
#endif //_INCLUDE_SOURCEMOD_UTIL_H_