]>
Commit | Line | Data |
---|---|---|
a68cf076 AR |
1 | #ifndef SQUID_ADAPTATION__SERVICE_H |
2 | #define SQUID_ADAPTATION__SERVICE_H | |
3 | ||
a68cf076 | 4 | #include "adaptation/Elements.h" |
602d9612 | 5 | #include "adaptation/forward.h" |
d81a31f1 | 6 | #include "adaptation/ServiceConfig.h" |
8bf217bd | 7 | #include "base/RefCount.h" |
602d9612 | 8 | #include "SquidString.h" |
d81a31f1 AR |
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: | |
6666da11 | 27 | explicit Service(const ServiceConfigPointer &aConfig); |
a68cf076 AR |
28 | virtual ~Service(); |
29 | ||
d81a31f1 | 30 | virtual bool probed() const = 0; // see comments above |
201438ac | 31 | virtual bool broken() const; |
d81a31f1 | 32 | virtual bool up() const = 0; // see comments above |
a68cf076 | 33 | |
4299f876 | 34 | virtual Initiate *makeXactLauncher(HttpMsg *virginHeader, HttpRequest *virginCause) = 0; |
a68cf076 | 35 | |
a22e6cd3 AR |
36 | bool wants(const ServiceFilter &filter) const; |
37 | ||
d81a31f1 AR |
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 | ||
e1e90d26 | 44 | const ServiceConfig &cfg() const { return *theConfig; } |
a68cf076 | 45 | |
62c7f90e AR |
46 | virtual void finalize(); // called after creation |
47 | ||
76fc7e57 AJ |
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 | ||
a68cf076 | 54 | protected: |
e1e90d26 | 55 | ServiceConfig &writeableCfg() { return *theConfig; } |
d81a31f1 AR |
56 | |
57 | private: | |
e1e90d26 | 58 | ServiceConfigPointer theConfig; |
a68cf076 AR |
59 | }; |
60 | ||
d81a31f1 AR |
61 | typedef Service::Pointer ServicePointer; |
62 | ||
62c7f90e | 63 | typedef Vector<Adaptation::ServicePointer> Services; |
82afb125 FC |
64 | Services &AllServices(); |
65 | ServicePointer FindService(const Service::Id &key); | |
62c7f90e | 66 | |
76fc7e57 | 67 | /// detach all adaptation services from current configuration |
82afb125 | 68 | void DetachServices(); |
76fc7e57 | 69 | |
a68cf076 AR |
70 | } // namespace Adaptation |
71 | ||
72 | #endif /* SQUID_ADAPTATION__SERVICE_H */ |