From: brain Date: Wed, 31 Oct 2007 19:03:28 +0000 (+0000) Subject: Add XLineFactory stuff. X-Git-Tag: v2.0.23~4267 X-Git-Url: https://git.netwichtig.de/gitweb/?a=commitdiff_plain;h=3cf7620e916d1dc943151117eb508ea459fe4fc8;p=user%2Fhenk%2Fcode%2Finspircd.git 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 --- 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 active_lines; + std::map line_factory; + public: std::map > 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