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(HttpMsg
*virginHeader
, HttpRequest
*virginCause
,
25 const Adaptation::ServiceGroupPointer
&aGroup
);
28 // Adaptation::Initiate: asynchronous communication with the initiator
29 void noteInitiatorAborted();
31 // Adaptation::Initiator: asynchronous communication with the current launcher
32 virtual void noteAdaptationAnswer(HttpMsg
*message
);
33 virtual void noteAdaptationQueryAbort(bool final
);
36 // Adaptation::Initiate API implementation
38 virtual bool doneAll() const;
39 virtual void swanSong();
41 /// launches adaptation for the service selected by the plan
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
47 /// creates service filter for the current step
48 ServiceFilter
filter() const;
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
58 CBDATA_CLASS2(Iterator
);
61 } // namespace Adaptation
64 #endif /* SQUID_ADAPTATION__ITERATOR_H */