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