]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/ACLStrategised.h
3 * $Id: ACLStrategised.h,v 1.4 2003/07/14 08:21:56 robertc Exp $
6 * SQUID Web Proxy Cache http://www.squid-cache.org/
7 * ----------------------------------------------------------
9 * Squid is the result of efforts by numerous individuals from
10 * the Internet community; see the CONTRIBUTORS file for full
11 * details. Many organizations have provided support for Squid's
12 * development; see the SPONSORS file for full details. Squid is
13 * Copyrighted (C) 2001 by the Regents of the University of
14 * California; see the COPYRIGHT file for full details. Squid
15 * incorporates software developed and/or copyrighted by other
16 * sources; see the CREDITS file for full details.
18 * This program is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by
20 * the Free Software Foundation; either version 2 of the License, or
21 * (at your option) any later version.
23 * This program is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
28 * You should have received a copy of the GNU General Public License
29 * along with this program; if not, write to the Free Software
30 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
33 * Copyright (c) 2003, Robert Collins <robertc@squid-cache.org>
36 #ifndef SQUID_ACLSTRATEGISED_H
37 #define SQUID_ACLSTRATEGISED_H
40 #include "ACLStrategy.h"
44 class ACLStrategised
: public ACL
49 void *operator new(size_t);
50 void operator delete(void *);
51 virtual void deleteSelf() const;
54 ACLStrategised(ACLData
<MatchType
> *, ACLStrategy
<MatchType
> *, char const *);
55 ACLStrategised (ACLStrategised
const &);
56 ACLStrategised
&operator= (ACLStrategised
const &);
58 virtual char const *typeString() const;
59 virtual bool requiresRequest() const {return matcher
->requiresRequest();}
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 valid () const;
68 virtual ACL
*clone()const;
72 ACLData
<MatchType
> *data
;
74 ACLStrategy
<MatchType
> *matcher
;
77 /* implementation follows */
79 template <class MatchType
>
80 MemPool (*ACLStrategised
<MatchType
>::Pool
)(NULL
);
82 template <class MatchType
>
84 ACLStrategised
<MatchType
>::operator new (size_t byteCount
)
86 /* derived classes with different sizes must implement their own new */
87 assert (byteCount
== sizeof (ACLStrategised
<MatchType
>));
90 Pool
= memPoolCreate("ACLStrategised", sizeof (ACLStrategised
<MatchType
>));
92 return memPoolAlloc(Pool
);
95 template <class MatchType
>
97 ACLStrategised
<MatchType
>::operator delete (void *address
)
99 memPoolFree (Pool
, address
);
102 template <class MatchType
>
104 ACLStrategised
<MatchType
>::deleteSelf() const
109 template <class MatchType
>
110 ACLStrategised
<MatchType
>::~ACLStrategised()
115 template <class MatchType
>
116 ACLStrategised
<MatchType
>::ACLStrategised(ACLData
<MatchType
> *newData
, ACLStrategy
<MatchType
> *theStrategy
, char const *theType
) : data (newData
), type_(theType
), matcher(theStrategy
) {}
118 template <class MatchType
>
119 ACLStrategised
<MatchType
>::ACLStrategised (ACLStrategised
const &old
) : data (old
.data
->clone()), type_(old
.type_
), matcher (old
.matcher
)
122 template <class MatchType
>
123 ACLStrategised
<MatchType
> &
124 ACLStrategised
<MatchType
>::operator= (ACLStrategised
const &rhs
)
126 data
= rhs
.data
->clone();
128 matcher
= rhs
.matcher
;
132 template <class MatchType
>
134 ACLStrategised
<MatchType
>::typeString() const
139 template <class MatchType
>
141 ACLStrategised
<MatchType
>::parse()
146 template <class MatchType
>
148 ACLStrategised
<MatchType
>::match(ACLChecklist
*checklist
)
150 return matcher
->match(data
, checklist
);
153 template <class MatchType
>
155 ACLStrategised
<MatchType
>::match(MatchType
const &toFind
)
157 return data
->match(toFind
);
160 template <class MatchType
>
162 ACLStrategised
<MatchType
>::dump() const
167 template <class MatchType
>
169 ACLStrategised
<MatchType
>::valid () const
174 template <class MatchType
>
176 ACLStrategised
<MatchType
>::clone() const
178 return new ACLStrategised(*this);
181 #endif /* SQUID_ACLSTRATEGISED_H */