]>
Commit | Line | Data |
---|---|---|
a68cf076 AR |
1 | #ifndef SQUID_ADAPTATION__SERVICE_H |
2 | #define SQUID_ADAPTATION__SERVICE_H | |
3 | ||
af0ded40 | 4 | #include "AccessLogEntry.h" |
a68cf076 | 5 | #include "adaptation/Elements.h" |
602d9612 | 6 | #include "adaptation/forward.h" |
d81a31f1 | 7 | #include "adaptation/ServiceConfig.h" |
8bf217bd | 8 | #include "base/RefCount.h" |
602d9612 | 9 | #include "SquidString.h" |
d81a31f1 AR |
10 | |
11 | // TODO: Move src/ICAP/ICAPServiceRep.h API comments here and update them | |
12 | ||
13 | class HttpMsg; | |
14 | class HttpRequest; | |
a68cf076 | 15 | |
26ac0430 AJ |
16 | namespace Adaptation |
17 | { | |
a68cf076 AR |
18 | |
19 | // manages adaptation service configuration in squid.conf | |
20 | // specific adaptation mechanisms extend this class | |
d81a31f1 | 21 | class Service: public RefCountable |
a68cf076 AR |
22 | { |
23 | public: | |
d81a31f1 | 24 | typedef RefCount<Service> Pointer; |
62c7f90e | 25 | typedef String Id; |
d81a31f1 AR |
26 | |
27 | public: | |
6666da11 | 28 | explicit Service(const ServiceConfigPointer &aConfig); |
a68cf076 AR |
29 | virtual ~Service(); |
30 | ||
d81a31f1 | 31 | virtual bool probed() const = 0; // see comments above |
201438ac | 32 | virtual bool broken() const; |
d81a31f1 | 33 | virtual bool up() const = 0; // see comments above |
a68cf076 | 34 | |
af0ded40 | 35 | virtual Initiate *makeXactLauncher(HttpMsg *virginHeader, HttpRequest *virginCause, AccessLogEntry::Pointer &alp) = 0; |
a68cf076 | 36 | |
a22e6cd3 AR |
37 | bool wants(const ServiceFilter &filter) const; |
38 | ||
d81a31f1 AR |
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 | ||
e1e90d26 | 45 | const ServiceConfig &cfg() const { return *theConfig; } |
a68cf076 | 46 | |
62c7f90e AR |
47 | virtual void finalize(); // called after creation |
48 | ||
76fc7e57 AJ |
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 | ||
a68cf076 | 55 | protected: |
e1e90d26 | 56 | ServiceConfig &writeableCfg() { return *theConfig; } |
d81a31f1 AR |
57 | |
58 | private: | |
e1e90d26 | 59 | ServiceConfigPointer theConfig; |
a68cf076 AR |
60 | }; |
61 | ||
d81a31f1 AR |
62 | typedef Service::Pointer ServicePointer; |
63 | ||
62c7f90e | 64 | typedef Vector<Adaptation::ServicePointer> Services; |
82afb125 FC |
65 | Services &AllServices(); |
66 | ServicePointer FindService(const Service::Id &key); | |
62c7f90e | 67 | |
76fc7e57 | 68 | /// detach all adaptation services from current configuration |
82afb125 | 69 | void DetachServices(); |
76fc7e57 | 70 | |
a68cf076 AR |
71 | } // namespace Adaptation |
72 | ||
73 | #endif /* SQUID_ADAPTATION__SERVICE_H */ |