3
* $Id: ACLStrategised.h,v 1.11 2006/09/03 21:05:20 hno 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 *);
53
ACLStrategised(ACLData<MatchType> *, ACLStrategy<MatchType> *, char const *);
54
ACLStrategised (ACLStrategised const &);
55
ACLStrategised &operator= (ACLStrategised const &);
57
virtual char const *typeString() const;
58
virtual bool requiresRequest() const {return matcher->requiresRequest();}
60
virtual bool requiresReply() const {return matcher->requiresReply();}
62
virtual void prepareForUse() { data->prepareForUse();}
65
virtual int match(ACLChecklist *checklist);
66
virtual int match (M const &);
67
virtual wordlist *dump() const;
68
virtual bool empty () const;
69
virtual bool valid () const;
70
virtual ACL *clone()const;
73
static MemAllocator *Pool;
74
ACLData<MatchType> *data;
76
ACLStrategy<MatchType> *matcher;
79
/* implementation follows */
81
template <class MatchType>
82
MemAllocator *ACLStrategised<MatchType>::Pool = NULL;
84
template <class MatchType>
86
ACLStrategised<MatchType>::operator new (size_t byteCount)
88
/* derived classes with different sizes must implement their own new */
89
assert (byteCount == sizeof (ACLStrategised<MatchType>));
92
Pool = memPoolCreate("ACLStrategised", sizeof (ACLStrategised<MatchType>));
97
template <class MatchType>
99
ACLStrategised<MatchType>::operator delete (void *address)
104
template <class MatchType>
105
ACLStrategised<MatchType>::~ACLStrategised()
110
template <class MatchType>
111
ACLStrategised<MatchType>::ACLStrategised(ACLData<MatchType> *newData, ACLStrategy<MatchType> *theStrategy, char const *theType) : data (newData), type_(theType), matcher(theStrategy) {}
113
template <class MatchType>
114
ACLStrategised<MatchType>::ACLStrategised (ACLStrategised const &old) : data (old.data->clone()), type_(old.type_), matcher (old.matcher)
117
template <class MatchType>
118
ACLStrategised<MatchType> &
119
ACLStrategised<MatchType>::operator= (ACLStrategised const &rhs)
121
data = rhs.data->clone();
123
matcher = rhs.matcher;
127
template <class MatchType>
129
ACLStrategised<MatchType>::typeString() const
134
template <class MatchType>
136
ACLStrategised<MatchType>::parse()
141
template <class MatchType>
143
ACLStrategised<MatchType>::empty() const
145
return data->empty();
148
template <class MatchType>
150
ACLStrategised<MatchType>::match(ACLChecklist *checklist)
152
return matcher->match(data, checklist);
155
template <class MatchType>
157
ACLStrategised<MatchType>::match(MatchType const &toFind)
159
return data->match(toFind);
162
template <class MatchType>
164
ACLStrategised<MatchType>::dump() const
169
template <class MatchType>
171
ACLStrategised<MatchType>::valid () const
173
return matcher->valid();
176
template <class MatchType>
178
ACLStrategised<MatchType>::clone() const
180
return new ACLStrategised(*this);
183
#endif /* SQUID_ACLSTRATEGISED_H */