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