From a89b0ed42d90f714e4fa01265f5cd4995686ba82 Mon Sep 17 00:00:00 2001 From: brain Date: Fri, 30 Apr 2004 12:26:20 +0000 Subject: Added Extensible classes git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@754 e03df62e-2008-0410-955e-edbf42e46eb7 --- include/base.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'include') diff --git a/include/base.h b/include/base.h index dbe4588e9..e755fc951 100644 --- a/include/base.h +++ b/include/base.h @@ -40,6 +40,29 @@ class Extensible : public classbase /** Private data store */ std::map Extension_Items; + +public: + + /** Extend an Extensible class. + * You must provide a key to store the data as, and a void* to the data (typedef VoidPointer) + * The data will be inserted into the map. If the data already exists, you may not insert it + * twice, Extensible::Extend will return false in this case. + * On successful extension, Extend returns true. + */ + bool Extend(std::string key, VoidPointer p); + + /** Shrink an Extensible class. + * You must provide a key name. The given key name will be removed from the classes data. If + * you provide a nonexistent key (case is important) then the function will return false. + * Returns true on success. + */ + bool Shrink(std::string key); + + /** Get an extension item. + * You must provide a key name, which is case sensitive. If you provide a non-existent key name, + * the function returns NULL, otherwise a pointer to the item referenced by the key is returned. + */ + VoidPointer GetExt(std::string key); }; #endif -- cgit v1.2.3