]> git.ipfire.org Git - thirdparty/squid.git/blame - src/acl/Tree.h
SourceFormat Enforcement
[thirdparty/squid.git] / src / acl / Tree.h
CommitLineData
bbc27441 1/*
bde978a6 2 * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
bbc27441
AJ
3 *
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
7 */
8
6f58d7d7
AR
9#ifndef SQUID_ACL_TREE_H
10#define SQUID_ACL_TREE_H
11
12#include "acl/BoolOps.h"
8966008b 13#include "SBufList.h"
6f58d7d7 14
e936c41c
AR
15namespace Acl
16{
6f58d7d7
AR
17
18/// An ORed set of rules at the top of the ACL expression tree, providing two
19/// unique properties: cbdata protection and optional rule actions.
20class Tree: public OrNode
21{
5c2f68b7
AJ
22 // XXX: We should use refcounting instead, but it requires making ACLs
23 // refcounted as well. Otherwise, async lookups will reach deleted ACLs.
24 CBDATA_CLASS(Tree);
25
6f58d7d7
AR
26public:
27 /// dumps <name, action, rule, new line> tuples
28 /// action.kind is mapped to a string using the supplied conversion table
29 typedef const char **ActionToString;
8966008b 30 SBufList treeDump(const char *name, const ActionToString &convert) const;
6f58d7d7
AR
31
32 /// Returns the corresponding action after a successful tree match.
33 allow_t winningAction() const;
34
35 /// what action to use if no nodes matched
36 allow_t lastAction() const;
37
38 /// appends and takes control over the rule with a given action
39 void add(ACL *rule, const allow_t &action);
40 void add(ACL *rule); ///< same as InnerNode::add()
41
42protected:
43 allow_t actionAt(const Nodes::size_type pos) const;
44
45 /// if not empty, contains actions corresponding to InnerNode::nodes
46 typedef std::vector<allow_t> Actions;
47 Actions actions;
6f58d7d7
AR
48};
49
6f58d7d7
AR
50} // namespace Acl
51
52#endif /* SQUID_ACL_TREE_H */
f53969cc 53