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