]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/acl/Strategised.h
4 * SQUID Web Proxy Cache http://www.squid-cache.org/
5 * ----------------------------------------------------------
7 * Squid is the result of efforts by numerous individuals from
8 * the Internet community; see the CONTRIBUTORS file for full
9 * details. Many organizations have provided support for Squid's
10 * development; see the SPONSORS file for full details. Squid is
11 * Copyrighted (C) 2001 by the Regents of the University of
12 * California; see the COPYRIGHT file for full details. Squid
13 * incorporates software developed and/or copyrighted by other
14 * sources; see the CREDITS file for full details.
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2 of the License, or
19 * (at your option) any later version.
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
31 * Copyright (c) 2003, Robert Collins <robertc@squid-cache.org>
34 #ifndef SQUID_ACLSTRATEGISED_H
35 #define SQUID_ACLSTRATEGISED_H
38 #include "acl/Strategy.h"
39 #include "acl/FilledChecklist.h"
43 class ACLStrategised
: public ACL
48 void *operator new(size_t);
49 void operator delete(void *);
52 ACLStrategised(ACLData
<MatchType
> *, ACLStrategy
<MatchType
> *, char const *);
53 ACLStrategised (ACLStrategised
const &);
54 ACLStrategised
&operator= (ACLStrategised
const &);
56 virtual char const *typeString() const;
57 virtual bool requiresRequest() const {return matcher
->requiresRequest();}
59 virtual bool requiresReply() const {return matcher
->requiresReply();}
61 virtual void prepareForUse() { data
->prepareForUse();}
64 virtual int match(ACLChecklist
*checklist
);
65 virtual int match (M
const &);
66 virtual wordlist
*dump() const;
67 virtual bool empty () const;
68 virtual bool valid () const;
69 virtual ACL
*clone()const;
72 static MemAllocator
*Pool
;
73 ACLData
<MatchType
> *data
;
75 ACLStrategy
<MatchType
> *matcher
;
78 /* implementation follows */
80 template <class MatchType
>
81 MemAllocator
*ACLStrategised
<MatchType
>::Pool
= NULL
;
83 template <class MatchType
>
85 ACLStrategised
<MatchType
>::operator new (size_t byteCount
)
87 /* derived classes with different sizes must implement their own new */
88 assert (byteCount
== sizeof (ACLStrategised
<MatchType
>));
91 Pool
= memPoolCreate("ACLStrategised", sizeof (ACLStrategised
<MatchType
>));
96 template <class MatchType
>
98 ACLStrategised
<MatchType
>::operator delete (void *address
)
100 Pool
->freeOne(address
);
103 template <class MatchType
>
104 ACLStrategised
<MatchType
>::~ACLStrategised()
109 template <class MatchType
>
110 ACLStrategised
<MatchType
>::ACLStrategised(ACLData
<MatchType
> *newData
, ACLStrategy
<MatchType
> *theStrategy
, char const *theType
) : data (newData
), type_(theType
), matcher(theStrategy
) {}
112 template <class MatchType
>
113 ACLStrategised
<MatchType
>::ACLStrategised (ACLStrategised
const &old
) : data (old
.data
->clone()), type_(old
.type_
), matcher (old
.matcher
)
116 template <class MatchType
>
117 ACLStrategised
<MatchType
> &
118 ACLStrategised
<MatchType
>::operator= (ACLStrategised
const &rhs
)
120 data
= rhs
.data
->clone();
122 matcher
= rhs
.matcher
;
126 template <class MatchType
>
128 ACLStrategised
<MatchType
>::typeString() const
133 template <class MatchType
>
135 ACLStrategised
<MatchType
>::parse()
140 template <class MatchType
>
142 ACLStrategised
<MatchType
>::empty() const
144 return data
->empty();
147 template <class MatchType
>
149 ACLStrategised
<MatchType
>::match(ACLChecklist
*cl
)
151 ACLFilledChecklist
*checklist
= dynamic_cast<ACLFilledChecklist
*>(cl
);
153 return matcher
->match(data
, checklist
);
156 template <class MatchType
>
158 ACLStrategised
<MatchType
>::match(MatchType
const &toFind
)
160 return data
->match(toFind
);
163 template <class MatchType
>
165 ACLStrategised
<MatchType
>::dump() const
170 template <class MatchType
>
172 ACLStrategised
<MatchType
>::valid () const
174 return matcher
->valid();
177 template <class MatchType
>
179 ACLStrategised
<MatchType
>::clone() const
181 return new ACLStrategised(*this);
184 #endif /* SQUID_ACLSTRATEGISED_H */