]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/adaptation/Service.h
1 #ifndef SQUID_ADAPTATION__SERVICE_H
2 #define SQUID_ADAPTATION__SERVICE_H
4 #include "SquidString.h"
6 #include "adaptation/forward.h"
7 #include "adaptation/Elements.h"
8 #include "adaptation/ServiceConfig.h"
10 // TODO: Move src/ICAP/ICAPServiceRep.h API comments here and update them
18 // manages adaptation service configuration in squid.conf
19 // specific adaptation mechanisms extend this class
20 class Service
: public RefCountable
23 typedef RefCount
<Service
> Pointer
;
27 Service(const ServiceConfig
&aConfig
);
30 virtual bool probed() const = 0; // see comments above
31 virtual bool broken() const;
32 virtual bool up() const = 0; // see comments above
34 virtual Initiate
*makeXactLauncher(Initiator
*, HttpMsg
*virginHeader
, HttpRequest
*virginCause
) = 0;
36 bool wants(const ServiceFilter
&filter
) const;
38 // the methods below can only be called on an up() service
39 virtual bool wantsUrl(const String
&urlPath
) const = 0;
41 // called by transactions to report service failure
42 virtual void noteFailure() = 0;
44 const ServiceConfig
&cfg() const { return theConfig
; }
46 virtual void finalize(); // called after creation
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;
55 ServiceConfig
&writeableCfg() { return theConfig
; }
58 ServiceConfig theConfig
;
61 typedef Service::Pointer ServicePointer
;
63 typedef Vector
<Adaptation::ServicePointer
> Services
;
64 extern Services
&AllServices();
65 extern ServicePointer
FindService(const Service::Id
&key
);
67 /// detach all adaptation services from current configuration
68 extern void DetachServices();
70 } // namespace Adaptation
72 #endif /* SQUID_ADAPTATION__SERVICE_H */