]> git.ipfire.org Git - thirdparty/squid.git/blob - src/adaptation/Iterator.h
Support libecap v0.2.0; fixed eCAP body handling and logging.
[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(const Answer &answer);
33
34 protected:
35 // Adaptation::Initiate API implementation
36 virtual void start();
37 virtual bool doneAll() const;
38 virtual void swanSong();
39
40 /// launches adaptation for the service selected by the plan
41 void step();
42
43 /// replace the current group and plan with service-proposed ones if needed
44 bool updatePlan(bool adopt); // returns true iff the plan was replaced
45
46 /// creates service filter for the current step
47 ServiceFilter filter() const;
48
49 void handleAdaptedHeader(HttpMsg *msg);
50 void handleAdaptationBlock(const Answer &answer);
51 void handleAdaptationError(bool final);
52
53 ServiceGroupPointer theGroup; ///< the service group we are iterating
54 ServicePlan thePlan; ///< which services to use and in what order
55 HttpMsg *theMsg; ///< the message being adapted (virgin for each step)
56 HttpRequest *theCause; ///< the cause of the original virgin message
57 CbcPointer<Adaptation::Initiate> theLauncher; ///< current transaction launcher
58 int iterations; ///< number of steps initiated
59 bool adapted; ///< whether the virgin message has been replaced
60
61 CBDATA_CLASS2(Iterator);
62 };
63
64 } // namespace Adaptation
65
66
67 #endif /* SQUID_ADAPTATION__ITERATOR_H */