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.
59 * You must provide a key to store the data as, and a void* to the data (typedef VoidPointer)
60 * The data will be inserted into the map. If the data already exists, you may not insert it
61 * twice, Extensible::Extend will return false in this case.
62 * On successful extension, Extend returns true.
64 bool Extend(std::string key, char* p);
66 /** Shrink an Extensible class.
67 * You must provide a key name. The given key name will be removed from the classes data. If
68 * you provide a nonexistent key (case is important) then the function will return false.
69 * Returns true on success.
71 bool Shrink(std::string key);
73 /** Get an extension item.
74 * You must provide a key name, which is case sensitive. If you provide a non-existent key name,
75 * the function returns NULL, otherwise a pointer to the item referenced by the key is returned.
77 char* GetExt(std::string key);