]>
Commit | Line | Data |
---|---|---|
bbc27441 | 1 | /* |
4ac4a490 | 2 | * Copyright (C) 1996-2017 The Squid Software Foundation and contributors |
bbc27441 AJ |
3 | * |
4 | * Squid software is distributed under GPLv2+ license and includes | |
5 | * contributions from numerous individuals and organizations. | |
6 | * Please see the COPYING and CONTRIBUTORS files for details. | |
7 | */ | |
8 | ||
a68cf076 AR |
9 | #ifndef SQUID_ADAPTATION__SERVICE_H |
10 | #define SQUID_ADAPTATION__SERVICE_H | |
11 | ||
af0ded40 | 12 | #include "AccessLogEntry.h" |
a68cf076 | 13 | #include "adaptation/Elements.h" |
602d9612 | 14 | #include "adaptation/forward.h" |
d81a31f1 | 15 | #include "adaptation/ServiceConfig.h" |
8bf217bd | 16 | #include "base/RefCount.h" |
602d9612 | 17 | #include "SquidString.h" |
d81a31f1 AR |
18 | |
19 | // TODO: Move src/ICAP/ICAPServiceRep.h API comments here and update them | |
20 | ||
21 | class HttpMsg; | |
22 | class HttpRequest; | |
a68cf076 | 23 | |
26ac0430 AJ |
24 | namespace Adaptation |
25 | { | |
a68cf076 AR |
26 | |
27 | // manages adaptation service configuration in squid.conf | |
28 | // specific adaptation mechanisms extend this class | |
d81a31f1 | 29 | class Service: public RefCountable |
a68cf076 AR |
30 | { |
31 | public: | |
d81a31f1 | 32 | typedef RefCount<Service> Pointer; |
62c7f90e | 33 | typedef String Id; |
d81a31f1 AR |
34 | |
35 | public: | |
6666da11 | 36 | explicit Service(const ServiceConfigPointer &aConfig); |
a68cf076 AR |
37 | virtual ~Service(); |
38 | ||
d81a31f1 | 39 | virtual bool probed() const = 0; // see comments above |
201438ac | 40 | virtual bool broken() const; |
d81a31f1 | 41 | virtual bool up() const = 0; // see comments above |
a68cf076 | 42 | |
af0ded40 | 43 | virtual Initiate *makeXactLauncher(HttpMsg *virginHeader, HttpRequest *virginCause, AccessLogEntry::Pointer &alp) = 0; |
a68cf076 | 44 | |
a22e6cd3 AR |
45 | bool wants(const ServiceFilter &filter) const; |
46 | ||
d81a31f1 | 47 | // the methods below can only be called on an up() service |
51b5dcf5 | 48 | virtual bool wantsUrl(const SBuf &urlPath) const = 0; |
d81a31f1 AR |
49 | |
50 | // called by transactions to report service failure | |
51 | virtual void noteFailure() = 0; | |
52 | ||
e1e90d26 | 53 | const ServiceConfig &cfg() const { return *theConfig; } |
a68cf076 | 54 | |
62c7f90e AR |
55 | virtual void finalize(); // called after creation |
56 | ||
76fc7e57 AJ |
57 | /// called when removed from the config; the service will be |
58 | /// auto-destroyed when the last refcounting user leaves | |
59 | virtual void detach() = 0; | |
60 | /// whether detached() was called | |
61 | virtual bool detached() const = 0; | |
62 | ||
a68cf076 | 63 | protected: |
e1e90d26 | 64 | ServiceConfig &writeableCfg() { return *theConfig; } |
d81a31f1 AR |
65 | |
66 | private: | |
e1e90d26 | 67 | ServiceConfigPointer theConfig; |
a68cf076 AR |
68 | }; |
69 | ||
d81a31f1 AR |
70 | typedef Service::Pointer ServicePointer; |
71 | ||
c8ea3cc0 | 72 | typedef std::vector<Adaptation::ServicePointer> Services; |
82afb125 FC |
73 | Services &AllServices(); |
74 | ServicePointer FindService(const Service::Id &key); | |
62c7f90e | 75 | |
76fc7e57 | 76 | /// detach all adaptation services from current configuration |
82afb125 | 77 | void DetachServices(); |
76fc7e57 | 78 | |
a68cf076 AR |
79 | } // namespace Adaptation |
80 | ||
81 | #endif /* SQUID_ADAPTATION__SERVICE_H */ | |
f53969cc | 82 |