]> git.ipfire.org Git - thirdparty/squid.git/blob - src/RemovalPolicy.h
bee52acc372fd4afdfd430cb8e80be537a7e9d83
[thirdparty/squid.git] / src / RemovalPolicy.h
1 /*
2 * Copyright (C) 1996-2022 The Squid Software Foundation and contributors
3 *
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
7 */
8
9 #ifndef SQUID_REMOVALPOLICY_H
10 #define SQUID_REMOVALPOLICY_H
11
12 #include "cbdata.h"
13
14 class RemovalPolicyWalker;
15 class RemovalPurgeWalker;
16 class wordlist;
17 class StoreEntry;
18
19 class RemovalPolicySettings
20 {
21
22 public:
23 RemovalPolicySettings() : type(nullptr), args(nullptr) {};
24
25 char *type;
26 wordlist *args;
27 };
28
29 class RemovalPolicyNode
30 {
31
32 public:
33 RemovalPolicyNode() : data(nullptr) {}
34
35 void *data;
36 };
37
38 class RemovalPolicy
39 {
40 CBDATA_CLASS(RemovalPolicy);
41
42 public:
43 const char *_type;
44 void *_data;
45 void (*Free) (RemovalPolicy * policy);
46 void (*Add) (RemovalPolicy * policy, StoreEntry * entry, RemovalPolicyNode * node);
47 void (*Remove) (RemovalPolicy * policy, StoreEntry * entry, RemovalPolicyNode * node);
48 void (*Referenced) (RemovalPolicy * policy, const StoreEntry * entry, RemovalPolicyNode * node);
49 void (*Dereferenced) (RemovalPolicy * policy, const StoreEntry * entry, RemovalPolicyNode * node);
50 RemovalPolicyWalker *(*WalkInit) (RemovalPolicy * policy);
51 RemovalPurgeWalker *(*PurgeInit) (RemovalPolicy * policy, int max_scan);
52 void (*Stats) (RemovalPolicy * policy, StoreEntry * entry);
53 };
54
55 class RemovalPolicyWalker
56 {
57 CBDATA_CLASS(RemovalPolicyWalker);
58
59 public:
60 RemovalPolicy *_policy;
61 void *_data;
62 const StoreEntry *(*Next) (RemovalPolicyWalker * walker);
63 void (*Done) (RemovalPolicyWalker * walker);
64 };
65
66 class RemovalPurgeWalker
67 {
68 CBDATA_CLASS(RemovalPurgeWalker);
69
70 public:
71 RemovalPolicy *_policy;
72 void *_data;
73 int scanned, max_scan, locked;
74 StoreEntry *(*Next) (RemovalPurgeWalker * walker);
75 void (*Done) (RemovalPurgeWalker * walker);
76 };
77
78 RemovalPolicy *createRemovalPolicy(RemovalPolicySettings * settings);
79
80 typedef RemovalPolicy *REMOVALPOLICYCREATE(wordlist * args);
81
82 #endif /* SQUID_REMOVALPOLICY_H */
83