]> git.ipfire.org Git - thirdparty/squid.git/blame - src/adaptation/Iterator.h
Support adaptation sets and chains, including dynamic ICAP chains:
[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
8namespace 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
21class Iterator: public Initiate, public Initiator
22{
23public:
24 Iterator(Adaptation::Initiator *anInitiator,
25 HttpMsg *virginHeader, HttpRequest *virginCause,
26 const Adaptation::ServiceGroupPointer &aGroup);
27 virtual ~Iterator();
28
29 // Adaptation::Initiate: asynchronous communication with the initiator
30 void noteInitiatorAborted();
31
32 // Adaptation::Initiator: asynchronous communication with the current launcher
33 virtual void noteAdaptationAnswer(HttpMsg *message);
34 virtual void noteAdaptationQueryAbort(bool final);
35
36protected:
37 // Adaptation::Initiate API implementation
38 virtual void start();
39 virtual bool doneAll() const;
40 virtual void swanSong();
41
42 /// launches adaptation for the service selected by the plan
43 void step();
44
45 /// replace the current group and plan with service-proposed ones if needed
46 bool updatePlan(bool adopt); // returns true iff the plan was replaced
47
48 /// creates service filter for the current step
49 ServiceFilter filter() const;
50
51 ServiceGroupPointer theGroup; ///< the service group we are iterating
52 ServicePlan thePlan; ///< which services to use and in what order
53 HttpMsg *theMsg; ///< the message being adapted (virgin for each step)
54 HttpRequest *theCause; ///< the cause of the original virgin message
55 Adaptation::Initiate *theLauncher; ///< current transaction launcher
56 int iterations; ///< number of steps initiated
57 bool adapted; ///< whether the virgin message has been replaced
58
59 CBDATA_CLASS2(Iterator);
60};
61
62} // namespace Adaptation
63
64
65#endif /* SQUID_ADAPTATION__ITERATOR_H */