public/IADTFactory.h
author Scott Ehlert <ds@alliedmods.net>
Sun Jul 15 08:00:26 2007 +0000 (2007-07-15)
changeset 1116 40cc5e9f0f1b
parent 1057 de136462a416
child 1226 478550a4d5ec
permissions -rw-r--r--
Removed strange debugging code
     1 #ifndef _INCLUDE_SOURCEMOD_ADT_FACTORY_H_
     2 #define _INCLUDE_SOURCEMOD_ADT_FACTORY_H_
     3 
     4 #include <IShareSys.h>
     5 
     6 #define SMINTERFACE_ADTFACTORY_NAME		"IADTFactory"
     7 #define SMINTERFACE_ADTFACTORY_VERSION	2
     8 
     9 /**
    10 * @file IADTFactory.h
    11 * @brief Creates abstract data types.
    12 */
    13 
    14 namespace SourceMod
    15 {
    16 	/**
    17 	 * @brief A "Trie" data type.
    18 	 */
    19 	class IBasicTrie
    20 	{
    21 	public:
    22 		/**
    23 		 * @brief Inserts a key/value pair.
    24 		 *
    25 		 * @param key		Key string (null terminated).
    26 		 * @param value		Value pointer (may be anything).
    27 		 * @return			True on success, false if key already exists.
    28 		 */
    29 		virtual bool Insert(const char *key, void *value) =0;
    30 
    31 		/**
    32 		 * @brief Retrieves the value of a key.
    33 		 *
    34 		 * @param key		Key string (null terminated).
    35 		 * @param value		Optional pointer to store value pointer.
    36 		 * @return			True on success, false if key was not found.
    37 		 */
    38 		virtual bool Retrieve(const char *key, void **value) =0;
    39 
    40 		/**
    41 		 * @brief Deletes a key.
    42 		 *
    43 		 * @param key		Key string (null terminated).
    44 		 * @return			True on success, false if key was not found.
    45 		 */
    46 		virtual bool Delete(const char *key) =0;
    47 
    48 		/**
    49 		 * @brief Flushes the entire trie of all keys.
    50 		 */
    51 		virtual void Clear() =0;
    52 
    53 		/**
    54 		 * @brief Destroys the IBasicTrie object and frees all associated 
    55 		 * memory.
    56 		 */
    57 		virtual void Destroy() =0;
    58 
    59 		/**
    60 		 * @brief Inserts a key/value pair, replacing an old inserted
    61 		 * value if it already exists.
    62 		 *
    63 		 * @param key		Key string (null terminated).
    64 		 * @param value		Value pointer (may be anything).
    65 		 * @return			True on success, false on failure.
    66 		 */
    67 		virtual bool Replace(const char *key, void *value) =0;
    68 	};
    69 
    70 	class IADTFactory : public SMInterface
    71 	{
    72 	public:
    73 		/**
    74 		 * @brief Creates a basic Trie object.
    75 		 *
    76 		 * @return			A new IBasicTrie object which must be destroyed
    77 		 *					via IBasicTrie::Destroy().
    78 		 */
    79 		virtual IBasicTrie *CreateBasicTrie() =0;
    80 	};
    81 }
    82 
    83 #endif //_INCLUDE_SOURCEMOD_ADT_FACTORY_H_