summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2004-04-29 15:23:20 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2004-04-29 15:23:20 +0000
commit71247cc2f120b67302271937b887de95c8bcc623 (patch)
treedb20427b07c3c7caa310887c5ab00aaf99409f1d /include
parent71e6de4b88c3d51bfa59fed44049a4d1ea6d26a1 (diff)
Added 'Extensible' class which allows modules to store custom data in objects
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@750 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'include')
-rw-r--r--include/base.h26
-rw-r--r--include/channels.h2
-rw-r--r--include/connection.h2
3 files changed, 23 insertions, 7 deletions
diff --git a/include/base.h b/include/base.h
index b0e264bac..dbe4588e9 100644
--- a/include/base.h
+++ b/include/base.h
@@ -1,15 +1,17 @@
/*
-
-
+Defines the base classes used by InspIRCd
*/
-#include "inspircd_config.h"
-#include <time.h>
-
#ifndef __BASE_H__
#define __BASE_H__
+#include "inspircd_config.h"
+#include <time.h>
+#include <map>
+#include <string>
+typedef void* VoidPointer;
+
/** The base class for all inspircd classes
*/
class classbase
@@ -26,5 +28,19 @@ class classbase
~classbase() { }
};
+/** class Extensible is the parent class of many classes such as userrec and chanrec.
+ * class Extensible implements a system which allows modules to 'extend' the class by attaching data within
+ * a map associated with the object. In this way modules can store their own custom information within user
+ * objects, channel objects and server objects, without breaking other modules (this is more sensible than using
+ * a flags variable, and each module defining bits within the flag as 'theirs' as it is less prone to conflict and
+ * supports arbitary data storage).
+ */
+class Extensible : public classbase
+{
+ /** Private data store
+ */
+ std::map<std::string,VoidPointer> Extension_Items;
+};
+
#endif
diff --git a/include/channels.h b/include/channels.h
index de629c399..c0df69513 100644
--- a/include/channels.h
+++ b/include/channels.h
@@ -80,7 +80,7 @@ typedef std::vector<InviteItem> InviteList;
* This class represents a channel, and contains its name, modes, time created, topic, topic set time,
* etc, and an instance of the BanList type.
*/
-class chanrec : public classbase
+class chanrec : public Extensible
{
public:
/** The channels name.
diff --git a/include/connection.h b/include/connection.h
index bb402b5d2..eaa995f89 100644
--- a/include/connection.h
+++ b/include/connection.h
@@ -158,7 +158,7 @@ class packet : public classbase
/** Please note: classes serverrec and userrec both inherit from class connection.
*/
-class connection : public classbase
+class connection : public Extensible
{
public:
/** File descriptor of the connection