]> git.ipfire.org Git - thirdparty/squid.git/blob - src/RefreshPattern.h
SourceLayout: refactor regex pattern objects
[thirdparty/squid.git] / src / RefreshPattern.h
1 /*
2 * Copyright (C) 1996-2015 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_REFRESHPATTERN_H_
10 #define SQUID_REFRESHPATTERN_H_
11
12 #include "base/RegexPattern.h"
13
14 /// a representation of a refresh pattern.
15 class RefreshPattern
16 {
17 MEMPROXY_CLASS(RefreshPattern);
18
19 public:
20
21 /*
22 * Defaults:
23 * MIN NONE
24 * PCT 20%
25 * MAX 3 days
26 */
27 #define REFRESH_DEFAULT_MAX static_cast<time_t>(259200)
28
29 RefreshPattern(const char *aPattern, const decltype(RegexPattern::flags) &reFlags) :
30 pattern(reFlags, aPattern),
31 min(0), pct(0.20), max(REFRESH_DEFAULT_MAX),
32 next(NULL),
33 max_stale(0)
34 {
35 memset(&flags, 0, sizeof(flags));
36 }
37
38 ~RefreshPattern() {
39 while (RefreshPattern *t = next) {
40 next = t->next;
41 t->next = nullptr;
42 delete t;
43 }
44 }
45 // ~RefreshPattern() default destructor is fine
46
47 RegexPattern pattern;
48 time_t min;
49 double pct;
50 time_t max;
51 RefreshPattern *next;
52
53 struct {
54 bool refresh_ims;
55 bool store_stale;
56 #if USE_HTTP_VIOLATIONS
57 bool override_expire;
58 bool override_lastmod;
59 bool reload_into_ims;
60 bool ignore_reload;
61 bool ignore_no_store;
62 bool ignore_private;
63 #endif
64 } flags;
65 int max_stale;
66
67 // statistics about how many matches this pattern has had
68 mutable struct stats_ {
69 stats_() : matchTests(0), matchCount(0) {}
70
71 uint64_t matchTests;
72 uint64_t matchCount;
73 // TODO: some stats to indicate how useful/less the flags are would be nice.
74 } stats;
75 };
76
77 #endif /* SQUID_REFRESHPATTERN_H_ */
78