]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/adaptation/Config.h
SourceFormat Enforcement
[thirdparty/squid.git] / src / adaptation / Config.h
index 9cd33baba5a55ab02d670ac92dda72b5ac367d3e..1341b080530de0f6d0f01c228c527d66a7608f72 100644 (file)
@@ -1,37 +1,36 @@
+/*
+ * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
+ *
+ * Squid software is distributed under GPLv2+ license and includes
+ * contributions from numerous individuals and organizations.
+ * Please see the COPYING and CONTRIBUTORS files for details.
+ */
+
 #ifndef SQUID_ADAPTATION__CONFIG_H
 #define SQUID_ADAPTATION__CONFIG_H
 
-#include "event.h"
-#include "AsyncCall.h"
+#include "acl/forward.h"
 #include "adaptation/Elements.h"
+#include "adaptation/forward.h"
+#include "base/AsyncCall.h"
+#include "event.h"
+#include "Notes.h"
+#include "SquidString.h"
 
-class acl_access;
 class ConfigParser;
-
-template <class C>
-class RefCount;
+class HttpRequest;
+class HttpReply;
 
 namespace Adaptation
 {
 
-class Service;
-class ServiceConfig;
-class Class;
-
-typedef RefCount<Service> ServicePointer;
-
-class ServiceGroup;
-class AccessRule;
-
 class Config
 {
 public:
     static void Finalize(bool enable);
-    static void DestroyConfig();
 
     static void ParseServiceSet(void);
-    static void FreeServiceSet(void);
-    static void DumpServiceSet(StoreEntry *, const char *);
+    static void ParseServiceChain(void);
 
     static void ParseAccess(ConfigParser &parser);
     static void FreeAccess(void);
@@ -42,13 +41,26 @@ public:
 public:
     static bool Enabled; // true if at least one adaptation mechanism is
 
+    // these are global squid.conf options, documented elsewhere
+    static char *masterx_shared_name; // global TODO: do we need TheConfig?
+    static int service_iteration_limit;
+    static int send_client_ip;
+    static int send_username;
+    static int use_indirect_client;
+
+    // Options below are accessed via Icap::TheConfig or Ecap::TheConfig
+    // TODO: move ICAP-specific options to Icap::Config and add TheConfig
     int onoff;
-    int send_client_ip;
-    int send_client_username;
     int service_failure_limit;
+    time_t oldest_service_failure;
     int service_revival_delay;
 
-    Vector<ServiceConfig*> serviceConfigs;
+    static Notes metaHeaders; ///< The list of configured meta headers
+
+    static bool needHistory; ///< HttpRequest adaptation history should recorded
+
+    typedef std::vector<ServiceConfigPointer> ServiceConfigs;
+    ServiceConfigs serviceConfigs;
 
     Config();
     virtual ~Config();
@@ -56,18 +68,41 @@ public:
     void parseService(void);
     void freeService(void);
     void dumpService(StoreEntry *, const char *) const;
-    ServicePointer findService(const String&);
-    Class * findClass(const String& key);
+    ServiceConfigPointer findServiceConfig(const String&);
+
+    /**
+     * Creates and starts the adaptation services. In the case the adaptation
+     * mechanism is disabled then removes any reference to the services from
+     * access rules and service groups, and returns false.
+     * \return true if the services are ready and running, false otherwise
+     */
+    virtual bool finalize();
+
+protected:
+    /// Removes any reference to the services  from configuration
+    virtual void clear();
 
-    virtual void finalize();
+    /// creates service configuration object that will parse and keep cfg info
+    virtual ServiceConfig *newServiceConfig() const;
+
+    /// Removes the given service from all service groups.
+    void removeService(const String& service);
+
+    /// Removes access rules of the given service or group
+    void removeRule(const String& id);
 
 private:
     Config(const Config &); // unsupported
     Config &operator =(const Config &); // unsupported
 
-    virtual ServicePointer createService(const ServiceConfig &cfg) = 0;
+    virtual ServicePointer createService(const ServiceConfigPointer &cfg) = 0;
+
+    static void ParseServiceGroup(ServiceGroupPointer group);
+    static void FreeServiceGroups(void);
+    static void DumpServiceGroups(StoreEntry *, const char *);
 };
 
 } // namespace Adaptation
 
 #endif /* SQUID_ADAPTATION__CONFIG_H */
+