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