Strategised.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2022 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_ACLSTRATEGISED_H
10#define SQUID_ACLSTRATEGISED_H
11
12#include "acl/Acl.h"
13#include "acl/Data.h"
14#include "acl/FilledChecklist.h"
15#include "acl/Strategy.h"
16
17// XXX: Replace with a much simpler abstract ACL child class without the
18// ACLStrategy parameter (and associated call forwarding). Duplicating key
19// portions of the ACL class API in ACLStrategy is not needed because
20// ACLStrategy is unused outside the ACLStrategised context. Existing classes
21// like ACLExtUser, ACLProxyAuth, and ACLIdent seem to confirm this assertion.
22// It also requires forwarding ACL info to ACLStrategy as method parameters.
23
27template <class M>
28class ACLStrategised : public ACL
29{
31
32public:
33 typedef M MatchType;
34
37
38 virtual char const *typeString() const;
39
40 virtual bool requiresRequest() const {return matcher->requiresRequest();}
41
42 virtual bool requiresReply() const {return matcher->requiresReply();}
43
44 virtual void prepareForUse() { data->prepareForUse();}
45 virtual void parse();
46 virtual int match(ACLChecklist *checklist);
47 virtual int match (M const &);
48 virtual SBufList dump() const;
49 virtual bool empty () const;
50 virtual bool valid () const;
51
52private:
53 /* ACL API */
54 virtual const Acl::Options &options() { return matcher->options(); }
55 virtual const Acl::Options &lineOptions() { return data->lineOptions(); }
56
58 char const *type_;
60};
61
62/* implementation follows */
63
64template <class MatchType>
66{
67 delete data;
68 delete matcher;
69}
70
71template <class MatchType>
72ACLStrategised<MatchType>::ACLStrategised(ACLData<MatchType> *newData, ACLStrategy<MatchType> *theStrategy, char const *theType): data(newData), type_(theType), matcher(theStrategy)
73{}
74
75template <class MatchType>
76char const *
78{
79 return type_;
80}
81
82template <class MatchType>
83void
85{
86 data->parse();
87}
88
89template <class MatchType>
90bool
92{
93 return data->empty();
94}
95
96template <class MatchType>
97int
99{
100 ACLFilledChecklist *checklist = dynamic_cast<ACLFilledChecklist*>(cl);
101 assert(checklist);
102 return matcher->match(data, checklist);
103}
104
105template <class MatchType>
106int
108{
109 return data->match(toFind);
110}
111
112template <class MatchType>
115{
116 return data->dump();
117}
118
119template <class MatchType>
120bool
122{
123 return matcher->valid();
124}
125
126#endif /* SQUID_ACLSTRATEGISED_H */
127
#define assert(EX)
Definition: assert.h:19
virtual void prepareForUse()
Definition: Data.h:31
virtual const Acl::Options & lineOptions()
supported ACL "line" options (e.g., "-i")
Definition: Data.h:26
virtual bool requiresRequest() const
whether our (i.e. shallow) match() requires checklist to have a request
Definition: Strategised.h:40
virtual const Acl::Options & lineOptions()
Definition: Strategised.h:55
virtual int match(ACLChecklist *checklist)
Matches the actual data in checklist against this ACL.
Definition: Strategised.h:98
virtual bool requiresReply() const
whether our (i.e. shallow) match() requires checklist to have a reply
Definition: Strategised.h:42
ACLStrategised(ACLData< MatchType > *, ACLStrategy< MatchType > *, char const *)
Definition: Strategised.h:72
virtual void parse()
parses node representation in squid.conf; dies on failures
Definition: Strategised.h:84
virtual char const * typeString() const
Definition: Strategised.h:77
ACLStrategy< MatchType > * matcher
Definition: Strategised.h:59
ACLData< MatchType > * data
Definition: Strategised.h:57
char const * type_
Definition: Strategised.h:58
virtual bool valid() const
Definition: Strategised.h:121
virtual void prepareForUse()
Definition: Strategised.h:44
virtual const Acl::Options & options()
Definition: Strategised.h:54
virtual bool empty() const
Definition: Strategised.h:91
virtual SBufList dump() const
Definition: Strategised.h:114
MEMPROXY_CLASS(ACLStrategised)
virtual bool requiresReply() const
Definition: Strategy.h:32
virtual const Acl::Options & options()
Definition: Strategy.h:28
virtual bool requiresRequest() const
Definition: Strategy.h:30
Definition: Acl.h:40
std::vector< const Option * > Options
Definition: Options.h:214
std::list< SBuf > SBufList
Definition: forward.h:23

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors