]> git.ipfire.org Git - thirdparty/squid.git/blob - src/acl/InnerNode.h
Source Format Enforcement (#532)
[thirdparty/squid.git] / src / acl / InnerNode.h
1 /*
2 * Copyright (C) 1996-2020 The Squid Software Foundation and contributors
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
9 #ifndef SQUID_ACL_INNER_NODE_H
10 #define SQUID_ACL_INNER_NODE_H
11
12 #include "acl/Acl.h"
13 #include <vector>
14
15 namespace Acl
16 {
17
18 typedef std::vector<ACL*> Nodes; ///< a collection of nodes
19
20 /// An intermediate ACL tree node. Manages a collection of child tree nodes.
21 class InnerNode: public ACL
22 {
23 public:
24 // No ~InnerNode() to delete children. They are aclRegister()ed instead.
25
26 /// Resumes matching (suspended by an async call) at the given position.
27 bool resumeMatchingAt(ACLChecklist *checklist, Acl::Nodes::const_iterator pos) const;
28
29 /// the number of children nodes
30 Nodes::size_type childrenCount() const { return nodes.size(); }
31
32 /* ACL API */
33 virtual void prepareForUse();
34 virtual bool empty() const;
35 virtual SBufList dump() const;
36
37 /// parses one "acl name type acl1 acl2..." line, appending to nodes
38 void lineParse();
39
40 /// appends the node to the collection and takes control over it
41 void add(ACL *node);
42
43 protected:
44 /// checks whether the nodes match, starting with the given one
45 /// kids determine what a match means for their type of intermediate nodes
46 virtual int doMatch(ACLChecklist *checklist, Nodes::const_iterator start) const = 0;
47
48 /* ACL API */
49 virtual int match(ACLChecklist *checklist);
50
51 // XXX: use refcounting instead of raw pointers
52 std::vector<ACL*> nodes; ///< children nodes of this intermediate node
53 };
54
55 } // namespace Acl
56
57 #endif /* SQUID_ACL_INNER_NODE_H */
58