]> git.ipfire.org Git - thirdparty/squid.git/blob - src/adaptation/Service.h
merge from trunk r12441
[thirdparty/squid.git] / src / adaptation / Service.h
1 #ifndef SQUID_ADAPTATION__SERVICE_H
2 #define SQUID_ADAPTATION__SERVICE_H
3
4 #include "SquidString.h"
5 #include "adaptation/forward.h"
6 #include "adaptation/Elements.h"
7 #include "adaptation/ServiceConfig.h"
8 #include "base/RefCount.h"
9
10 // TODO: Move src/ICAP/ICAPServiceRep.h API comments here and update them
11
12 class HttpMsg;
13 class HttpRequest;
14
15 namespace Adaptation
16 {
17
18 // manages adaptation service configuration in squid.conf
19 // specific adaptation mechanisms extend this class
20 class Service: public RefCountable
21 {
22 public:
23 typedef RefCount<Service> Pointer;
24 typedef String Id;
25
26 public:
27 explicit Service(const ServiceConfigPointer &aConfig);
28 virtual ~Service();
29
30 virtual bool probed() const = 0; // see comments above
31 virtual bool broken() const;
32 virtual bool up() const = 0; // see comments above
33
34 virtual Initiate *makeXactLauncher(HttpMsg *virginHeader, HttpRequest *virginCause) = 0;
35
36 bool wants(const ServiceFilter &filter) const;
37
38 // the methods below can only be called on an up() service
39 virtual bool wantsUrl(const String &urlPath) const = 0;
40
41 // called by transactions to report service failure
42 virtual void noteFailure() = 0;
43
44 const ServiceConfig &cfg() const { return *theConfig; }
45
46 virtual void finalize(); // called after creation
47
48 /// called when removed from the config; the service will be
49 /// auto-destroyed when the last refcounting user leaves
50 virtual void detach() = 0;
51 /// whether detached() was called
52 virtual bool detached() const = 0;
53
54 protected:
55 ServiceConfig &writeableCfg() { return *theConfig; }
56
57 private:
58 ServiceConfigPointer theConfig;
59 };
60
61 typedef Service::Pointer ServicePointer;
62
63 typedef Vector<Adaptation::ServicePointer> Services;
64 Services &AllServices();
65 ServicePointer FindService(const Service::Id &key);
66
67 /// detach all adaptation services from current configuration
68 void DetachServices();
69
70 } // namespace Adaptation
71
72 #endif /* SQUID_ADAPTATION__SERVICE_H */