1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/core/ADTFactory.cpp Sat Jun 30 16:43:11 2007 +0000
1.3 @@ -0,0 +1,60 @@
1.4 +#include "ADTFactory.h"
1.5 +#include "sm_globals.h"
1.6 +#include "ShareSys.h"
1.7 +
1.8 +ADTFactory g_AdtFactory;
1.9 +
1.10 +const char *ADTFactory::GetInterfaceName()
1.11 +{
1.12 + return SMINTERFACE_ADTFACTORY_NAME;
1.13 +}
1.14 +
1.15 +unsigned int ADTFactory::GetInterfaceVersion()
1.16 +{
1.17 + return SMINTERFACE_ADTFACTORY_VERSION;
1.18 +}
1.19 +
1.20 +void ADTFactory::OnSourceModAllInitialized()
1.21 +{
1.22 + g_ShareSys.AddInterface(NULL, this);
1.23 +}
1.24 +
1.25 +IBasicTrie *ADTFactory::CreateBasicTrie()
1.26 +{
1.27 + return new BaseTrie();
1.28 +}
1.29 +
1.30 +BaseTrie::BaseTrie()
1.31 +{
1.32 + m_pTrie = sm_trie_create();
1.33 +}
1.34 +
1.35 +BaseTrie::~BaseTrie()
1.36 +{
1.37 + sm_trie_destroy(m_pTrie);
1.38 +}
1.39 +
1.40 +bool BaseTrie::Insert(const char *key, void *value)
1.41 +{
1.42 + return sm_trie_insert(m_pTrie, key, value);
1.43 +}
1.44 +
1.45 +bool BaseTrie::Retrieve(const char *key, void **value)
1.46 +{
1.47 + return sm_trie_retrieve(m_pTrie, key, value);
1.48 +}
1.49 +
1.50 +bool BaseTrie::Delete(const char *key)
1.51 +{
1.52 + return sm_trie_delete(m_pTrie, key);
1.53 +}
1.54 +
1.55 +void BaseTrie::Clear()
1.56 +{
1.57 + sm_trie_clear(m_pTrie);
1.58 +}
1.59 +
1.60 +void BaseTrie::Destroy()
1.61 +{
1.62 + delete this;
1.63 +}
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/core/ADTFactory.h Sat Jun 30 16:43:11 2007 +0000
2.3 @@ -0,0 +1,33 @@
2.4 +#include <IADTFactory.h>
2.5 +#include "sm_globals.h"
2.6 +#include "sm_trie.h"
2.7 +
2.8 +using namespace SourceMod;
2.9 +
2.10 +class BaseTrie : public IBasicTrie
2.11 +{
2.12 +public:
2.13 + BaseTrie();
2.14 + virtual ~BaseTrie();
2.15 + virtual bool Insert(const char *key, void *value);
2.16 + virtual bool Retrieve(const char *key, void **value);
2.17 + virtual bool Delete(const char *key);
2.18 + virtual void Clear();
2.19 + virtual void Destroy();
2.20 +private:
2.21 + Trie *m_pTrie;
2.22 +};
2.23 +
2.24 +class ADTFactory :
2.25 + public SMGlobalClass,
2.26 + public IADTFactory
2.27 +{
2.28 +public: //SMInterface
2.29 + const char *GetInterfaceName();
2.30 + unsigned int GetInterfaceVersion();
2.31 +public: //SMGlobalClass
2.32 + void OnSourceModAllInitialized();
2.33 +public: //IADTFactory
2.34 + IBasicTrie *CreateBasicTrie();
2.35 +};
2.36 +
3.1 --- a/core/msvc8/sourcemod_mm.vcproj Fri Jun 29 07:09:56 2007 +0000
3.2 +++ b/core/msvc8/sourcemod_mm.vcproj Sat Jun 30 16:43:11 2007 +0000
3.3 @@ -186,6 +186,10 @@
3.4 >
3.5 </File>
3.6 <File
3.7 + RelativePath="..\ADTFactory.cpp"
3.8 + >
3.9 + </File>
3.10 + <File
3.11 RelativePath="..\CDataPack.cpp"
3.12 >
3.13 </File>
3.14 @@ -308,6 +312,10 @@
3.15 >
3.16 </File>
3.17 <File
3.18 + RelativePath="..\ADTFactory.h"
3.19 + >
3.20 + </File>
3.21 + <File
3.22 RelativePath="..\CDataPack.h"
3.23 >
3.24 </File>
3.25 @@ -453,6 +461,10 @@
3.26 >
3.27 </File>
3.28 <File
3.29 + RelativePath="..\..\public\IADTFactory.h"
3.30 + >
3.31 + </File>
3.32 + <File
3.33 RelativePath="..\..\public\IDataPack.h"
3.34 >
3.35 </File>
4.1 --- a/extensions/sdktools/sdk/smsdk_config.h Fri Jun 29 07:09:56 2007 +0000
4.2 +++ b/extensions/sdktools/sdk/smsdk_config.h Sat Jun 30 16:43:11 2007 +0000
4.3 @@ -54,5 +54,8 @@
4.4 //#define SMEXT_ENABLE_DBMANAGER
4.5 #define SMEXT_ENABLE_GAMECONF
4.6 #define SMEXT_ENABLE_MEMUTILS
4.7 +//#define SMEXT_ENABLE_GAMEHELPERS
4.8 +//#define SMEXT_ENABLE_TIMERSYS
4.9 +//#define SMEXT_ENABLE_ADTFACTORY
4.10
4.11 #endif // _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
5.1 --- a/extensions/sdktools/sdk/smsdk_ext.cpp Fri Jun 29 07:09:56 2007 +0000
5.2 +++ b/extensions/sdktools/sdk/smsdk_ext.cpp Sat Jun 30 16:43:11 2007 +0000
5.3 @@ -51,6 +51,15 @@
5.4 #if defined SMEXT_ENABLE_MEMUTILS
5.5 IMemoryUtils *memutils = NULL;
5.6 #endif
5.7 +#if defined SMEXT_ENABLE_GAMEHELPERS
5.8 +IGameHelpers *gamehelpers = NULL;
5.9 +#endif
5.10 +#if defined SMEXT_ENABLE_TIMERSYS
5.11 +ITimerSystem *timersys = NULL;
5.12 +#endif
5.13 +#if defined SMEXT_ENABLE_ADTFACTORY
5.14 +IADTFactory *adtfactory = NULL;
5.15 +#endif
5.16
5.17 /** Exports the main interface */
5.18 PLATFORM_EXTERN_C IExtensionInterface *GetSMExtAPI()
5.19 @@ -106,6 +115,15 @@
5.20 #if defined SMEXT_ENABLE_MEMUTILS
5.21 SM_GET_IFACE(MEMORYUTILS, memutils);
5.22 #endif
5.23 +#if defined SMEXT_ENABLE_GAMEHELPERS
5.24 + SM_GET_IFACE(GAMEHELPERS, gamehelpers);
5.25 +#endif
5.26 +#if defined SMEXT_ENABLE_TIMERSYS
5.27 + SM_GET_IFACE(TIMERSYS, timersys);
5.28 +#endif
5.29 +#if defined SMEXT_ENABLE_ADTFACTORY
5.30 + SM_GET_IFACE(ADTFACTORY, adtfactory);
5.31 +#endif
5.32
5.33 if (SDK_OnLoad(error, maxlength, late))
5.34 {
6.1 --- a/extensions/sdktools/sdk/smsdk_ext.h Fri Jun 29 07:09:56 2007 +0000
6.2 +++ b/extensions/sdktools/sdk/smsdk_ext.h Sat Jun 30 16:43:11 2007 +0000
6.3 @@ -45,6 +45,15 @@
6.4 #if defined SMEXT_ENABLE_MEMUTILS
6.5 #include <IMemoryUtils.h>
6.6 #endif
6.7 +#if defined SMEXT_ENABLE_GAMEHELPERS
6.8 +#include <IGameHelpers.h>
6.9 +#endif
6.10 +#if defined SMEXT_ENABLE_TIMERSYS
6.11 +#include <ITimerSystem.h>
6.12 +#endif
6.13 +#if defined SMEXT_ENABLE_ADTFACTORY
6.14 +#include <IADTFactory.h>
6.15 +#endif
6.16
6.17 #if defined SMEXT_CONF_METAMOD
6.18 #include <ISmmPlugin.h>
6.19 @@ -213,6 +222,15 @@
6.20 #if defined SMEXT_ENABLE_MEMUTILS
6.21 extern IMemoryUtils *memutils;
6.22 #endif
6.23 +#if defined SMEXT_ENABLE_GAMEHELPERS
6.24 +extern IGameHelpers *gamehelpers;
6.25 +#endif
6.26 +#if defined SMEXT_ENABLE_TIMERSYS
6.27 +extern ITimerSystem *timersys;
6.28 +#endif
6.29 +#if defined SMEXT_ENABLE_ADTFACTORY
6.30 +extern IADTFactory *adtfactory;
6.31 +#endif
6.32
6.33 #if defined SMEXT_CONF_METAMOD
6.34 PLUGIN_GLOBALVARS();
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
7.2 +++ b/public/IADTFactory.h Sat Jun 30 16:43:11 2007 +0000
7.3 @@ -0,0 +1,73 @@
7.4 +#ifndef _INCLUDE_SOURCEMOD_ADT_FACTORY_H_
7.5 +#define _INCLUDE_SOURCEMOD_ADT_FACTORY_H_
7.6 +
7.7 +#include <IShareSys.h>
7.8 +
7.9 +#define SMINTERFACE_ADTFACTORY_NAME "IADTFactory"
7.10 +#define SMINTERFACE_ADTFACTORY_VERSION 1
7.11 +
7.12 +/**
7.13 +* @file IADTFactory.h
7.14 +* @brief Creates abstract data types.
7.15 +*/
7.16 +
7.17 +namespace SourceMod
7.18 +{
7.19 + /**
7.20 + * @brief A "Trie" data type.
7.21 + */
7.22 + class IBasicTrie
7.23 + {
7.24 + public:
7.25 + /**
7.26 + * @brief Inserts a key/value pair.
7.27 + *
7.28 + * @param key Key string (null terminated).
7.29 + * @param value Value pointer (may be anything).
7.30 + * @return True on success, false if key already exists.
7.31 + */
7.32 + virtual bool Insert(const char *key, void *value) =0;
7.33 +
7.34 + /**
7.35 + * @brief Retrieves the value of a key.
7.36 + *
7.37 + * @param key Key string (null terminated).
7.38 + * @param value Optional pointer to store value pointer.
7.39 + * @return True on success, false if key was not found.
7.40 + */
7.41 + virtual bool Retrieve(const char *key, void **value) =0;
7.42 +
7.43 + /**
7.44 + * @brief Deletes a key.
7.45 + *
7.46 + * @param key Key string (null terminated).
7.47 + * @return True on success, false if key was not found.
7.48 + */
7.49 + virtual bool Delete(const char *key) =0;
7.50 +
7.51 + /**
7.52 + * @brief Flushes the entire trie of all keys.
7.53 + */
7.54 + virtual void Clear() =0;
7.55 +
7.56 + /**
7.57 + * @brief Destroys the IBasicTrie object and frees all associated
7.58 + * memory.
7.59 + */
7.60 + virtual void Destroy() =0;
7.61 + };
7.62 +
7.63 + class IADTFactory : public SMInterface
7.64 + {
7.65 + public:
7.66 + /**
7.67 + * @brief Creates a basic Trie object.
7.68 + *
7.69 + * @return A new IBasicTrie object which must be destroyed
7.70 + * via IBasicTrie::Destroy().
7.71 + */
7.72 + virtual IBasicTrie *CreateBasicTrie() =0;
7.73 + };
7.74 +}
7.75 +
7.76 +#endif //_INCLUDE_SOURCEMOD_ADT_FACTORY_H_
8.1 --- a/public/sample_ext/sdk/smsdk_ext.cpp Fri Jun 29 07:09:56 2007 +0000
8.2 +++ b/public/sample_ext/sdk/smsdk_ext.cpp Sat Jun 30 16:43:11 2007 +0000
8.3 @@ -57,6 +57,9 @@
8.4 #if defined SMEXT_ENABLE_TIMERSYS
8.5 ITimerSystem *timersys = NULL;
8.6 #endif
8.7 +#if defined SMEXT_ENABLE_ADTFACTORY
8.8 +IADTFactory *adtfactory = NULL;
8.9 +#endif
8.10
8.11 /** Exports the main interface */
8.12 PLATFORM_EXTERN_C IExtensionInterface *GetSMExtAPI()
8.13 @@ -118,6 +121,9 @@
8.14 #if defined SMEXT_ENABLE_TIMERSYS
8.15 SM_GET_IFACE(TIMERSYS, timersys);
8.16 #endif
8.17 +#if defined SMEXT_ENABLE_ADTFACTORY
8.18 + SM_GET_IFACE(ADTFACTORY, adtfactory);
8.19 +#endif
8.20
8.21 if (SDK_OnLoad(error, maxlength, late))
8.22 {
9.1 --- a/public/sample_ext/sdk/smsdk_ext.h Fri Jun 29 07:09:56 2007 +0000
9.2 +++ b/public/sample_ext/sdk/smsdk_ext.h Sat Jun 30 16:43:11 2007 +0000
9.3 @@ -51,6 +51,9 @@
9.4 #if defined SMEXT_ENABLE_TIMERSYS
9.5 #include <ITimerSystem.h>
9.6 #endif
9.7 +#if defined SMEXT_ENABLE_ADTFACTORY
9.8 +#include <IADTFactory.h>
9.9 +#endif
9.10
9.11 #if defined SMEXT_CONF_METAMOD
9.12 #include <ISmmPlugin.h>
9.13 @@ -225,6 +228,9 @@
9.14 #if defined SMEXT_ENABLE_TIMERSYS
9.15 extern ITimerSystem *timersys;
9.16 #endif
9.17 +#if defined SMEXT_ENABLE_ADTFACTORY
9.18 +extern IADTFactory *adtfactory;
9.19 +#endif
9.20
9.21 #if defined SMEXT_CONF_METAMOD
9.22 PLUGIN_GLOBALVARS();