]> git.ipfire.org Git - thirdparty/squid.git/blob - src/RemovalPolicy.h
Merged from trunk
[thirdparty/squid.git] / src / RemovalPolicy.h
1
2 /*
3 *
4 * SQUID Web Proxy Cache http://www.squid-cache.org/
5 * ----------------------------------------------------------
6 *
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.
15 *
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.
20 *
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.
25 *
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.
29 *
30 * Copyright (c) 2003, Robert Collins <robertc@squid-cache.org>
31 */
32
33 #ifndef SQUID_REMOVALPOLICY_H
34 #define SQUID_REMOVALPOLICY_H
35
36 #include "cbdata.h"
37
38 class RemovalPolicyWalker;
39 class RemovalPurgeWalker;
40
41 class RemovalPolicySettings
42 {
43
44 public:
45 RemovalPolicySettings() : type(NULL), args(NULL) {};
46
47 char *type;
48 wordlist *args;
49 };
50
51 class RemovalPolicyNode
52 {
53
54 public:
55 RemovalPolicyNode() : data(NULL) {}
56
57 void *data;
58 };
59
60 class RemovalPolicy
61 {
62 public:
63 const char *_type;
64 void *_data;
65 void (*Free) (RemovalPolicy * policy);
66 void (*Add) (RemovalPolicy * policy, StoreEntry * entry, RemovalPolicyNode * node);
67 void (*Remove) (RemovalPolicy * policy, StoreEntry * entry, RemovalPolicyNode * node);
68 void (*Referenced) (RemovalPolicy * policy, const StoreEntry * entry, RemovalPolicyNode * node);
69 void (*Dereferenced) (RemovalPolicy * policy, const StoreEntry * entry, RemovalPolicyNode * node);
70 RemovalPolicyWalker *(*WalkInit) (RemovalPolicy * policy);
71 RemovalPurgeWalker *(*PurgeInit) (RemovalPolicy * policy, int max_scan);
72 void (*Stats) (RemovalPolicy * policy, StoreEntry * entry);
73 private:
74 CBDATA_CLASS2(RemovalPolicy);
75 };
76
77 class RemovalPolicyWalker
78 {
79 public:
80 RemovalPolicy *_policy;
81 void *_data;
82 const StoreEntry *(*Next) (RemovalPolicyWalker * walker);
83 void (*Done) (RemovalPolicyWalker * walker);
84 private:
85 CBDATA_CLASS2(RemovalPolicyWalker);
86 };
87
88 class RemovalPurgeWalker
89 {
90 public:
91 RemovalPolicy *_policy;
92 void *_data;
93 int scanned, max_scan, locked;
94 StoreEntry *(*Next) (RemovalPurgeWalker * walker);
95 void (*Done) (RemovalPurgeWalker * walker);
96 private:
97 CBDATA_CLASS2(RemovalPurgeWalker);
98 };
99
100 extern RemovalPolicy *createRemovalPolicy(RemovalPolicySettings * settings);
101
102 typedef RemovalPolicy *REMOVALPOLICYCREATE(wordlist * args);
103
104 #endif /* SQUID_REMOVALPOLICY_H */