]>
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
15 namespace Adaptation
{
17 // manages adaptation service configuration in squid.conf
18 // specific adaptation mechanisms extend this class
19 class Service
: public RefCountable
22 typedef RefCount
<Service
> Pointer
;
26 Service(const ServiceConfig
&aConfig
);
29 // call when the service is no longer needed or valid
30 virtual void invalidate() = 0;
32 virtual bool probed() const = 0; // see comments above
33 virtual bool broken() const = 0; // see comments above
34 virtual bool up() const = 0; // see comments above
36 virtual Initiate
*makeXactLauncher(Initiator
*, HttpMsg
*virginHeader
, HttpRequest
*virginCause
) = 0;
38 typedef void Callback(void *data
, Pointer
&service
);
39 void callWhenReady(Callback
*cb
, void *data
);
41 // the methods below can only be called on an up() service
42 virtual bool wantsUrl(const String
&urlPath
) const = 0;
44 // called by transactions to report service failure
45 virtual void noteFailure() = 0;
47 const ServiceConfig
&cfg() const { return theConfig
; }
49 virtual void finalize(); // called after creation
52 ServiceConfig
&writeableCfg() { return theConfig
; }
55 ServiceConfig theConfig
;
58 typedef Service::Pointer ServicePointer
;
60 typedef Vector
<Adaptation::ServicePointer
> Services
;
61 extern Services
&AllServices();
62 extern ServicePointer
FindService(const Service::Id
&key
);
64 } // namespace Adaptation
66 #endif /* SQUID_ADAPTATION__SERVICE_H */