]> git.ipfire.org Git - thirdparty/squid.git/blame - src/ACLStrategised.h
Complain during parsing if https_port version is not in (1..4)
[thirdparty/squid.git] / src / ACLStrategised.h
CommitLineData
5dee515e 1
2/*
4b0f5de8 3 * $Id: ACLStrategised.h,v 1.9 2005/05/06 01:57:55 hno Exp $
5dee515e 4 *
5 *
6 * SQUID Web Proxy Cache http://www.squid-cache.org/
7 * ----------------------------------------------------------
8 *
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.
17 *
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.
22 *
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.
27 *
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.
31 *
32 *
33 * Copyright (c) 2003, Robert Collins <robertc@squid-cache.org>
34 */
35
36#ifndef SQUID_ACLSTRATEGISED_H
37#define SQUID_ACLSTRATEGISED_H
38#include "ACL.h"
39#include "ACLData.h"
b0dd28ba 40#include "ACLStrategy.h"
5dee515e 41
42template <class M>
62e76326 43
44class ACLStrategised : public ACL
45{
46
47public:
5dee515e 48 typedef M MatchType;
49 void *operator new(size_t);
50 void operator delete(void *);
5dee515e 51
52 ~ACLStrategised();
b0dd28ba 53 ACLStrategised(ACLData<MatchType> *, ACLStrategy<MatchType> *, char const *);
5dee515e 54 ACLStrategised (ACLStrategised const &);
55 ACLStrategised &operator= (ACLStrategised const &);
62e76326 56
5dee515e 57 virtual char const *typeString() const;
5dee515e 58 virtual bool requiresRequest() const {return matcher->requiresRequest();}
62e76326 59
f201d9ac 60 virtual bool requiresReply() const {return matcher->requiresReply();}
61
b0dd28ba 62 virtual void prepareForUse() { data->prepareForUse();}
63
5dee515e 64 virtual void parse();
65 virtual int match(ACLChecklist *checklist);
b0dd28ba 66 virtual int match (M const &);
5dee515e 67 virtual wordlist *dump() const;
4b0f5de8 68 virtual bool empty () const;
5dee515e 69 virtual ACL *clone()const;
62e76326 70
71private:
b001e822 72 static MemAllocator *Pool;
5dee515e 73 ACLData<MatchType> *data;
74 char const *type_;
b0dd28ba 75 ACLStrategy<MatchType> *matcher;
5dee515e 76};
77
78/* implementation follows */
79
80template <class MatchType>
b001e822 81MemAllocator *ACLStrategised<MatchType>::Pool = NULL;
5dee515e 82
83template <class MatchType>
84void *
85ACLStrategised<MatchType>::operator new (size_t byteCount)
86{
87 /* derived classes with different sizes must implement their own new */
88 assert (byteCount == sizeof (ACLStrategised<MatchType>));
62e76326 89
5dee515e 90 if (!Pool)
b001e822 91 Pool = MemPools::GetInstance().create("ACLStrategised", sizeof (ACLStrategised<MatchType>));
62e76326 92
b001e822 93 return Pool->alloc();
5dee515e 94}
95
96template <class MatchType>
97void
98ACLStrategised<MatchType>::operator delete (void *address)
99{
b001e822 100 Pool->free(address);
5dee515e 101}
102
5dee515e 103template <class MatchType>
104ACLStrategised<MatchType>::~ACLStrategised()
105{
00d77d6b 106 delete data;
5dee515e 107}
108
109template <class MatchType>
b0dd28ba 110ACLStrategised<MatchType>::ACLStrategised(ACLData<MatchType> *newData, ACLStrategy<MatchType> *theStrategy, char const *theType) : data (newData), type_(theType), matcher(theStrategy) {}
62e76326 111
5dee515e 112template <class MatchType>
113ACLStrategised<MatchType>::ACLStrategised (ACLStrategised const &old) : data (old.data->clone()), type_(old.type_), matcher (old.matcher)
62e76326 114{}
115
5dee515e 116template <class MatchType>
117ACLStrategised<MatchType> &
118ACLStrategised<MatchType>::operator= (ACLStrategised const &rhs)
119{
120 data = rhs.data->clone();
121 type_ = rhs.type_;
122 matcher = rhs.matcher;
123 return *this;
124}
125
126template <class MatchType>
127char const *
128ACLStrategised<MatchType>::typeString() const
129{
130 return type_;
131}
132
133template <class MatchType>
134void
135ACLStrategised<MatchType>::parse()
136{
137 data->parse();
138}
139
140template <class MatchType>
141int
142ACLStrategised<MatchType>::match(ACLChecklist *checklist)
143{
144 return matcher->match(data, checklist);
145}
146
b0dd28ba 147template <class MatchType>
148int
149ACLStrategised<MatchType>::match(MatchType const &toFind)
150{
151 return data->match(toFind);
152}
153
5dee515e 154template <class MatchType>
155wordlist *
156ACLStrategised<MatchType>::dump() const
157{
158 return data->dump();
159}
160
161template <class MatchType>
162bool
4b0f5de8 163ACLStrategised<MatchType>::empty () const
5dee515e 164{
4b0f5de8 165 return data == NULL;
5dee515e 166}
167
168template <class MatchType>
169ACL *
170ACLStrategised<MatchType>::clone() const
171{
172 return new ACLStrategised(*this);
173}
174
175#endif /* SQUID_ACLSTRATEGISED_H */