]> git.ipfire.org Git - thirdparty/squid.git/blob - src/adaptation/Service.h
Merged from trunk.
[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 "RefCount.h"
6 #include "adaptation/forward.h"
7 #include "adaptation/Elements.h"
8 #include "adaptation/ServiceConfig.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 // manages adaptation service configuration in squid.conf
18 // specific adaptation mechanisms extend this class
19 class Service: public RefCountable
20 {
21 public:
22 typedef RefCount<Service> Pointer;
23 typedef String Id;
24
25 public:
26 Service(const ServiceConfig &aConfig);
27 virtual ~Service();
28
29 // call when the service is no longer needed or valid
30 virtual void invalidate() = 0;
31
32 virtual bool probed() const = 0; // see comments above
33 virtual bool broken() const;
34 virtual bool up() const = 0; // see comments above
35
36 virtual Initiate *makeXactLauncher(Initiator *, HttpMsg *virginHeader, HttpRequest *virginCause) = 0;
37
38 typedef void Callback(void *data, Pointer &service);
39 void callWhenReady(Callback *cb, void *data);
40
41 // the methods below can only be called on an up() service
42 virtual bool wantsUrl(const String &urlPath) const = 0;
43
44 // called by transactions to report service failure
45 virtual void noteFailure() = 0;
46
47 const ServiceConfig &cfg() const { return theConfig; }
48
49 virtual void finalize(); // called after creation
50
51 protected:
52 ServiceConfig &writeableCfg() { return theConfig; }
53
54 private:
55 ServiceConfig theConfig;
56 };
57
58 typedef Service::Pointer ServicePointer;
59
60 typedef Vector<Adaptation::ServicePointer> Services;
61 extern Services &AllServices();
62 extern ServicePointer FindService(const Service::Id &key);
63
64 } // namespace Adaptation
65
66 #endif /* SQUID_ADAPTATION__SERVICE_H */