]> git.ipfire.org Git - thirdparty/squid.git/blob - src/adaptation/Iterator.h
Bug #2583 fix: pure virtual method called
[thirdparty/squid.git] / src / adaptation / Iterator.h
1 #ifndef SQUID_ADAPTATION__ITERATOR_H
2 #define SQUID_ADAPTATION__ITERATOR_H
3
4 #include "adaptation/Initiator.h"
5 #include "adaptation/Initiate.h"
6 #include "adaptation/ServiceGroups.h"
7
8 namespace Adaptation
9 {
10
11 /* Iterator is started by client or server Initiators. It iterates services
12 in a given group, starting transaction launcher for each service, according
13 to the service plan. Service plans support adaptation sets and chains.
14
15 Note: Initiate must be the first parent for cbdata to work. We use
16 a temporary InitiatorHolder/toCbdata hacks and do not call cbdata
17 operations on the initiator directly.
18 */
19
20 /// iterates services in ServiceGroup, starting adaptation launchers
21 class Iterator: public Initiate, public Initiator
22 {
23 public:
24 Iterator(HttpMsg *virginHeader, HttpRequest *virginCause,
25 const Adaptation::ServiceGroupPointer &aGroup);
26 virtual ~Iterator();
27
28 // Adaptation::Initiate: asynchronous communication with the initiator
29 void noteInitiatorAborted();
30
31 // Adaptation::Initiator: asynchronous communication with the current launcher
32 virtual void noteAdaptationAnswer(HttpMsg *message);
33 virtual void noteAdaptationQueryAbort(bool final);
34
35 protected:
36 // Adaptation::Initiate API implementation
37 virtual void start();
38 virtual bool doneAll() const;
39 virtual void swanSong();
40
41 /// launches adaptation for the service selected by the plan
42 void step();
43
44 /// replace the current group and plan with service-proposed ones if needed
45 bool updatePlan(bool adopt); // returns true iff the plan was replaced
46
47 /// creates service filter for the current step
48 ServiceFilter filter() const;
49
50 ServiceGroupPointer theGroup; ///< the service group we are iterating
51 ServicePlan thePlan; ///< which services to use and in what order
52 HttpMsg *theMsg; ///< the message being adapted (virgin for each step)
53 HttpRequest *theCause; ///< the cause of the original virgin message
54 CbcPointer<Adaptation::Initiate> theLauncher; ///< current transaction launcher
55 int iterations; ///< number of steps initiated
56 bool adapted; ///< whether the virgin message has been replaced
57
58 CBDATA_CLASS2(Iterator);
59 };
60
61 } // namespace Adaptation
62
63
64 #endif /* SQUID_ADAPTATION__ITERATOR_H */