summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorom <om@e03df62e-2008-0410-955e-edbf42e46eb7>2006-07-23 15:32:22 +0000
committerom <om@e03df62e-2008-0410-955e-edbf42e46eb7>2006-07-23 15:32:22 +0000
commit4d0cd408dfabdcd0b95b5305e47a594ff958c74a (patch)
tree16f9248340d8e5d4b2c714a477d2d52fd5b583e3 /include
parent2a291c331fba316c3510b6dbaf973202bb99a49e (diff)
Add an ID field to Request and a GetId() method, takes const char* and returns it - Added new constructor to use it, all modules using ID should convert to the 'new' way of doing Requests, data is now theoretically depreceiated
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4529 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'include')
-rw-r--r--include/modules.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/include/modules.h b/include/modules.h
index 18a4a6dbb..fdc1ac178 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -193,6 +193,11 @@ class Request : public ModuleMessage
/** This member holds a pointer to arbitary data set by the emitter of the message
*/
char* data;
+ /** This should be a null-terminated string identifying the type of request,
+ * all modules should define this and use it to determine the nature of the
+ * request before they attempt to cast the Request in any way.
+ */
+ const char* id;
/** This is a pointer to the sender of the message, which can be used to
* directly trigger events, or to create a reply.
*/
@@ -202,11 +207,28 @@ class Request : public ModuleMessage
Module* dest;
public:
/** Create a new Request
+ * This is for the 'old' way of casting whatever the data is
+ * to char* and hoping you get the right thing at the other end.
+ * This is slowly being depreciated in favor of the 'new' way.
*/
Request(char* anydata, Module* src, Module* dst);
+ /** Create a new Request
+ * This is for the 'new' way of defining a subclass
+ * of Request and defining it in a common header,
+ * passing an object of your Request subclass through
+ * as a Request* and using the ID string to determine
+ * what to cast it back to and the other end. This is
+ * much safer as there are no casts not confirmed by
+ * the ID string, and all casts are child->parent and
+ * can be checked at runtime with dynamic_cast<>()
+ */
+ Request(Module* src, Module* dst, const char* idstr);
/** Fetch the Request data
*/
char* GetData();
+ /** Fetch the ID string
+ */
+ const char* GetId();
/** Fetch the request source
*/
Module* GetSource();