From 4e2ca31cf5fc874ab928dc4d3735f4345a910d0d Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 13 Feb 2016 14:16:29 -0500 Subject: Rewrite access path system to be simplier and use recursion Show where access is "from" in chanserv/status --- include/access.h | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'include') diff --git a/include/access.h b/include/access.h index c77d9aa29..6f0124928 100644 --- a/include/access.h +++ b/include/access.h @@ -78,12 +78,7 @@ class CoreExport ChanAccess : public Serializable Serialize::Reference nc; public: - typedef std::multimap Set; - /* shows the 'path' taken to determine if an access entry matches a user - * .first are access entries checked - * .second are access entries which match - */ - typedef std::pair Path; + typedef std::vector Path; /* The provider that created this access entry */ AccessProvider *provider; @@ -103,12 +98,14 @@ class CoreExport ChanAccess : public Serializable void Serialize(Serialize::Data &data) const anope_override; static Serializable* Unserialize(Serializable *obj, Serialize::Data &); + static const unsigned int MAX_DEPTH = 4; + /** Check if this access entry matches the given user or account * @param u The user * @param nc The account - * @param p The path to the access object which matches will be put here + * @param next Next channel to check if any */ - virtual bool Matches(const User *u, const NickCore *nc, Path &p) const; + virtual bool Matches(const User *u, const NickCore *nc, ChannelInfo* &next) const; /** Check if this access entry has the given privilege. * @param name The privilege name @@ -136,13 +133,13 @@ class CoreExport ChanAccess : public Serializable /* A group of access entries. This is used commonly, for example with ChannelInfo::AccessFor, * to show what access a user has on a channel because users can match multiple access entries. */ -class CoreExport AccessGroup : public std::vector +class CoreExport AccessGroup { public: + /* access entries + paths */ + std::vector paths; /* Channel these access entries are on */ const ChannelInfo *ci; - /* Path from these entries to other entries that they depend on */ - ChanAccess::Path path; /* Account these entries affect, if any */ const NickCore *nc; /* super_admin always gets all privs. founder is a special case where ci->founder == nc */ @@ -170,6 +167,8 @@ class CoreExport AccessGroup : public std::vector bool operator<(const AccessGroup &other) const; bool operator>=(const AccessGroup &other) const; bool operator<=(const AccessGroup &other) const; + + inline bool empty() const { return paths.empty(); } }; #endif -- cgit