2 Defines the base classes used by InspIRCd
8 #include "inspircd_config.h"
13 typedef void* VoidPointer;
15 /** The base class for all inspircd classes
20 /** Time that the object was instantiated (used for TS calculation etc)
25 * Sets the object's time
27 classbase() { age = time(NULL); }
31 /** class Extensible is the parent class of many classes such as userrec and chanrec.
32 * class Extensible implements a system which allows modules to 'extend' the class by attaching data within
33 * a map associated with the object. In this way modules can store their own custom information within user
34 * objects, channel objects and server objects, without breaking other modules (this is more sensible than using
35 * a flags variable, and each module defining bits within the flag as 'theirs' as it is less prone to conflict and
36 * supports arbitary data storage).
38 class Extensible : public classbase
40 /** Private data store
42 std::map<std::string,char*> Extension_Items;
46 /** Extend an Extensible class.
47 * You must provide a key to store the data as, and a void* to the data (typedef VoidPointer)
48 * The data will be inserted into the map. If the data already exists, you may not insert it
49 * twice, Extensible::Extend will return false in this case.
50 * On successful extension, Extend returns true.
52 bool Extend(std::string key, char* p);
54 /** Shrink an Extensible class.
55 * You must provide a key name. The given key name will be removed from the classes data. If
56 * you provide a nonexistent key (case is important) then the function will return false.
57 * Returns true on success.
59 bool Shrink(std::string key);
61 /** Get an extension item.
62 * You must provide a key name, which is case sensitive. If you provide a non-existent key name,
63 * the function returns NULL, otherwise a pointer to the item referenced by the key is returned.
65 char* GetExt(std::string key);