]>
Commit | Line | Data |
---|---|---|
b9ae18aa | 1 | /* |
bbc27441 | 2 | * Copyright (C) 1996-2014 The Squid Software Foundation and contributors |
b9ae18aa | 3 | * |
bbc27441 AJ |
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. | |
b9ae18aa | 7 | */ |
bbc27441 | 8 | |
b9ae18aa | 9 | #ifndef SQUID_CONFIGOPTION_H |
10 | #define SQUID_CONFIGOPTION_H | |
11 | ||
c8ea3cc0 | 12 | #include <vector> |
b9ae18aa | 13 | |
fafe8849 FC |
14 | class StoreEntry; |
15 | ||
b9ae18aa | 16 | /* cache option parsers */ |
17 | ||
18 | class ConfigOption | |
19 | { | |
20 | ||
21 | public: | |
22 | virtual ~ConfigOption() {} | |
23 | ||
24 | virtual bool parse(char const *option, const char *value, int reconfiguring) = 0; | |
6ca34f6f | 25 | virtual void dump(StoreEntry * e) const = 0; |
b9ae18aa | 26 | }; |
27 | ||
28 | class ConfigOptionVector : public ConfigOption | |
29 | { | |
30 | ||
31 | public: | |
32 | virtual ~ConfigOptionVector(); | |
33 | virtual bool parse(char const *option, const char *value, int reconfiguring); | |
34 | virtual void dump(StoreEntry * e) const; | |
c8ea3cc0 | 35 | std::vector<ConfigOption *>options; |
b9ae18aa | 36 | }; |
37 | ||
38 | template <class C> | |
b9ae18aa | 39 | class ConfigOptionAdapter : public ConfigOption |
40 | { | |
41 | ||
42 | public: | |
6ca34f6f | 43 | ConfigOptionAdapter(C& theObject, bool (C::*parseFP)(char const *option, const char *value, int reconfiguring), void (C::*dumpFP)(StoreEntry * e) const) : object(theObject), parser(parseFP), dumper(dumpFP) {} |
b9ae18aa | 44 | |
18ec8500 | 45 | bool parse(char const *option, const char *value, int isaReconf) { |
b9ae18aa | 46 | if (parser) |
18ec8500 | 47 | return (object.*parser)(option, value, isaReconf); |
b9ae18aa | 48 | |
49 | return false; | |
50 | } | |
51 | ||
26ac0430 | 52 | void dump(StoreEntry * e) const { |
b9ae18aa | 53 | if (dumper) |
6ca34f6f | 54 | (object.*dumper)(e); |
b9ae18aa | 55 | } |
56 | ||
57 | private: | |
58 | C &object; | |
6ca34f6f | 59 | bool (C::*parser)(char const *option, const char *value, int reconfiguring) ; |
b9ae18aa | 60 | void (C::*dumper)(StoreEntry * e) const; |
61 | }; | |
62 | ||
63 | #endif /* SQUID_CONFIGOPTION_H */ | |
f53969cc | 64 |