]> git.ipfire.org Git - thirdparty/squid.git/blob - src/adaptation/Config.h
Merged from trunk (r12813).
[thirdparty/squid.git] / src / adaptation / Config.h
1 #ifndef SQUID_ADAPTATION__CONFIG_H
2 #define SQUID_ADAPTATION__CONFIG_H
3
4 #include "event.h"
5 #include "acl/forward.h"
6 #include "acl/Gadgets.h"
7 #include "base/AsyncCall.h"
8 #include "adaptation/forward.h"
9 #include "adaptation/Elements.h"
10 #include "Notes.h"
11 #include "SquidString.h"
12
13 class ConfigParser;
14 class HttpRequest;
15 class HttpReply;
16
17 namespace Adaptation
18 {
19
20 class Config
21 {
22 public:
23 static void Finalize(bool enable);
24
25 static void ParseServiceSet(void);
26 static void ParseServiceChain(void);
27
28 static void ParseAccess(ConfigParser &parser);
29 static void FreeAccess(void);
30 static void DumpAccess(StoreEntry *, const char *);
31
32 friend class AccessCheck;
33
34 public:
35 static bool Enabled; // true if at least one adaptation mechanism is
36
37 // these are global squid.conf options, documented elsewhere
38 static char *masterx_shared_name; // global TODO: do we need TheConfig?
39 static int service_iteration_limit;
40 static int send_client_ip;
41 static int send_username;
42 static int use_indirect_client;
43
44 // Options below are accessed via Icap::TheConfig or Ecap::TheConfig
45 // TODO: move ICAP-specific options to Icap::Config and add TheConfig
46 int onoff;
47 int service_failure_limit;
48 time_t oldest_service_failure;
49 int service_revival_delay;
50
51 static Notes metaHeaders; ///< The list of configured meta headers
52
53 typedef Vector<ServiceConfigPointer> ServiceConfigs;
54 ServiceConfigs serviceConfigs;
55
56 Config();
57 virtual ~Config();
58
59 void parseService(void);
60 void freeService(void);
61 void dumpService(StoreEntry *, const char *) const;
62 ServicePointer findService(const String&);
63
64 /**
65 * Creates and starts the adaptation services. In the case the adaptation
66 * mechanism is disabled then removes any reference to the services from
67 * access rules and service groups, and returns false.
68 * \return true if the services are ready and running, false otherwise
69 */
70 virtual bool finalize();
71
72 protected:
73 /// Removes any reference to the services from configuration
74 virtual void clear();
75
76 /// creates service configuration object that will parse and keep cfg info
77 virtual ServiceConfig *newServiceConfig() const;
78
79 /// Removes the given service from all service groups.
80 void removeService(const String& service);
81
82 /// Removes access rules of the given service or group
83 void removeRule(const String& id);
84
85 private:
86 Config(const Config &); // unsupported
87 Config &operator =(const Config &); // unsupported
88
89 virtual ServicePointer createService(const ServiceConfigPointer &cfg) = 0;
90
91 static void ParseServiceGroup(ServiceGroupPointer group);
92 static void FreeServiceGroups(void);
93 static void DumpServiceGroups(StoreEntry *, const char *);
94 };
95
96 } // namespace Adaptation
97
98 #endif /* SQUID_ADAPTATION__CONFIG_H */