1 #ifndef SQUID_ADAPTATION__ITERATOR_H
2 #define SQUID_ADAPTATION__ITERATOR_H
4 #include "adaptation/Initiator.h"
5 #include "adaptation/Initiate.h"
6 #include "adaptation/ServiceGroups.h"
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.
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.
20 /// iterates services in ServiceGroup, starting adaptation launchers
21 class Iterator
: public Initiate
, public Initiator
24 Iterator(Adaptation::Initiator
*anInitiator
,
25 HttpMsg
*virginHeader
, HttpRequest
*virginCause
,
26 const Adaptation::ServiceGroupPointer
&aGroup
);
29 // Adaptation::Initiate: asynchronous communication with the initiator
30 void noteInitiatorAborted();
32 // Adaptation::Initiator: asynchronous communication with the current launcher
33 virtual void noteAdaptationAnswer(HttpMsg
*message
);
34 virtual void noteAdaptationQueryAbort(bool final
);
37 // Adaptation::Initiate API implementation
39 virtual bool doneAll() const;
40 virtual void swanSong();
42 /// launches adaptation for the service selected by the plan
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
48 /// creates service filter for the current step
49 ServiceFilter
filter() const;
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
59 CBDATA_CLASS2(Iterator
);
62 } // namespace Adaptation
65 #endif /* SQUID_ADAPTATION__ITERATOR_H */