- added IADTFactory for sdktools

- updated sample extension and sdktools sdks

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401034
This commit is contained in:
David Anderson
2007-06-30 16:43:11 +00:00
parent 761890b470
commit b649d60cb0
9 changed files with 229 additions and 0 deletions
+60
View File
@@ -0,0 +1,60 @@
#include "ADTFactory.h"
#include "sm_globals.h"
#include "ShareSys.h"
ADTFactory g_AdtFactory;
const char *ADTFactory::GetInterfaceName()
{
return SMINTERFACE_ADTFACTORY_NAME;
}
unsigned int ADTFactory::GetInterfaceVersion()
{
return SMINTERFACE_ADTFACTORY_VERSION;
}
void ADTFactory::OnSourceModAllInitialized()
{
g_ShareSys.AddInterface(NULL, this);
}
IBasicTrie *ADTFactory::CreateBasicTrie()
{
return new BaseTrie();
}
BaseTrie::BaseTrie()
{
m_pTrie = sm_trie_create();
}
BaseTrie::~BaseTrie()
{
sm_trie_destroy(m_pTrie);
}
bool BaseTrie::Insert(const char *key, void *value)
{
return sm_trie_insert(m_pTrie, key, value);
}
bool BaseTrie::Retrieve(const char *key, void **value)
{
return sm_trie_retrieve(m_pTrie, key, value);
}
bool BaseTrie::Delete(const char *key)
{
return sm_trie_delete(m_pTrie, key);
}
void BaseTrie::Clear()
{
sm_trie_clear(m_pTrie);
}
void BaseTrie::Destroy()
{
delete this;
}
+33
View File
@@ -0,0 +1,33 @@
#include <IADTFactory.h>
#include "sm_globals.h"
#include "sm_trie.h"
using namespace SourceMod;
class BaseTrie : public IBasicTrie
{
public:
BaseTrie();
virtual ~BaseTrie();
virtual bool Insert(const char *key, void *value);
virtual bool Retrieve(const char *key, void **value);
virtual bool Delete(const char *key);
virtual void Clear();
virtual void Destroy();
private:
Trie *m_pTrie;
};
class ADTFactory :
public SMGlobalClass,
public IADTFactory
{
public: //SMInterface
const char *GetInterfaceName();
unsigned int GetInterfaceVersion();
public: //SMGlobalClass
void OnSourceModAllInitialized();
public: //IADTFactory
IBasicTrie *CreateBasicTrie();
};
+12
View File
@@ -185,6 +185,10 @@
RelativePath="..\AdminCache.cpp"
>
</File>
<File
RelativePath="..\ADTFactory.cpp"
>
</File>
<File
RelativePath="..\CDataPack.cpp"
>
@@ -307,6 +311,10 @@
RelativePath="..\AdminCache.h"
>
</File>
<File
RelativePath="..\ADTFactory.h"
>
</File>
<File
RelativePath="..\CDataPack.h"
>
@@ -452,6 +460,10 @@
RelativePath="..\..\public\IAdminSystem.h"
>
</File>
<File
RelativePath="..\..\public\IADTFactory.h"
>
</File>
<File
RelativePath="..\..\public\IDataPack.h"
>