1 #ifndef SQUID_ADAPTATION__SERVICE_H
2 #define SQUID_ADAPTATION__SERVICE_H
4 #include "AccessLogEntry.h"
5 #include "adaptation/Elements.h"
6 #include "adaptation/forward.h"
7 #include "adaptation/ServiceConfig.h"
8 #include "base/RefCount.h"
9 #include "SquidString.h"
11 // TODO: Move src/ICAP/ICAPServiceRep.h API comments here and update them
19 // manages adaptation service configuration in squid.conf
20 // specific adaptation mechanisms extend this class
21 class Service
: public RefCountable
24 typedef RefCount
<Service
> Pointer
;
28 explicit Service(const ServiceConfigPointer
&aConfig
);
31 virtual bool probed() const = 0; // see comments above
32 virtual bool broken() const;
33 virtual bool up() const = 0; // see comments above
35 virtual Initiate
*makeXactLauncher(HttpMsg
*virginHeader
, HttpRequest
*virginCause
, AccessLogEntry::Pointer
&alp
) = 0;
37 bool wants(const ServiceFilter
&filter
) const;
39 // the methods below can only be called on an up() service
40 virtual bool wantsUrl(const String
&urlPath
) const = 0;
42 // called by transactions to report service failure
43 virtual void noteFailure() = 0;
45 const ServiceConfig
&cfg() const { return *theConfig
; }
47 virtual void finalize(); // called after creation
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;
56 ServiceConfig
&writeableCfg() { return *theConfig
; }
59 ServiceConfigPointer theConfig
;
62 typedef Service::Pointer ServicePointer
;
64 typedef Vector
<Adaptation::ServicePointer
> Services
;
65 Services
&AllServices();
66 ServicePointer
FindService(const Service::Id
&key
);
68 /// detach all adaptation services from current configuration
69 void DetachServices();
71 } // namespace Adaptation
73 #endif /* SQUID_ADAPTATION__SERVICE_H */