]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- |
2 | // vim: ts=8 sw=2 smarttab | |
3 | /* | |
4 | * Ceph - scalable distributed file system | |
5 | * | |
6 | * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net> | |
7 | * | |
8 | * This is free software; you can redistribute it and/or | |
9 | * modify it under the terms of the GNU Lesser General Public | |
10 | * License version 2.1, as published by the Free Software | |
11 | * Foundation. See file COPYING. | |
12 | * | |
13 | */ | |
14 | ||
15 | #ifndef CEPH_MCOMMAND_H | |
16 | #define CEPH_MCOMMAND_H | |
17 | ||
18 | #include <vector> | |
19 | ||
20 | #include "msg/Message.h" | |
21 | ||
9f95a23c | 22 | class MCommand : public Message { |
11fdf7f2 | 23 | public: |
7c673cae | 24 | uuid_d fsid; |
9f95a23c | 25 | std::vector<std::string> cmd; |
7c673cae FG |
26 | |
27 | MCommand() | |
9f95a23c | 28 | : Message{MSG_COMMAND} {} |
7c673cae | 29 | MCommand(const uuid_d &f) |
9f95a23c | 30 | : Message{MSG_COMMAND}, |
7c673cae FG |
31 | fsid(f) { } |
32 | ||
33 | private: | |
34 | ~MCommand() override {} | |
35 | ||
9f95a23c | 36 | public: |
11fdf7f2 | 37 | std::string_view get_type_name() const override { return "command"; } |
9f95a23c | 38 | void print(std::ostream& o) const override { |
7c673cae FG |
39 | o << "command(tid " << get_tid() << ": "; |
40 | for (unsigned i=0; i<cmd.size(); i++) { | |
41 | if (i) o << ' '; | |
42 | o << cmd[i]; | |
43 | } | |
44 | o << ")"; | |
45 | } | |
46 | ||
47 | void encode_payload(uint64_t features) override { | |
11fdf7f2 TL |
48 | using ceph::encode; |
49 | encode(fsid, payload); | |
50 | encode(cmd, payload); | |
7c673cae FG |
51 | } |
52 | void decode_payload() override { | |
9f95a23c | 53 | using ceph::decode; |
11fdf7f2 TL |
54 | auto p = payload.cbegin(); |
55 | decode(fsid, p); | |
56 | decode(cmd, p); | |
7c673cae FG |
57 | } |
58 | }; | |
59 | ||
60 | #endif |