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