]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - include/modules.h
More stuff for allowing hostnames in <bind> and <link> again - note there is a FIXME...
[user/henk/code/inspircd.git] / include / modules.h
index f15341e017baa3c53e2a2fb6addfd5f140a24f2b..d303f7c727b136064f64eaba8435d9cf4b3f058d 100644 (file)
@@ -78,6 +78,9 @@ enum TargetTypeFlags {
 class Server;
 class ServerConfig;
 
+// Forward-delacare module for ModuleMessage etc
+class Module;
+
 /** Low level definition of a FileReader classes file cache area
  */
 typedef std::deque<std::string> file_cache;
@@ -88,6 +91,10 @@ typedef file_cache string_list;
 typedef std::deque<userrec*> chanuserlist;
 
 
+/** Holds a list of 'published features' for modules.
+ */
+typedef std::map<std::string,Module*> featurelist;
+
 /**
  * This #define allows us to call a method in all
  * loaded modules in a readable simple way, e.g.:
@@ -164,9 +171,6 @@ class Admin : public classbase
         Admin(std::string name, std::string email, std::string nick);
 };
 
-// Forward-delacare module for ModuleMessage etc
-class Module;
-
 /** The ModuleMessage class is the base class of Request and Event
  * This class is used to represent a basic data structure which is passed
  * between modules for safe inter-module communications.
@@ -190,7 +194,7 @@ class Request : public ModuleMessage
  protected:
        /** This member holds a pointer to arbitary data set by the emitter of the message
         */
-       char* data;
+       void* data;
        /** This is a pointer to the sender of the message, which can be used to
         * directly trigger events, or to create a reply.
         */
@@ -201,7 +205,7 @@ class Request : public ModuleMessage
  public:
        /** Create a new Request
         */
-       Request(char* anydata, Module* src, Module* dst);
+       Request(void* anydata, Module* src, Module* dst);
        /** Fetch the Request data
         */
        char* GetData();
@@ -230,7 +234,7 @@ class Event : public ModuleMessage
  protected:
        /** This member holds a pointer to arbitary data set by the emitter of the message
         */
-       char* data;
+       void* data;
        /** This is a pointer to the sender of the message, which can be used to
         * directly trigger events, or to create a reply.
         */
@@ -243,7 +247,7 @@ class Event : public ModuleMessage
  public:
        /** Create a new Event
         */
-       Event(char* anydata, Module* src, const std::string &eventid);
+       Event(void* anydata, Module* src, const std::string &eventid);
        /** Get the Event data
         */
        char* GetData();
@@ -1302,6 +1306,43 @@ class Server : public classbase
         */
        std::string GetVersion();
 
+       /** Publish a 'feature'.
+        * There are two ways for a module to find another module it depends on.
+        * Either by name, using Server::FindModule, or by feature, using this
+        * function. A feature is an arbitary string which identifies something this
+        * module can do. For example, if your module provides SSL support, but other
+        * modules provide SSL support too, all the modules supporting SSL should
+        * publish an identical 'SSL' feature. This way, any module requiring use
+        * of SSL functions can just look up the 'SSL' feature using FindFeature,
+        * then use the module pointer they are given.
+        * @param FeatureName The case sensitive feature name to make available
+        * @param Mod a pointer to your module class
+        * @returns True on success, false if the feature is already published by
+        * another module.
+        */
+       bool PublishFeature(std::string FeatureName, Module* Mod);
+
+       /** Unpublish a 'feature'.
+        * When your module exits, it must call this method for every feature it
+        * is providing so that the feature table is cleaned up.
+        * @param FeatureName the feature to remove
+        */
+       bool UnpublishFeature(std::string FeatureName);
+
+       /** Find a 'feature'.
+        * There are two ways for a module to find another module it depends on.
+        * Either by name, using Server::FindModule, or by feature, using the
+        * Server::PublishFeature method. A feature is an arbitary string which
+        * identifies something this module can do. For example, if your module
+        * provides SSL support, but other modules provide SSL support too, all
+        * the modules supporting SSL should publish an identical 'SSL' feature.
+        * To find a module capable of providing the feature you want, simply
+        * call this method with the feature name you are looking for.
+        * @param FeatureName The feature name you wish to obtain the module for
+        * @returns A pointer to a valid module class on success, NULL on failure.
+        */
+       Module* FindFeature(std::string FeatureName);
+
        /** Writes a log string.
         * This method writes a line of text to the log. If the level given is lower than the
         * level given in the configuration, this command has no effect.