1 #ifndef _INCLUDE_SOURCEMOD_ADT_FACTORY_H_
2 #define _INCLUDE_SOURCEMOD_ADT_FACTORY_H_
6 #define SMINTERFACE_ADTFACTORY_NAME "IADTFactory"
7 #define SMINTERFACE_ADTFACTORY_VERSION 2
11 * @brief Creates abstract data types.
17 * @brief A "Trie" data type.
23 * @brief Inserts a key/value pair.
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.
29 virtual bool Insert(const char *key, void *value) =0;
32 * @brief Retrieves the value of a key.
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.
38 virtual bool Retrieve(const char *key, void **value) =0;
41 * @brief Deletes a key.
43 * @param key Key string (null terminated).
44 * @return True on success, false if key was not found.
46 virtual bool Delete(const char *key) =0;
49 * @brief Flushes the entire trie of all keys.
51 virtual void Clear() =0;
54 * @brief Destroys the IBasicTrie object and frees all associated
57 virtual void Destroy() =0;
60 * @brief Inserts a key/value pair, replacing an old inserted
61 * value if it already exists.
63 * @param key Key string (null terminated).
64 * @param value Value pointer (may be anything).
65 * @return True on success, false on failure.
67 virtual bool Replace(const char *key, void *value) =0;
70 class IADTFactory : public SMInterface
74 * @brief Creates a basic Trie object.
76 * @return A new IBasicTrie object which must be destroyed
77 * via IBasicTrie::Destroy().
79 virtual IBasicTrie *CreateBasicTrie() =0;
83 #endif //_INCLUDE_SOURCEMOD_ADT_FACTORY_H_