|
12 | 12 | namespace viam { |
13 | 13 | namespace sdk { |
14 | 14 |
|
15 | | -viam::app::v1::Frame LinkConfig::to_proto() const { |
16 | | - viam::app::v1::Frame frame; |
| 15 | +LinkConfig::LinkConfig(translation t, Orientation o, GeometryConfig gcfg, std::string parent) |
| 16 | + : translation_(std::move(t)), |
| 17 | + orientation_(std::move(o)), |
| 18 | + geometry_(std::move(gcfg)), |
| 19 | + parent_(std::move(parent)) {} |
17 | 20 |
|
18 | | - *frame.mutable_parent() = parent_; |
19 | | - *frame.mutable_geometry() = v2::to_proto(geometry_); |
20 | | - *frame.mutable_orientation() = v2::to_proto(orientation_); |
21 | | - *frame.mutable_translation() = v2::to_proto(translation_); |
22 | | - return frame; |
23 | | -}; |
24 | | - |
25 | | -LinkConfig LinkConfig::from_proto(const viam::app::v1::Frame& proto) { |
26 | | - LinkConfig lc; |
27 | | - |
28 | | - lc.parent_ = proto.parent(); |
29 | | - lc.translation_.x = proto.translation().x(); |
30 | | - lc.translation_.y = proto.translation().y(); |
31 | | - lc.translation_.z = proto.translation().z(); |
32 | | - |
33 | | - if (proto.has_orientation()) { |
34 | | - lc.orientation_ = v2::from_proto(proto.orientation()); |
35 | | - } |
36 | | - |
37 | | - if (proto.has_geometry()) { |
38 | | - lc.geometry_ = v2::from_proto(proto.geometry()); |
39 | | - } |
40 | | - |
41 | | - return lc; |
42 | | -}; |
43 | | - |
44 | | -translation LinkConfig::get_translation() const { |
| 21 | +const translation& LinkConfig::get_translation() const { |
45 | 22 | return translation_; |
46 | 23 | } |
47 | 24 |
|
48 | 25 | const Orientation& LinkConfig::get_orientation() const { |
49 | 26 | return orientation_; |
50 | 27 | } |
51 | 28 |
|
52 | | -GeometryConfig LinkConfig::get_geometry_config() const { |
| 29 | +const GeometryConfig& LinkConfig::get_geometry_config() const { |
53 | 30 | return geometry_; |
54 | 31 | } |
55 | 32 |
|
56 | | -std::string LinkConfig::get_parent() const { |
| 33 | +const std::string& LinkConfig::get_parent() const { |
57 | 34 | return parent_; |
58 | 35 | } |
59 | 36 |
|
| 37 | +namespace proto_convert_details { |
| 38 | + |
| 39 | +void to_proto<LinkConfig>::operator()(const LinkConfig& self, app::v1::Frame* proto) const { |
| 40 | + *(proto->mutable_parent()) = self.get_parent(); |
| 41 | + *(proto->mutable_geometry()) = v2::to_proto(self.get_geometry_config()); |
| 42 | + *(proto->mutable_orientation()) = v2::to_proto(self.get_orientation()); |
| 43 | + *(proto->mutable_translation()) = v2::to_proto(self.get_translation()); |
| 44 | +} |
| 45 | + |
| 46 | +LinkConfig from_proto<app::v1::Frame>::operator()(const app::v1::Frame* proto) const { |
| 47 | + return LinkConfig( |
| 48 | + v2::from_proto(proto->translation()), |
| 49 | + proto->has_orientation() ? v2::from_proto(proto->orientation()) : Orientation{}, |
| 50 | + proto->has_geometry() ? v2::from_proto(proto->geometry()) : GeometryConfig{}, |
| 51 | + proto->parent()); |
| 52 | +} |
| 53 | + |
| 54 | +} // namespace proto_convert_details |
60 | 55 | } // namespace sdk |
61 | 56 | } // namespace viam |
0 commit comments