]> git.ipfire.org Git - thirdparty/squid.git/blob - src/acl/Tree.h
Merged from trunk (r13356).
[thirdparty/squid.git] / src / acl / Tree.h
1 #ifndef SQUID_ACL_TREE_H
2 #define SQUID_ACL_TREE_H
3
4 #include "acl/BoolOps.h"
5 #include "SBufList.h"
6
7 namespace Acl
8 {
9
10 /// An ORed set of rules at the top of the ACL expression tree, providing two
11 /// unique properties: cbdata protection and optional rule actions.
12 class Tree: public OrNode
13 {
14 public:
15 /// dumps <name, action, rule, new line> tuples
16 /// action.kind is mapped to a string using the supplied conversion table
17 typedef const char **ActionToString;
18 SBufList treeDump(const char *name, const ActionToString &convert) const;
19
20 /// Returns the corresponding action after a successful tree match.
21 allow_t winningAction() const;
22
23 /// what action to use if no nodes matched
24 allow_t lastAction() const;
25
26 /// appends and takes control over the rule with a given action
27 void add(ACL *rule, const allow_t &action);
28 void add(ACL *rule); ///< same as InnerNode::add()
29
30 protected:
31 allow_t actionAt(const Nodes::size_type pos) const;
32
33 /// if not empty, contains actions corresponding to InnerNode::nodes
34 typedef std::vector<allow_t> Actions;
35 Actions actions;
36
37 private:
38 // XXX: We should use refcounting instead, but it requires making ACLs
39 // refcounted as well. Otherwise, async lookups will reach deleted ACLs.
40 CBDATA_CLASS2(Tree);
41 };
42
43 } // namespace Acl
44
45 #endif /* SQUID_ACL_TREE_H */