summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-11-15 18:26:53 +0000
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-11-15 18:26:53 +0000
commitfb3964d5c007900061e86e392ceb786bd47260c0 (patch)
tree41ff940cce47b6d8ba9aef701205dd0ea6707c6f /include
parent8ab1381e8d277152d99a72f33f3d1c0564060fee (diff)
Add Inspircd::AddServices
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@12135 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'include')
-rw-r--r--include/base.h35
-rw-r--r--include/ctables.h11
-rw-r--r--include/extensible.h4
-rw-r--r--include/inspircd.h11
-rw-r--r--include/mode.h8
5 files changed, 47 insertions, 22 deletions
diff --git a/include/base.h b/include/base.h
index bc096b85b..8324d6347 100644
--- a/include/base.h
+++ b/include/base.h
@@ -36,8 +36,6 @@ class CoreExport classbase
/**
* Called just prior to destruction via cull list.
- *
- * @return true to allow the delete, or false to halt the delete
*/
virtual CullResult cull();
virtual ~classbase();
@@ -93,6 +91,8 @@ class CoreExport refcountbase
/** Base class for use count tracking. Uses reference<>, but does not
* cause object deletion when the last user is removed.
+ *
+ * Safe for use as a second parent class; will not add a second vtable.
*/
class CoreExport usecountbase
{
@@ -197,4 +197,35 @@ class CoreExport ModuleException : public CoreException
typedef const reference<Module> ModuleRef;
+enum ServiceType {
+ /** is a Command */
+ SERVICE_COMMAND,
+ /** is a channel ModeHandler */
+ SERVICE_CMODE,
+ /** is a user ModeHandler */
+ SERVICE_UMODE,
+ /** is a metadata descriptor */
+ SERVICE_METADATA,
+ /** is a data processing provider (MD5, SQL) */
+ SERVICE_DATA,
+ /** is an I/O hook provider (SSL) */
+ SERVICE_IOHOOK
+};
+
+/** A structure defining something that a module can provide */
+class CoreExport providerbase : public classbase
+{
+ public:
+ /** Module that is providing this service */
+ ModuleRef creator;
+ /** Name of the service being provided */
+ const std::string name;
+ /** Type of service (must match object type) */
+ const ServiceType service;
+ providerbase(Module* Creator, const std::string& Name, ServiceType Type)
+ : creator(Creator), name(Name), service(Type) {}
+ virtual ~providerbase();
+};
+
+
#endif
diff --git a/include/ctables.h b/include/ctables.h
index 68244932d..991ad1cc2 100644
--- a/include/ctables.h
+++ b/include/ctables.h
@@ -85,16 +85,9 @@ struct RouteDescriptor
/** A structure that defines a command. Every command available
* in InspIRCd must be defined as derived from Command.
*/
-class CoreExport Command : public classbase
+class CoreExport Command : public providerbase
{
public:
- /** Command name
- */
- const std::string command;
-
- /** Creator module - never NULL */
- ModuleRef creator;
-
/** User flags needed to execute the command or 0
*/
char flags_needed;
@@ -151,7 +144,7 @@ class CoreExport Command : public classbase
* NICK, optionally PASS, and been resolved).
*/
Command(Module* me, const std::string &cmd, int minpara = 0, int maxpara = 0) :
- command(cmd), creator(me), flags_needed(0), min_params(minpara), max_params(maxpara),
+ providerbase(me, cmd, SERVICE_COMMAND), flags_needed(0), min_params(minpara), max_params(maxpara),
use_count(0), total_bytes(0), disabled(false), works_before_reg(false), Penalty(1)
{
}
diff --git a/include/extensible.h b/include/extensible.h
index 487b67408..ae78c0a0d 100644
--- a/include/extensible.h
+++ b/include/extensible.h
@@ -12,11 +12,9 @@ enum SerializeFormat
/** Class represnting an extension of some object
*/
-class CoreExport ExtensionItem : public usecountbase
+class CoreExport ExtensionItem : public providerbase, public usecountbase
{
public:
- const std::string key;
- ModuleRef owner;
ExtensionItem(const std::string& key, Module* owner);
virtual ~ExtensionItem();
/** Serialize this item into a string
diff --git a/include/inspircd.h b/include/inspircd.h
index 0bbf3fb03..52035ce49 100644
--- a/include/inspircd.h
+++ b/include/inspircd.h
@@ -594,6 +594,15 @@ class CoreExport InspIRCd
*/
bool AddResolver(Resolver* r, bool cached);
+ /** Register a service provided by a module */
+ void AddService(providerbase&);
+
+ inline void AddServices(providerbase** list, int count)
+ {
+ for(int i=0; i < count; i++)
+ AddService(*list[i]);
+ }
+
/** Add a command to this server's command parser
* @param f A Command command handler object to add
* @throw ModuleException Will throw ModuleExcption if the command already exists
@@ -814,7 +823,7 @@ class CommandModule : public Module
Version GetVersion()
{
- return Version(cmd.command, VF_VENDOR|VF_CORE);
+ return Version(cmd.name, VF_VENDOR|VF_CORE);
}
};
diff --git a/include/mode.h b/include/mode.h
index a633cebca..f2b58a309 100644
--- a/include/mode.h
+++ b/include/mode.h
@@ -90,7 +90,7 @@ enum ParamSpec
* mode is expected to have a parameter, then this is
* equivalent to returning MODEACTION_DENY.
*/
-class CoreExport ModeHandler : public classbase
+class CoreExport ModeHandler : public providerbase
{
protected:
/**
@@ -145,12 +145,6 @@ class CoreExport ModeHandler : public classbase
int levelrequired;
public:
- /** Module that created this mode. NULL for core modes */
- ModuleRef creator;
- /** Long-form name
- */
- const std::string name;
-
/**
* The constructor for ModeHandler initalizes the mode handler.
* The constructor of any class you derive from ModeHandler should