Move ADTFactory from core to logic (bug 5953, r=fyren).
authorNicholas Hastings <skamonkey@gmail.com>
Wed Oct 09 08:43:08 2013 -0400 (2013-10-09)
changeset 413711a7aa48621c
parent 4136 08043605bc39
child 4138 da768ad428cf
Move ADTFactory from core to logic (bug 5953, r=fyren).
core/ADTFactory.cpp
core/ADTFactory.h
core/AMBuilder
core/logic/ADTFactory.cpp
core/logic/ADTFactory.h
core/logic/AMBuilder
     1.1 --- a/core/ADTFactory.cpp	Tue Oct 08 21:01:21 2013 -0400
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,94 +0,0 @@
     1.4 -/**
     1.5 - * vim: set ts=4 sw=4 tw=99 noet :
     1.6 - * =============================================================================
     1.7 - * SourceMod
     1.8 - * Copyright (C) 2004-2008 AlliedModders LLC.  All rights reserved.
     1.9 - * =============================================================================
    1.10 - *
    1.11 - * This program is free software; you can redistribute it and/or modify it under
    1.12 - * the terms of the GNU General Public License, version 3.0, as published by the
    1.13 - * Free Software Foundation.
    1.14 - * 
    1.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
    1.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    1.17 - * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
    1.18 - * details.
    1.19 - *
    1.20 - * You should have received a copy of the GNU General Public License along with
    1.21 - * this program.  If not, see <http://www.gnu.org/licenses/>.
    1.22 - *
    1.23 - * As a special exception, AlliedModders LLC gives you permission to link the
    1.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
    1.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
    1.26 - * by the Valve Corporation.  You must obey the GNU General Public License in
    1.27 - * all respects for all other code used.  Additionally, AlliedModders LLC grants
    1.28 - * this exception to all derivative works.  AlliedModders LLC defines further
    1.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
    1.30 - * or <http://www.sourcemod.net/license.php>.
    1.31 - *
    1.32 - * Version: $Id$
    1.33 - */
    1.34 -
    1.35 -#include "ADTFactory.h"
    1.36 -#include "sm_globals.h"
    1.37 -#include "logic_bridge.h"
    1.38 -
    1.39 -ADTFactory g_AdtFactory;
    1.40 -
    1.41 -const char *ADTFactory::GetInterfaceName()
    1.42 -{
    1.43 -	return SMINTERFACE_ADTFACTORY_NAME;
    1.44 -}
    1.45 -
    1.46 -unsigned int ADTFactory::GetInterfaceVersion()
    1.47 -{
    1.48 -	return SMINTERFACE_ADTFACTORY_VERSION;
    1.49 -}
    1.50 -
    1.51 -void ADTFactory::OnSourceModAllInitialized()
    1.52 -{
    1.53 -	sharesys->AddInterface(NULL, this);
    1.54 -}
    1.55 -
    1.56 -IBasicTrie *ADTFactory::CreateBasicTrie()
    1.57 -{
    1.58 -	return new BaseTrie();
    1.59 -}
    1.60 -
    1.61 -BaseTrie::BaseTrie()
    1.62 -{
    1.63 -}
    1.64 -
    1.65 -BaseTrie::~BaseTrie()
    1.66 -{
    1.67 -}
    1.68 -
    1.69 -bool BaseTrie::Insert(const char *key, void *value)
    1.70 -{
    1.71 -	return map_.insert(key, value);
    1.72 -}
    1.73 -
    1.74 -bool BaseTrie::Retrieve(const char *key, void **value)
    1.75 -{
    1.76 -	return map_.retrieve(key, value);
    1.77 -}
    1.78 -
    1.79 -bool BaseTrie::Delete(const char *key)
    1.80 -{
    1.81 -	return map_.remove(key);
    1.82 -}
    1.83 -
    1.84 -void BaseTrie::Clear()
    1.85 -{
    1.86 -	map_.clear();
    1.87 -}
    1.88 -
    1.89 -void BaseTrie::Destroy()
    1.90 -{
    1.91 -	delete this;
    1.92 -}
    1.93 -
    1.94 -bool BaseTrie::Replace(const char *key, void *value)
    1.95 -{
    1.96 -	return map_.replace(key, value);
    1.97 -}
     2.1 --- a/core/ADTFactory.h	Tue Oct 08 21:01:21 2013 -0400
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,70 +0,0 @@
     2.4 -/**
     2.5 - * vim: set ts=4 sw=4 tw=99 noet :
     2.6 - * =============================================================================
     2.7 - * SourceMod
     2.8 - * Copyright (C) 2004-2008 AlliedModders LLC.  All rights reserved.
     2.9 - * =============================================================================
    2.10 - *
    2.11 - * This program is free software; you can redistribute it and/or modify it under
    2.12 - * the terms of the GNU General Public License, version 3.0, as published by the
    2.13 - * Free Software Foundation.
    2.14 - * 
    2.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
    2.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    2.17 - * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
    2.18 - * details.
    2.19 - *
    2.20 - * You should have received a copy of the GNU General Public License along with
    2.21 - * this program.  If not, see <http://www.gnu.org/licenses/>.
    2.22 - *
    2.23 - * As a special exception, AlliedModders LLC gives you permission to link the
    2.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
    2.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
    2.26 - * by the Valve Corporation.  You must obey the GNU General Public License in
    2.27 - * all respects for all other code used.  Additionally, AlliedModders LLC grants
    2.28 - * this exception to all derivative works.  AlliedModders LLC defines further
    2.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
    2.30 - * or <http://www.sourcemod.net/license.php>.
    2.31 - *
    2.32 - * Version: $Id$
    2.33 - */
    2.34 -
    2.35 -#ifndef _INCLUDE_SOURCEMOD_ADTFACTORY_H_
    2.36 -#define _INCLUDE_SOURCEMOD_ADTFACTORY_H_
    2.37 -
    2.38 -#include <IADTFactory.h>
    2.39 -#include "sm_globals.h"
    2.40 -#include <sm_stringhashmap.h>
    2.41 -
    2.42 -using namespace SourceMod;
    2.43 -
    2.44 -class BaseTrie : public IBasicTrie
    2.45 -{
    2.46 -public:
    2.47 -	BaseTrie();
    2.48 -	virtual ~BaseTrie();
    2.49 -	virtual bool Insert(const char *key, void *value);
    2.50 -	virtual bool Replace(const char *key, void *value);
    2.51 -	virtual bool Retrieve(const char *key, void **value);
    2.52 -	virtual bool Delete(const char *key);
    2.53 -	virtual void Clear();
    2.54 -	virtual void Destroy();
    2.55 -private:
    2.56 -	StringHashMap<void *> map_;
    2.57 -};
    2.58 -
    2.59 -class ADTFactory : 
    2.60 -	public SMGlobalClass,
    2.61 -	public IADTFactory
    2.62 -{
    2.63 -public: //SMInterface
    2.64 -	const char *GetInterfaceName();
    2.65 -	unsigned int GetInterfaceVersion();
    2.66 -public: //SMGlobalClass
    2.67 -	void OnSourceModAllInitialized();
    2.68 -public: //IADTFactory
    2.69 -	IBasicTrie *CreateBasicTrie();
    2.70 -};
    2.71 -
    2.72 -#endif //_INCLUDE_SOURCEMOD_ADTFACTORY_H_
    2.73 -
     3.1 --- a/core/AMBuilder	Tue Oct 08 21:01:21 2013 -0400
     3.2 +++ b/core/AMBuilder	Wed Oct 09 08:43:08 2013 -0400
     3.3 @@ -61,7 +61,6 @@
     3.4  		'logic_bridge.cpp',
     3.5  		'smn_entities.cpp',
     3.6  		'sm_stringutil.cpp',
     3.7 -		'ADTFactory.cpp',
     3.8  		'ForwardSys.cpp',
     3.9  		'MenuVoting.cpp',
    3.10  		'smn_events.cpp',
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/core/logic/ADTFactory.cpp	Wed Oct 09 08:43:08 2013 -0400
     4.3 @@ -0,0 +1,93 @@
     4.4 +/**
     4.5 + * vim: set ts=4 sw=4 tw=99 noet :
     4.6 + * =============================================================================
     4.7 + * SourceMod
     4.8 + * Copyright (C) 2004-2008 AlliedModders LLC.  All rights reserved.
     4.9 + * =============================================================================
    4.10 + *
    4.11 + * This program is free software; you can redistribute it and/or modify it under
    4.12 + * the terms of the GNU General Public License, version 3.0, as published by the
    4.13 + * Free Software Foundation.
    4.14 + * 
    4.15 + * This program is distributed in the hope that it will be useful, but WITHOUT
    4.16 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    4.17 + * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
    4.18 + * details.
    4.19 + *
    4.20 + * You should have received a copy of the GNU General Public License along with
    4.21 + * this program.  If not, see <http://www.gnu.org/licenses/>.
    4.22 + *
    4.23 + * As a special exception, AlliedModders LLC gives you permission to link the
    4.24 + * code of this program (as well as its derivative works) to "Half-Life 2," the
    4.25 + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
    4.26 + * by the Valve Corporation.  You must obey the GNU General Public License in
    4.27 + * all respects for all other code used.  Additionally, AlliedModders LLC grants
    4.28 + * this exception to all derivative works.  AlliedModders LLC defines further
    4.29 + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
    4.30 + * or <http://www.sourcemod.net/license.php>.
    4.31 + *
    4.32 + * Version: $Id$
    4.33 + */
    4.34 +
    4.35 +#include "ADTFactory.h"
    4.36 +#include "ShareSys.h"
    4.37 +
    4.38 +ADTFactory g_AdtFactory;
    4.39 +
    4.40 +const char *ADTFactory::GetInterfaceName()
    4.41 +{
    4.42 +	return SMINTERFACE_ADTFACTORY_NAME;
    4.43 +}
    4.44 +
    4.45 +unsigned int ADTFactory::GetInterfaceVersion()
    4.46 +{
    4.47 +	return SMINTERFACE_ADTFACTORY_VERSION;
    4.48 +}
    4.49 +
    4.50 +void ADTFactory::OnSourceModAllInitialized()
    4.51 +{
    4.52 +	g_ShareSys.AddInterface(NULL, this);
    4.53 +}
    4.54 +
    4.55 +IBasicTrie *ADTFactory::CreateBasicTrie()
    4.56 +{
    4.57 +	return new BaseTrie();
    4.58 +}
    4.59 +
    4.60 +BaseTrie::BaseTrie()
    4.61 +{
    4.62 +}
    4.63 +
    4.64 +BaseTrie::~BaseTrie()
    4.65 +{
    4.66 +}
    4.67 +
    4.68 +bool BaseTrie::Insert(const char *key, void *value)
    4.69 +{
    4.70 +	return map_.insert(key, value);
    4.71 +}
    4.72 +
    4.73 +bool BaseTrie::Retrieve(const char *key, void **value)
    4.74 +{
    4.75 +	return map_.retrieve(key, value);
    4.76 +}
    4.77 +
    4.78 +bool BaseTrie::Delete(const char *key)
    4.79 +{
    4.80 +	return map_.remove(key);
    4.81 +}
    4.82 +
    4.83 +void BaseTrie::Clear()
    4.84 +{
    4.85 +	map_.clear();
    4.86 +}
    4.87 +
    4.88 +void BaseTrie::Destroy()
    4.89 +{
    4.90 +	delete this;
    4.91 +}
    4.92 +
    4.93 +bool BaseTrie::Replace(const char *key, void *value)
    4.94 +{
    4.95 +	return map_.replace(key, value);
    4.96 +}
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/core/logic/ADTFactory.h	Wed Oct 09 08:43:08 2013 -0400
     5.3 @@ -0,0 +1,70 @@
     5.4 +/**
     5.5 + * vim: set ts=4 sw=4 tw=99 noet :
     5.6 + * =============================================================================
     5.7 + * SourceMod
     5.8 + * Copyright (C) 2004-2008 AlliedModders LLC.  All rights reserved.
     5.9 + * =============================================================================
    5.10 + *
    5.11 + * This program is free software; you can redistribute it and/or modify it under
    5.12 + * the terms of the GNU General Public License, version 3.0, as published by the
    5.13 + * Free Software Foundation.
    5.14 + * 
    5.15 + * This program is distributed in the hope that it will be useful, but WITHOUT
    5.16 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    5.17 + * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
    5.18 + * details.
    5.19 + *
    5.20 + * You should have received a copy of the GNU General Public License along with
    5.21 + * this program.  If not, see <http://www.gnu.org/licenses/>.
    5.22 + *
    5.23 + * As a special exception, AlliedModders LLC gives you permission to link the
    5.24 + * code of this program (as well as its derivative works) to "Half-Life 2," the
    5.25 + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
    5.26 + * by the Valve Corporation.  You must obey the GNU General Public License in
    5.27 + * all respects for all other code used.  Additionally, AlliedModders LLC grants
    5.28 + * this exception to all derivative works.  AlliedModders LLC defines further
    5.29 + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
    5.30 + * or <http://www.sourcemod.net/license.php>.
    5.31 + *
    5.32 + * Version: $Id$
    5.33 + */
    5.34 +
    5.35 +#ifndef _INCLUDE_SOURCEMOD_ADTFACTORY_H_
    5.36 +#define _INCLUDE_SOURCEMOD_ADTFACTORY_H_
    5.37 +
    5.38 +#include <IADTFactory.h>
    5.39 +#include "common_logic.h"
    5.40 +#include <sm_stringhashmap.h>
    5.41 +
    5.42 +using namespace SourceMod;
    5.43 +
    5.44 +class BaseTrie : public IBasicTrie
    5.45 +{
    5.46 +public:
    5.47 +	BaseTrie();
    5.48 +	virtual ~BaseTrie();
    5.49 +	virtual bool Insert(const char *key, void *value);
    5.50 +	virtual bool Replace(const char *key, void *value);
    5.51 +	virtual bool Retrieve(const char *key, void **value);
    5.52 +	virtual bool Delete(const char *key);
    5.53 +	virtual void Clear();
    5.54 +	virtual void Destroy();
    5.55 +private:
    5.56 +	StringHashMap<void *> map_;
    5.57 +};
    5.58 +
    5.59 +class ADTFactory : 
    5.60 +	public SMGlobalClass,
    5.61 +	public IADTFactory
    5.62 +{
    5.63 +public: //SMInterface
    5.64 +	const char *GetInterfaceName();
    5.65 +	unsigned int GetInterfaceVersion();
    5.66 +public: //SMGlobalClass
    5.67 +	void OnSourceModAllInitialized();
    5.68 +public: //IADTFactory
    5.69 +	IBasicTrie *CreateBasicTrie();
    5.70 +};
    5.71 +
    5.72 +#endif //_INCLUDE_SOURCEMOD_ADTFACTORY_H_
    5.73 +
     6.1 --- a/core/logic/AMBuilder	Tue Oct 08 21:01:21 2013 -0400
     6.2 +++ b/core/logic/AMBuilder	Wed Oct 09 08:43:08 2013 -0400
     6.3 @@ -25,6 +25,7 @@
     6.4  	'smn_adt_array.cpp',
     6.5  	'smn_sorting.cpp',
     6.6  	'smn_maplists.cpp',
     6.7 +	'ADTFactory.cpp',
     6.8  	'smn_adt_stack.cpp',
     6.9  	'thread/ThreadWorker.cpp',
    6.10  	'thread/BaseWorker.cpp',