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