core/ADTFactory.cpp
author David Anderson <dvander@alliedmods.net>
Sun Aug 25 12:21:15 2013 -0700 (2013-08-25)
changeset 4079 fc78b3dddc36
parent 3872 4c93f74cae51
permissions -rw-r--r--
Switch ADTFactory/IBasicTrie off KTrie (bug 5884 part 17, r=ds).
     1 /**
     2  * vim: set ts=4 sw=4 tw=99 noet :
     3  * =============================================================================
     4  * SourceMod
     5  * Copyright (C) 2004-2008 AlliedModders LLC.  All rights reserved.
     6  * =============================================================================
     7  *
     8  * This program is free software; you can redistribute it and/or modify it under
     9  * the terms of the GNU General Public License, version 3.0, as published by the
    10  * Free Software Foundation.
    11  * 
    12  * This program is distributed in the hope that it will be useful, but WITHOUT
    13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    14  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
    15  * details.
    16  *
    17  * You should have received a copy of the GNU General Public License along with
    18  * this program.  If not, see <http://www.gnu.org/licenses/>.
    19  *
    20  * As a special exception, AlliedModders LLC gives you permission to link the
    21  * code of this program (as well as its derivative works) to "Half-Life 2," the
    22  * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
    23  * by the Valve Corporation.  You must obey the GNU General Public License in
    24  * all respects for all other code used.  Additionally, AlliedModders LLC grants
    25  * this exception to all derivative works.  AlliedModders LLC defines further
    26  * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
    27  * or <http://www.sourcemod.net/license.php>.
    28  *
    29  * Version: $Id$
    30  */
    31 
    32 #include "ADTFactory.h"
    33 #include "sm_globals.h"
    34 #include "logic_bridge.h"
    35 
    36 ADTFactory g_AdtFactory;
    37 
    38 const char *ADTFactory::GetInterfaceName()
    39 {
    40 	return SMINTERFACE_ADTFACTORY_NAME;
    41 }
    42 
    43 unsigned int ADTFactory::GetInterfaceVersion()
    44 {
    45 	return SMINTERFACE_ADTFACTORY_VERSION;
    46 }
    47 
    48 void ADTFactory::OnSourceModAllInitialized()
    49 {
    50 	sharesys->AddInterface(NULL, this);
    51 }
    52 
    53 IBasicTrie *ADTFactory::CreateBasicTrie()
    54 {
    55 	return new BaseTrie();
    56 }
    57 
    58 BaseTrie::BaseTrie()
    59 {
    60 }
    61 
    62 BaseTrie::~BaseTrie()
    63 {
    64 }
    65 
    66 bool BaseTrie::Insert(const char *key, void *value)
    67 {
    68 	return map_.insert(key, value);
    69 }
    70 
    71 bool BaseTrie::Retrieve(const char *key, void **value)
    72 {
    73 	return map_.retrieve(key, value);
    74 }
    75 
    76 bool BaseTrie::Delete(const char *key)
    77 {
    78 	return map_.remove(key);
    79 }
    80 
    81 void BaseTrie::Clear()
    82 {
    83 	map_.clear();
    84 }
    85 
    86 void BaseTrie::Destroy()
    87 {
    88 	delete this;
    89 }
    90 
    91 bool BaseTrie::Replace(const char *key, void *value)
    92 {
    93 	return map_.replace(key, value);
    94 }