1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * Inspire is copyright (C) 2002-2004 ChatSpike-Dev.
7 * <brain@chatspike.net>
8 * <Craig@chatspike.net>
10 * Written by Craig Edwards, Craig McLure, and others.
11 * This program is free but copyrighted software; see
12 * the file COPYING for details.
14 * ---------------------------------------------------
20 #include "inspircd_config.h"
25 typedef void* VoidPointer;
27 /** The base class for all inspircd classes
32 /** Time that the object was instantiated (used for TS calculation etc)
37 * Sets the object's time
39 classbase() { age = time(NULL); }
43 /** class Extensible is the parent class of many classes such as userrec and chanrec.
44 * class Extensible implements a system which allows modules to 'extend' the class by attaching data within
45 * a map associated with the object. In this way modules can store their own custom information within user
46 * objects, channel objects and server objects, without breaking other modules (this is more sensible than using
47 * a flags variable, and each module defining bits within the flag as 'theirs' as it is less prone to conflict and
48 * supports arbitary data storage).
50 class Extensible : public classbase
52 /** Private data store
54 std::map<std::string,char*> Extension_Items;
58 /** Extend an Extensible class.
60 * @param key The key parameter is an arbitary string which identifies the extension data
61 * @param p This parameter is a pointer to any data you wish to associate with the object
63 * You must provide a key to store the data as, and a void* to the data (typedef VoidPointer)
64 * The data will be inserted into the map. If the data already exists, you may not insert it
65 * twice, Extensible::Extend will return false in this case.
67 * @return Returns true on success, false if otherwise
69 bool Extend(std::string key, char* p);
71 /** Shrink an Extensible class.
73 * @param key The key parameter is an arbitary string which identifies the extension data
75 * You must provide a key name. The given key name will be removed from the classes data. If
76 * you provide a nonexistent key (case is important) then the function will return false.
78 * @return Returns true on success.
80 bool Shrink(std::string key);
82 /** Get an extension item.
84 * @param key The key parameter is an arbitary string which identifies the extension data
86 * @return If you provide a non-existent key name, the function returns NULL, otherwise a pointer to the item referenced by the key is returned.
88 char* GetExt(std::string key);