]>
Commit | Line | Data |
---|---|---|
a22e6cd3 AR |
1 | #ifndef SQUID_ADAPTATION__ITERATOR_H |
2 | #define SQUID_ADAPTATION__ITERATOR_H | |
3 | ||
af0ded40 | 4 | #include "AccessLogEntry.h" |
a22e6cd3 | 5 | #include "adaptation/Initiate.h" |
602d9612 | 6 | #include "adaptation/Initiator.h" |
a22e6cd3 AR |
7 | #include "adaptation/ServiceGroups.h" |
8 | ||
1adcebc3 AR |
9 | class HttpMsg; |
10 | class HttpRequest; | |
11 | ||
a22e6cd3 AR |
12 | namespace Adaptation |
13 | { | |
14 | ||
15 | /* Iterator is started by client or server Initiators. It iterates services | |
16 | in a given group, starting transaction launcher for each service, according | |
17 | to the service plan. Service plans support adaptation sets and chains. | |
18 | ||
19 | Note: Initiate must be the first parent for cbdata to work. We use | |
20 | a temporary InitiatorHolder/toCbdata hacks and do not call cbdata | |
e1381638 | 21 | operations on the initiator directly. |
a22e6cd3 AR |
22 | */ |
23 | ||
24 | /// iterates services in ServiceGroup, starting adaptation launchers | |
25 | class Iterator: public Initiate, public Initiator | |
26 | { | |
27 | public: | |
4299f876 | 28 | Iterator(HttpMsg *virginHeader, HttpRequest *virginCause, |
af0ded40 | 29 | AccessLogEntry::Pointer &alp, |
e1381638 | 30 | const Adaptation::ServiceGroupPointer &aGroup); |
a22e6cd3 AR |
31 | virtual ~Iterator(); |
32 | ||
33 | // Adaptation::Initiate: asynchronous communication with the initiator | |
34 | void noteInitiatorAborted(); | |
35 | ||
36 | // Adaptation::Initiator: asynchronous communication with the current launcher | |
3af10ac0 | 37 | virtual void noteAdaptationAnswer(const Answer &answer); |
a22e6cd3 AR |
38 | |
39 | protected: | |
40 | // Adaptation::Initiate API implementation | |
41 | virtual void start(); | |
42 | virtual bool doneAll() const; | |
43 | virtual void swanSong(); | |
44 | ||
45 | /// launches adaptation for the service selected by the plan | |
46 | void step(); | |
47 | ||
48 | /// replace the current group and plan with service-proposed ones if needed | |
49 | bool updatePlan(bool adopt); // returns true iff the plan was replaced | |
50 | ||
51 | /// creates service filter for the current step | |
52 | ServiceFilter filter() const; | |
53 | ||
3af10ac0 AR |
54 | void handleAdaptedHeader(HttpMsg *msg); |
55 | void handleAdaptationBlock(const Answer &answer); | |
56 | void handleAdaptationError(bool final); | |
57 | ||
a22e6cd3 AR |
58 | ServiceGroupPointer theGroup; ///< the service group we are iterating |
59 | ServicePlan thePlan; ///< which services to use and in what order | |
60 | HttpMsg *theMsg; ///< the message being adapted (virgin for each step) | |
61 | HttpRequest *theCause; ///< the cause of the original virgin message | |
af0ded40 | 62 | AccessLogEntry::Pointer al; ///< info for the future access.log entry |
4299f876 | 63 | CbcPointer<Adaptation::Initiate> theLauncher; ///< current transaction launcher |
a22e6cd3 AR |
64 | int iterations; ///< number of steps initiated |
65 | bool adapted; ///< whether the virgin message has been replaced | |
66 | ||
67 | CBDATA_CLASS2(Iterator); | |
68 | }; | |
69 | ||
70 | } // namespace Adaptation | |
71 | ||
a22e6cd3 | 72 | #endif /* SQUID_ADAPTATION__ITERATOR_H */ |