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 
27 template <class M>
28 class ACLStrategised : public ACL
29 {
31 
32 public:
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 
52 private:
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 
64 template <class MatchType>
66 {
67  delete data;
68  delete matcher;
69 }
70 
71 template <class MatchType>
72 ACLStrategised<MatchType>::ACLStrategised(ACLData<MatchType> *newData, ACLStrategy<MatchType> *theStrategy, char const *theType): data(newData), type_(theType), matcher(theStrategy)
73 {}
74 
75 template <class MatchType>
76 char const *
78 {
79  return type_;
80 }
81 
82 template <class MatchType>
83 void
85 {
86  data->parse();
87 }
88 
89 template <class MatchType>
90 bool
92 {
93  return data->empty();
94 }
95 
96 template <class MatchType>
97 int
99 {
100  ACLFilledChecklist *checklist = dynamic_cast<ACLFilledChecklist*>(cl);
101  assert(checklist);
102  return matcher->match(data, checklist);
103 }
104 
105 template <class MatchType>
106 int
108 {
109  return data->match(toFind);
110 }
111 
112 template <class MatchType>
113 SBufList
115 {
116  return data->dump();
117 }
118 
119 template <class MatchType>
120 bool
122 {
123  return matcher->valid();
124 }
125 
126 #endif /* SQUID_ACLSTRATEGISED_H */
127 
virtual const Acl::Options & options()
Definition: Strategy.h:28
virtual const Acl::Options & lineOptions()
supported ACL "line" options (e.g., "-i")
Definition: Data.h:26
virtual void parse()
parses node representation in squid.conf; dies on failures
Definition: Strategised.h:84
ACLStrategy< MatchType > * matcher
Definition: Strategised.h:59
std::vector< const Option * > Options
Definition: Options.h:214
virtual const Acl::Options & options()
Definition: Strategised.h:54
MEMPROXY_CLASS(ACLStrategised)
virtual void prepareForUse()
Definition: Data.h:31
std::list< SBuf > SBufList
Definition: forward.h:22
virtual bool requiresReply() const
whether our (i.e. shallow) match() requires checklist to have a reply
Definition: Strategised.h:42
virtual void prepareForUse()
Definition: Strategised.h:44
virtual bool valid() const
Definition: Strategised.h:121
virtual bool empty() const
Definition: Strategised.h:91
#define assert(EX)
Definition: assert.h:19
virtual char const * typeString() const
Definition: Strategised.h:77
char const * type_
Definition: Strategised.h:58
virtual bool requiresRequest() const
Definition: Strategy.h:30
Definition: Acl.h:40
ACLData< MatchType > * data
Definition: Strategised.h:57
virtual int match(ACLChecklist *checklist)
Matches the actual data in checklist against this ACL.
Definition: Strategised.h:98
virtual const Acl::Options & lineOptions()
Definition: Strategised.h:55
virtual SBufList dump() const
Definition: Strategised.h:114
virtual bool requiresRequest() const
whether our (i.e. shallow) match() requires checklist to have a request
Definition: Strategised.h:40
virtual bool requiresReply() const
Definition: Strategy.h:32
ACLStrategised(ACLData< MatchType > *, ACLStrategy< MatchType > *, char const *)
Definition: Strategised.h:72

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors