]>
Commit | Line | Data |
---|---|---|
8822ebee AR |
1 | /* |
2 | * $Id$ | |
3 | * | |
4 | * DEBUG: section 16 Cache Manager API | |
5 | * | |
6 | */ | |
7 | ||
f7f3304a | 8 | #include "squid.h" |
8822ebee AR |
9 | #include "base/TextException.h" |
10 | #include "CacheManager.h" | |
11 | #include "ipc/Messages.h" | |
12 | #include "ipc/TypedMsgHdr.h" | |
13 | #include "mgr/ActionCreator.h" | |
14 | #include "mgr/ActionProfile.h" | |
15 | #include "mgr/Response.h" | |
16 | ||
51ea0904 CT |
17 | Mgr::Response::Response(unsigned int aRequestId, Action::Pointer anAction): |
18 | Ipc::Response(aRequestId), action(anAction) | |
8822ebee | 19 | { |
51ea0904 | 20 | Must(!action || action->name()); // if there is an action, it must be named |
8822ebee AR |
21 | } |
22 | ||
51ea0904 | 23 | Mgr::Response::Response(const Response& response): |
8fb5a96c | 24 | Ipc::Response(response.requestId), action(response.action) |
8822ebee | 25 | { |
8822ebee AR |
26 | } |
27 | ||
51ea0904 | 28 | Mgr::Response::Response(const Ipc::TypedMsgHdr& msg): |
8fb5a96c | 29 | Ipc::Response(0) |
8822ebee AR |
30 | { |
31 | msg.checkType(Ipc::mtCacheMgrResponse); | |
32 | msg.getPod(requestId); | |
33 | Must(requestId != 0); | |
34 | ||
35 | if (msg.hasMoreData()) { | |
36 | String actionName; | |
37 | msg.getString(actionName); | |
38 | action = CacheManager::GetInstance()->createNamedAction(actionName.termedBuf()); | |
39 | Must(hasAction()); | |
40 | action->unpack(msg); | |
41 | } | |
42 | } | |
43 | ||
44 | void | |
45 | Mgr::Response::pack(Ipc::TypedMsgHdr& msg) const | |
46 | { | |
47 | Must(requestId != 0); | |
48 | msg.setType(Ipc::mtCacheMgrResponse); | |
49 | msg.putPod(requestId); | |
50 | if (hasAction()) { | |
51 | msg.putString(action->name()); | |
52 | action->pack(msg); | |
53 | } | |
54 | } | |
55 | ||
51ea0904 CT |
56 | Ipc::Response::Pointer |
57 | Mgr::Response::clone() const | |
58 | { | |
59 | return new Response(*this); | |
60 | } | |
61 | ||
8822ebee AR |
62 | bool |
63 | Mgr::Response::hasAction() const | |
64 | { | |
65 | return action != NULL; | |
66 | } | |
67 | ||
68 | const Mgr::Action& | |
69 | Mgr::Response::getAction() const | |
70 | { | |
71 | Must(hasAction()); | |
72 | return *action; | |
73 | } |