]> git.ipfire.org Git - thirdparty/squid.git/blob - src/adaptation/Initiate.h
SourceFormat Enforcement
[thirdparty/squid.git] / src / adaptation / Initiate.h
1 /*
2 * Copyright (C) 1996-2017 The Squid Software Foundation and contributors
3 *
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.
7 */
8
9 #ifndef SQUID_ADAPTATION__INITIATE_H
10 #define SQUID_ADAPTATION__INITIATE_H
11
12 #include "adaptation/forward.h"
13 #include "base/AsyncJob.h"
14 #include "base/CbcPointer.h"
15
16 namespace Adaptation
17 {
18
19 /*
20 * The Initiate is a common base for queries or transactions
21 * initiated by an Initiator. This interface exists to allow an
22 * initiator to signal its "initiatees" that it is aborting and no longer
23 * expecting an answer. The class is also handy for implementing common
24 * initiate actions such as maintaining and notifying the initiator.
25 *
26 * Initiate implementations must cbdata-protect themselves.
27 *
28 * This class could have been named Initiatee.
29 */
30 class Initiate: virtual public AsyncJob
31 {
32
33 public:
34 Initiate(const char *aTypeName);
35 virtual ~Initiate();
36
37 void initiator(const CbcPointer<Initiator> &i); ///< sets initiator
38
39 // communication with the initiator
40 virtual void noteInitiatorAborted() = 0;
41
42 protected:
43 void sendAnswer(const Answer &answer); // send to the initiator
44 void tellQueryAborted(bool final); // tell initiator
45 void clearInitiator(); // used by noteInitiatorAborted; TODO: make private
46
47 virtual void swanSong(); // internal cleanup
48
49 virtual const char *status() const; // for debugging
50
51 CbcPointer<Initiator> theInitiator;
52
53 private:
54 Initiate(const Initiate &); // no definition
55 Initiate &operator =(const Initiate &); // no definition
56 };
57
58 } // namespace Adaptation
59
60 #endif /* SQUID_ADAPTATION__INITIATE_H */
61