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"
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.
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
20 operations on the initiator directly.
23 /// iterates services in ServiceGroup, starting adaptation launchers
24 class Iterator
: public Initiate
, public Initiator
27 Iterator(HttpMsg
*virginHeader
, HttpRequest
*virginCause
,
28 const Adaptation::ServiceGroupPointer
&aGroup
);
31 // Adaptation::Initiate: asynchronous communication with the initiator
32 void noteInitiatorAborted();
34 // Adaptation::Initiator: asynchronous communication with the current launcher
35 virtual void noteAdaptationAnswer(const Answer
&answer
);
38 // Adaptation::Initiate API implementation
40 virtual bool doneAll() const;
41 virtual void swanSong();
43 /// launches adaptation for the service selected by the plan
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
49 /// creates service filter for the current step
50 ServiceFilter
filter() const;
52 void handleAdaptedHeader(HttpMsg
*msg
);
53 void handleAdaptationBlock(const Answer
&answer
);
54 void handleAdaptationError(bool final
);
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
60 CbcPointer
<Adaptation::Initiate
> theLauncher
; ///< current transaction launcher
61 int iterations
; ///< number of steps initiated
62 bool adapted
; ///< whether the virgin message has been replaced
64 CBDATA_CLASS2(Iterator
);
67 } // namespace Adaptation
69 #endif /* SQUID_ADAPTATION__ITERATOR_H */