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