]> git.ipfire.org Git - thirdparty/squid.git/blob - src/adaptation/Initiator.h
SourceFormat: Moved Adaptation::Answer class to its dedicated source files.
[thirdparty/squid.git] / src / adaptation / Initiator.h
1 #ifndef SQUID_ADAPTATION__INITIATOR_H
2 #define SQUID_ADAPTATION__INITIATOR_H
3
4 #include "adaptation/forward.h"
5 #include "base/AsyncJob.h"
6 #include "base/CbcPointer.h"
7
8 /*
9 * The ICAP Initiator is an ICAP vectoring point that initates ICAP
10 * transactions. This interface exists to allow ICAP transactions to
11 * signal their initiators that they have the answer from the ICAP server
12 * or that the ICAP query has aborted and there will be no answer. It
13 * is also handy for implementing common initiator actions such as starting
14 * or aborting an ICAP transaction.
15 */
16
17 namespace Adaptation
18 {
19
20 class Initiator: virtual public AsyncJob
21 {
22 public:
23 Initiator(): AsyncJob("Initiator") {}
24 virtual ~Initiator() {}
25
26 /// called with the initial adaptation decision (adapt, block, error);
27 /// virgin and/or adapted body transmission may continue after this
28 virtual void noteAdaptationAnswer(const Answer &answer) = 0;
29
30 protected:
31 ///< starts freshly created initiate and returns a safe pointer to it
32 CbcPointer<Initiate> initiateAdaptation(Initiate *x);
33
34 /// clears the pointer (does not call announceInitiatorAbort)
35 void clearAdaptation(CbcPointer<Initiate> &x);
36
37 /// inform the transaction about abnormal termination and clear the pointer
38 void announceInitiatorAbort(CbcPointer<Initiate> &x);
39
40 /// Must(initiated(initiate)) instead of Must(initiate.set()), for clarity
41 bool initiated(const CbcPointer<AsyncJob> &job) const { return job.set(); }
42 };
43
44 } // namespace Adaptation
45
46 #endif /* SQUID_ADAPTATION__INITIATOR_H */