2 * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
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.
9 #ifndef SQUID_ADAPTATION__SERVICE_H
10 #define SQUID_ADAPTATION__SERVICE_H
12 #include "AccessLogEntry.h"
13 #include "adaptation/Elements.h"
14 #include "adaptation/forward.h"
15 #include "adaptation/ServiceConfig.h"
16 #include "base/RefCount.h"
17 #include "SquidString.h"
19 // TODO: Move src/ICAP/ICAPServiceRep.h API comments here and update them
27 // manages adaptation service configuration in squid.conf
28 // specific adaptation mechanisms extend this class
29 class Service
: public RefCountable
32 typedef RefCount
<Service
> Pointer
;
36 explicit Service(const ServiceConfigPointer
&aConfig
);
39 virtual bool probed() const = 0; // see comments above
40 virtual bool broken() const;
41 virtual bool up() const = 0; // see comments above
43 virtual Initiate
*makeXactLauncher(HttpMsg
*virginHeader
, HttpRequest
*virginCause
, AccessLogEntry::Pointer
&alp
) = 0;
45 bool wants(const ServiceFilter
&filter
) const;
47 // the methods below can only be called on an up() service
48 virtual bool wantsUrl(const SBuf
&urlPath
) const = 0;
50 // called by transactions to report service failure
51 virtual void noteFailure() = 0;
53 const ServiceConfig
&cfg() const { return *theConfig
; }
55 virtual void finalize(); // called after creation
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;
64 ServiceConfig
&writeableCfg() { return *theConfig
; }
67 ServiceConfigPointer theConfig
;
70 typedef Service::Pointer ServicePointer
;
72 typedef std::vector
<Adaptation::ServicePointer
> Services
;
73 Services
&AllServices();
74 ServicePointer
FindService(const Service::Id
&key
);
76 /// detach all adaptation services from current configuration
77 void DetachServices();
79 } // namespace Adaptation
81 #endif /* SQUID_ADAPTATION__SERVICE_H */