]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/base.h
Added 'Extensible' class which allows modules to store custom data in objects
[user/henk/code/inspircd.git] / include / base.h
1 /*
2 Defines the base classes used by InspIRCd
3 */
4
5 #ifndef __BASE_H__ 
6 #define __BASE_H__ 
7
8 #include "inspircd_config.h" 
9 #include <time.h>
10 #include <map>
11 #include <string>
12
13 typedef void* VoidPointer;
14  
15 /** The base class for all inspircd classes
16 */ 
17 class classbase
18 {
19  public:
20         /** Time that the object was instantiated (used for TS calculation etc)
21         */
22         time_t age;
23
24         /** Constructor,
25          * Sets the object's time
26          */
27         classbase() { age = time(NULL); }
28         ~classbase() { }
29 };
30
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).
37  */
38 class Extensible : public classbase
39 {
40         /** Private data store
41          */
42         std::map<std::string,VoidPointer> Extension_Items;
43 };
44
45 #endif
46