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(const Answer
&answer
);
35 // Adaptation::Initiate API implementation
37 virtual bool doneAll() const;
38 virtual void swanSong();
40 /// launches adaptation for the service selected by the plan
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
46 /// creates service filter for the current step
47 ServiceFilter
filter() const;
49 void handleAdaptedHeader(HttpMsg
*msg
);
50 void handleAdaptationBlock(const Answer
&answer
);
51 void handleAdaptationError(bool final
);
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
61 CBDATA_CLASS2(Iterator
);
64 } // namespace Adaptation
67 #endif /* SQUID_ADAPTATION__ITERATOR_H */