diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-10-31 19:03:28 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-10-31 19:03:28 +0000 |
commit | 3cf7620e916d1dc943151117eb508ea459fe4fc8 (patch) | |
tree | 2f1025931fda7b36279fee985e2f944b34458ad7 /include | |
parent | 98cfe3e3283605dca18e815a8c7ecc5f6b58a913 (diff) |
Add XLineFactory stuff.
The idea is, a module or the core can register a class derived from XLineFactory. This class's job is to handle creation of an 'unknown' xline type given xline-specific mask data
(e.g. "*@host*" or any other such text) and a line type, currently char (i DO plan on changing this!!!). This way, spanningtree and friends can create an xline without knowing
its full details just by passing what all xlines share in common and a bit of semi-opaque metadata.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8436 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'include')
-rw-r--r-- | include/xline.h | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/include/xline.h b/include/xline.h index b8b045fd5..a94161738 100644 --- a/include/xline.h +++ b/include/xline.h @@ -343,6 +343,24 @@ class CoreExport QLine : public XLine char* nick; }; +class XLineFactory +{ + protected: + + const char type; + InspIRCd* ServerInstance; + + public: + + XLineFactory(const char t) : type(t) { } + + virtual const char GetType() { return type; } + + virtual XLine* Generate(time_t set_time, long duration, const char* source, const char* reason, const char* xline_specific_mask) = 0; + + virtual ~XLineFactory() { } +}; + /* Required forward declarations */ class ServerConfig; @@ -371,6 +389,8 @@ class CoreExport XLineManager std::vector<XLine *> active_lines; + std::map<char, XLineFactory*> line_factory; + public: std::map<char, std::map<std::string, XLine *> > lookup_lines; @@ -407,6 +427,26 @@ class CoreExport XLineManager */ bool DelLine(const char* hostmask, char type, bool simulate = false); + /** Registers an xline factory. + * An xline factory is a class which when given a particular xline type, + * will generate a new XLine specialized to that type. For example if you + * pass the XLineFactory that handles glines some data it will return a + * pointer to a GLine, polymorphically represented as XLine. This is used where + * you do not know the full details of the item you wish to create, e.g. in a + * server protocol module like m_spanningtree, when you receive xlines from other + * servers. + */ + bool RegisterFactory(XLineFactory* xlf); + + /** Unregisters an xline factory + */ + bool UnregisterFactory(XLineFactory* xlf); + + /** Get the XLineFactory for a specific type. + * Returns NULL if there is no known handler for this xline type + */ + XLineFactory* GetFactory(const char type); + /** Check if a nickname matches a QLine * @return nick The nick to check against * @return The reason for the line if there is a match, or NULL if there is no match |