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);
91 /** BoolSet is a utility class designed to hold eight bools in a bitmask.
92 * Use BoolSet::Set and BoolSet::Get to set and get bools in the bitmask,
93 * and Unset and Invert for special operations upon them.
101 /** The default constructor initializes the BoolSet to all values unset.
105 /** This constructor copies the default bitmask from a char
107 BoolSet(char bitmask);
109 /** The Set method sets one bool in the set.
111 * @param number The number of the item to set. This must be between 0 and 7.
113 void Set(int number);
115 /** The Get method returns the value of one bool in the set
117 * @param number The number of the item to retrieve. This must be between 0 and 7.
119 * @return True if the item is set, false if it is unset.
121 bool Get(int number);
123 /** The Unset method unsets one value in the set
125 * @param number The number of the item to set. This must be between 0 and 7.
127 void Unset(int number);
129 /** The Unset method inverts (flips) one value in the set
131 * @param number The number of the item to invert. This must be between 0 and 7.
133 void Invert(int number);
135 /** Compare two BoolSets
137 bool operator==(BoolSet other);
139 /** OR two BoolSets together
141 BoolSet operator|(BoolSet other);
143 /** AND two BoolSets together
145 BoolSet operator&(BoolSet other);
147 /** Assign one BoolSet to another
149 bool operator=(BoolSet other);