00001 /** 00002 * vim: set ts=4 : 00003 * ============================================================================= 00004 * SourceMod 00005 * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. 00006 * ============================================================================= 00007 * 00008 * This program is free software; you can redistribute it and/or modify it under 00009 * the terms of the GNU General Public License, version 3.0, as published by the 00010 * Free Software Foundation. 00011 * 00012 * This program is distributed in the hope that it will be useful, but WITHOUT 00013 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00014 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 00015 * details. 00016 * 00017 * You should have received a copy of the GNU General Public License along with 00018 * this program. If not, see <http://www.gnu.org/licenses/>. 00019 * 00020 * As a special exception, AlliedModders LLC gives you permission to link the 00021 * code of this program (as well as its derivative works) to "Half-Life 2," the 00022 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software 00023 * by the Valve Corporation. You must obey the GNU General Public License in 00024 * all respects for all other code used. Additionally, AlliedModders LLC grants 00025 * this exception to all derivative works. AlliedModders LLC defines further 00026 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), 00027 * or <http://www.sourcemod.net/license.php>. 00028 * 00029 * Version: $Id: IADTFactory.h 1964 2008-03-27 04:54:56Z damagedsoul $ 00030 */ 00031 00032 #ifndef _INCLUDE_SOURCEMOD_ADT_FACTORY_H_ 00033 #define _INCLUDE_SOURCEMOD_ADT_FACTORY_H_ 00034 00035 #include <IShareSys.h> 00036 00037 #define SMINTERFACE_ADTFACTORY_NAME "IADTFactory" 00038 #define SMINTERFACE_ADTFACTORY_VERSION 2 00039 00040 /** 00041 * @file IADTFactory.h 00042 * @brief Creates abstract data types. 00043 */ 00044 00045 namespace SourceMod 00046 { 00047 /** 00048 * @brief A "Trie" data type. 00049 */ 00050 class IBasicTrie 00051 { 00052 public: 00053 /** 00054 * @brief Inserts a key/value pair. 00055 * 00056 * @param key Key string (null terminated). 00057 * @param value Value pointer (may be anything). 00058 * @return True on success, false if key already exists. 00059 */ 00060 virtual bool Insert(const char *key, void *value) =0; 00061 00062 /** 00063 * @brief Retrieves the value of a key. 00064 * 00065 * @param key Key string (null terminated). 00066 * @param value Optional pointer to store value pointer. 00067 * @return True on success, false if key was not found. 00068 */ 00069 virtual bool Retrieve(const char *key, void **value) =0; 00070 00071 /** 00072 * @brief Deletes a key. 00073 * 00074 * @param key Key string (null terminated). 00075 * @return True on success, false if key was not found. 00076 */ 00077 virtual bool Delete(const char *key) =0; 00078 00079 /** 00080 * @brief Flushes the entire trie of all keys. 00081 */ 00082 virtual void Clear() =0; 00083 00084 /** 00085 * @brief Destroys the IBasicTrie object and frees all associated 00086 * memory. 00087 */ 00088 virtual void Destroy() =0; 00089 00090 /** 00091 * @brief Inserts a key/value pair, replacing an old inserted 00092 * value if it already exists. 00093 * 00094 * @param key Key string (null terminated). 00095 * @param value Value pointer (may be anything). 00096 * @return True on success, false on failure. 00097 */ 00098 virtual bool Replace(const char *key, void *value) =0; 00099 }; 00100 00101 class IADTFactory : public SMInterface 00102 { 00103 public: 00104 /** 00105 * @brief Creates a basic Trie object. 00106 * 00107 * @return A new IBasicTrie object which must be destroyed 00108 * via IBasicTrie::Destroy(). 00109 */ 00110 virtual IBasicTrie *CreateBasicTrie() =0; 00111 }; 00112 } 00113 00114 #endif //_INCLUDE_SOURCEMOD_ADT_FACTORY_H_
1.5.1