Strategised.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2017 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  ACLStrategised(ACLStrategised const &&) = delete;
38 
39  virtual char const *typeString() const;
40  virtual void parseFlags();
41 
42  virtual bool requiresRequest() const {return matcher->requiresRequest();}
43 
44  virtual bool requiresReply() const {return matcher->requiresReply();}
45 
46  virtual void prepareForUse() { data->prepareForUse();}
47  virtual const Acl::Options &options() { return matcher->options(); }
48  virtual void parse();
49  virtual int match(ACLChecklist *checklist);
50  virtual int match (M const &);
51  virtual SBufList dump() const;
52  virtual bool empty () const;
53  virtual bool valid () const;
54 
55 private:
57  char const *type_;
59 };
60 
61 /* implementation follows */
62 
63 template <class MatchType>
65 {
66  delete data;
67 }
68 
69 template <class MatchType>
70 ACLStrategised<MatchType>::ACLStrategised(ACLData<MatchType> *newData, ACLStrategy<MatchType> *theStrategy, char const *theType): data(newData), type_(theType), matcher(theStrategy)
71 {}
72 
73 template <class MatchType>
74 char const *
76 {
77  return type_;
78 }
79 
80 template <class MatchType>
81 void
83 {
84  ParseFlags(options(), data->supportedFlags());
85 }
86 
87 template <class MatchType>
88 void
90 {
91  data->parse();
92 }
93 
94 template <class MatchType>
95 bool
97 {
98  return data->empty();
99 }
100 
101 template <class MatchType>
102 int
104 {
105  ACLFilledChecklist *checklist = dynamic_cast<ACLFilledChecklist*>(cl);
106  assert(checklist);
107  return matcher->match(data, checklist);
108 }
109 
110 template <class MatchType>
111 int
113 {
114  return data->match(toFind);
115 }
116 
117 template <class MatchType>
118 SBufList
120 {
121  return data->dump();
122 }
123 
124 template <class MatchType>
125 bool
127 {
128  return matcher->valid();
129 }
130 
131 #endif /* SQUID_ACLSTRATEGISED_H */
132 
#define assert(EX)
Definition: assert.h:17
virtual bool valid() const
Definition: Strategised.h:126
ACLData< MatchType > * data
Definition: Strategised.h:56
Definition: Acl.h:39
virtual bool empty() const
Definition: Strategised.h:96
ACLStrategised(ACLData< MatchType > *, ACLStrategy< MatchType > *, char const *)
Definition: Strategised.h:70
virtual bool requiresRequest() const
whether our (i.e. shallow) match() requires checklist to have a request
Definition: Strategised.h:42
virtual bool requiresReply() const
Definition: Strategy.h:32
virtual void prepareForUse()
Definition: Data.h:31
char const * type_
Definition: Strategised.h:57
ACLStrategy< MatchType > * matcher
Definition: Strategised.h:58
void const char HLPCB void * data
Definition: stub_helper.cc:16
virtual SBufList dump() const
Definition: Strategised.h:119
virtual int match(ACLChecklist *checklist)
Matches the actual data in checklist against this ACL.
Definition: Strategised.h:103
virtual const Acl::Options & options()
Definition: Strategised.h:47
virtual char const * typeString() const
Definition: Strategised.h:75
virtual const Acl::Options & options()
Definition: Strategy.h:28
virtual void parseFlags()
configures ACL options, throwing on configuration errors
Definition: Strategised.h:82
void ParseFlags(const Options &options, const ParameterFlags &flags)
Definition: Options.cc:240
virtual void parse()
parses node represenation in squid.conf; dies on failures
Definition: Strategised.h:89
std::list< SBuf > SBufList
Definition: forward.h:26
virtual bool requiresReply() const
whether our (i.e. shallow) match() requires checklist to have a reply
Definition: Strategised.h:44
std::map< OptionName, const Option *, OptionNameCmp > Options
name:option map
Definition: Options.h:159
MEMPROXY_CLASS(ACLStrategised)
virtual bool requiresRequest() const
Definition: Strategy.h:30
virtual void prepareForUse()
Definition: Strategised.h:46

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors