Skip to content

Commit 7bd33dd

Browse files
committed
rename to _impl
1 parent 0e9ccd5 commit 7bd33dd

28 files changed

+133
-123
lines changed

src/viam/sdk/common/client_helper.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class ClientHelper {
8585
debug_key_ = *value.get<std::string>();
8686
}
8787

88-
proto_convert_details::to_proto<ProtoStruct>{}(extra, request_.mutable_extra());
88+
proto_convert_details::to_proto_impl<ProtoStruct>{}(extra, request_.mutable_extra());
8989
return with(std::forward<RequestSetupCallable>(rsc));
9090
}
9191

src/viam/sdk/common/linear_algebra.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ Vector3& Vector3::set_z(double z) {
3636

3737
namespace proto_convert_details {
3838

39-
void to_proto<Vector3>::operator()(const Vector3& self, common::v1::Vector3* proto) const {
39+
void to_proto_impl<Vector3>::operator()(const Vector3& self, common::v1::Vector3* proto) const {
4040
proto->set_x(self.x());
4141
proto->set_y(self.y());
4242
proto->set_z(self.z());
4343
}
4444

45-
Vector3 from_proto<common::v1::Vector3>::operator()(const common::v1::Vector3* proto) const {
45+
Vector3 from_proto_impl<common::v1::Vector3>::operator()(const common::v1::Vector3* proto) const {
4646
return {proto->x(), proto->y(), proto->z()};
4747
}
4848

src/viam/sdk/common/linear_algebra.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ struct Vector3 {
4141
namespace proto_convert_details {
4242

4343
template <>
44-
struct to_proto<Vector3> {
44+
struct to_proto_impl<Vector3> {
4545
void operator()(const Vector3&, common::v1::Vector3*) const;
4646
};
4747

4848
template <>
49-
struct from_proto<common::v1::Vector3> {
49+
struct from_proto_impl<common::v1::Vector3> {
5050
Vector3 operator()(const common::v1::Vector3*) const;
5151
};
5252

src/viam/sdk/common/pose.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ std::ostream& operator<<(std::ostream& os, const pose_in_frame& v) {
1616

1717
namespace proto_convert_details {
1818

19-
void to_proto<pose>::operator()(const pose& self, common::v1::Pose* proto) const {
19+
void to_proto_impl<pose>::operator()(const pose& self, common::v1::Pose* proto) const {
2020
proto->set_x(self.coordinates.x);
2121
proto->set_y(self.coordinates.y);
2222
proto->set_z(self.coordinates.z);
@@ -26,7 +26,7 @@ void to_proto<pose>::operator()(const pose& self, common::v1::Pose* proto) const
2626
proto->set_theta(self.theta);
2727
}
2828

29-
pose from_proto<common::v1::Pose>::operator()(const common::v1::Pose* proto) const {
29+
pose from_proto_impl<common::v1::Pose>::operator()(const common::v1::Pose* proto) const {
3030
pose pose;
3131
pose.coordinates.x = proto->x();
3232
pose.coordinates.y = proto->y();
@@ -39,19 +39,19 @@ pose from_proto<common::v1::Pose>::operator()(const common::v1::Pose* proto) con
3939
return pose;
4040
}
4141

42-
void to_proto<pose_in_frame>::operator()(const pose_in_frame& self,
43-
common::v1::PoseInFrame* pif) const {
42+
void to_proto_impl<pose_in_frame>::operator()(const pose_in_frame& self,
43+
common::v1::PoseInFrame* pif) const {
4444
*(pif->mutable_reference_frame()) = self.reference_frame;
4545
common::v1::Pose proto_pose;
46-
to_proto<pose>{}(self.pose, &proto_pose);
46+
to_proto_impl<pose>{}(self.pose, &proto_pose);
4747
*(pif->mutable_pose()) = std::move(proto_pose);
4848
};
4949

50-
pose_in_frame from_proto<common::v1::PoseInFrame>::operator()(
50+
pose_in_frame from_proto_impl<common::v1::PoseInFrame>::operator()(
5151
const common::v1::PoseInFrame* proto) const {
5252
pose_in_frame pif;
5353
pif.reference_frame = proto->reference_frame();
54-
pif.pose = from_proto<common::v1::Pose>{}(&(proto->pose()));
54+
pif.pose = from_proto_impl<common::v1::Pose>{}(&(proto->pose()));
5555

5656
return pif;
5757
}

src/viam/sdk/common/pose.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,22 +50,22 @@ struct pose_in_frame {
5050
namespace proto_convert_details {
5151

5252
template <>
53-
struct to_proto<pose> {
53+
struct to_proto_impl<pose> {
5454
void operator()(const pose&, common::v1::Pose*) const;
5555
};
5656

5757
template <>
58-
struct from_proto<common::v1::Pose> {
58+
struct from_proto_impl<common::v1::Pose> {
5959
pose operator()(const common::v1::Pose*) const;
6060
};
6161

6262
template <>
63-
struct to_proto<pose_in_frame> {
63+
struct to_proto_impl<pose_in_frame> {
6464
void operator()(const pose_in_frame&, common::v1::PoseInFrame*) const;
6565
};
6666

6767
template <>
68-
struct from_proto<common::v1::PoseInFrame> {
68+
struct from_proto_impl<common::v1::PoseInFrame> {
6969
pose_in_frame operator()(const common::v1::PoseInFrame*) const;
7070
};
7171

src/viam/sdk/common/proto_convert.hpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ constexpr const T static_const<T>::value;
2525
// void operator()(const SdkType&, common::v1::ApiType*) const
2626
// to provide API/ABI insulated proto conversion
2727
template <typename SdkType>
28-
struct to_proto;
28+
struct to_proto_impl;
2929

3030
// This struct should be explicitly specialized with a
3131
// SdkType operator()(const ProtoType*) const
3232
// to provided API/ABI insulated construction from proto
3333
template <typename ProtoType>
34-
struct from_proto;
34+
struct from_proto_impl;
3535

3636
// This is a helper type trait for deducing corresponding API types from a to_proto specialization.
3737
// We use boost::callable_traits to generate a tuple of the arguments to the to_proto call operator,
@@ -41,23 +41,23 @@ using ProtoArgType = std::remove_pointer_t<
4141
boost::mp11::mp_back<boost::callable_traits::args_t<Callable, boost::mp11::mp_list>>>;
4242

4343
// Implementation struct for the omni-to_proto callable defined below.
44-
struct to_proto_impl {
44+
struct to_proto_fn {
4545
template <typename SdkType>
4646
auto operator()(const SdkType& t) const {
47-
using ProtoReturnType = ProtoArgType<to_proto<SdkType>>;
47+
using ProtoReturnType = ProtoArgType<to_proto_impl<SdkType>>;
4848

4949
ProtoReturnType ret;
50-
to_proto<SdkType>{}(t, &ret);
50+
to_proto_impl<SdkType>{}(t, &ret);
5151

5252
return ret;
5353
}
5454
};
5555

5656
// Implementation struct for the omni-from_proto callable defined below.
57-
struct from_proto_impl {
57+
struct from_proto_fn {
5858
template <typename ProtoType>
5959
auto operator()(const ProtoType& proto) const { // NOLINT(misc-no-recursion)
60-
return from_proto<ProtoType>{}(&proto);
60+
return from_proto_impl<ProtoType>{}(&proto);
6161
}
6262
};
6363

@@ -71,13 +71,13 @@ namespace {
7171
/// This callable works for any type with a proto_convert_details::to_proto specialization as
7272
/// described above.
7373
constexpr auto& to_proto =
74-
proto_convert_details::static_const<proto_convert_details::to_proto_impl>::value;
74+
proto_convert_details::static_const<proto_convert_details::to_proto_fn>::value;
7575

7676
/// @brief Function object implementing conversion from an API type to an SDK type.
7777
/// This callable works for any type with a proto_convert_details::from_proto specialization as
7878
/// described above.
7979
constexpr auto& from_proto =
80-
proto_convert_details::static_const<proto_convert_details::from_proto_impl>::value;
80+
proto_convert_details::static_const<proto_convert_details::from_proto_fn>::value;
8181

8282
} // namespace
8383

@@ -87,13 +87,13 @@ constexpr auto& from_proto =
8787
/// This is the return type of calling to_proto on an instance of SdkType.
8888
template <typename SdkType>
8989
using EquivalentApiType =
90-
proto_convert_details::ProtoArgType<proto_convert_details::to_proto<SdkType>>;
90+
proto_convert_details::ProtoArgType<proto_convert_details::to_proto_impl<SdkType>>;
9191

9292
/// @brief Type alias for the SDK type corresponding to a given API type.
9393
/// This is the return type of calling from_proto on an instance of ApiType.
9494
template <typename ApiType>
9595
using EquivalentSdkType =
96-
boost::callable_traits::return_type_t<proto_convert_details::from_proto<ApiType>>;
96+
boost::callable_traits::return_type_t<proto_convert_details::from_proto_impl<ApiType>>;
9797

9898
} // namespace sdk
9999
} // namespace viam

src/viam/sdk/common/proto_value.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,11 +250,12 @@ void to_value(const ProtoStruct& m, Value* v) {
250250

251251
namespace proto_convert_details {
252252

253-
void to_proto<ProtoValue>::operator()(const ProtoValue& self, google::protobuf::Value* v) const {
253+
void to_proto_impl<ProtoValue>::operator()(const ProtoValue& self,
254+
google::protobuf::Value* v) const {
254255
self.vtable_.to_value(self.self_.get(), v);
255256
}
256257

257-
ProtoValue from_proto<google::protobuf::Value>::operator()( // NOLINT(misc-no-recursion)
258+
ProtoValue from_proto_impl<google::protobuf::Value>::operator()( // NOLINT(misc-no-recursion)
258259
const google::protobuf::Value* v) const {
259260
switch (v->kind_case()) {
260261
case Value::KindCase::kBoolValue: {
@@ -285,14 +286,15 @@ ProtoValue from_proto<google::protobuf::Value>::operator()( // NOLINT(misc-no-r
285286
}
286287
}
287288

288-
void to_proto<ProtoStruct>::operator()(const ProtoStruct& self, google::protobuf::Struct* s) const {
289+
void to_proto_impl<ProtoStruct>::operator()(const ProtoStruct& self,
290+
google::protobuf::Struct* s) const {
289291
for (const auto& kv : self) {
290292
s->mutable_fields()->insert(
291293
google::protobuf::MapPair<std::string, Value>(kv.first, v2::to_proto(kv.second)));
292294
}
293295
}
294296

295-
ProtoStruct from_proto<google::protobuf::Struct>::operator()( // NOLINT(misc-no-recursion)
297+
ProtoStruct from_proto_impl<google::protobuf::Struct>::operator()( // NOLINT(misc-no-recursion)
296298
const google::protobuf::Struct* s) const {
297299
ProtoStruct result;
298300

src/viam/sdk/common/proto_value.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ struct all_moves_noexcept
5454
/// definition.
5555
class ProtoValue {
5656
public:
57-
friend proto_convert_details::to_proto<ProtoValue>;
57+
friend proto_convert_details::to_proto_impl<ProtoValue>;
5858

5959
/// @brief Type discriminator constants for possible values stored in a ProtoValue.
6060
enum Kind { k_null = 0, k_bool = 1, k_double = 2, k_string = 3, k_list = 4, k_struct = 5 };
@@ -318,22 +318,22 @@ extern template ProtoStruct&& ProtoValue::get_unchecked<ProtoStruct>() &&;
318318
namespace proto_convert_details {
319319

320320
template <>
321-
struct to_proto<ProtoValue> {
321+
struct to_proto_impl<ProtoValue> {
322322
void operator()(const ProtoValue&, google::protobuf::Value*) const;
323323
};
324324

325325
template <>
326-
struct to_proto<ProtoStruct> {
326+
struct to_proto_impl<ProtoStruct> {
327327
void operator()(const ProtoStruct&, google::protobuf::Struct*) const;
328328
};
329329

330330
template <>
331-
struct from_proto<google::protobuf::Value> {
331+
struct from_proto_impl<google::protobuf::Value> {
332332
ProtoValue operator()(const google::protobuf::Value*) const;
333333
};
334334

335335
template <>
336-
struct from_proto<google::protobuf::Struct> {
336+
struct from_proto_impl<google::protobuf::Struct> {
337337
ProtoStruct operator()(const google::protobuf::Struct*) const;
338338
};
339339

src/viam/sdk/common/utils.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ bool operator==(const response_metadata& lhs, const response_metadata& rhs) {
3030

3131
namespace proto_convert_details {
3232

33-
void to_proto<time_pt>::operator()(time_pt tp, google::protobuf::Timestamp* result) const {
33+
void to_proto_impl<time_pt>::operator()(time_pt tp, google::protobuf::Timestamp* result) const {
3434
const std::chrono::nanoseconds since_epoch = tp.time_since_epoch();
3535

3636
const auto sec_floor = std::chrono::duration_cast<std::chrono::seconds>(since_epoch);
@@ -40,14 +40,14 @@ void to_proto<time_pt>::operator()(time_pt tp, google::protobuf::Timestamp* resu
4040
result->set_nanos(static_cast<int32_t>(nano_part.count()));
4141
}
4242

43-
time_pt from_proto<google::protobuf::Timestamp>::operator()(
43+
time_pt from_proto_impl<google::protobuf::Timestamp>::operator()(
4444
const google::protobuf::Timestamp* timestamp) const {
4545
return time_pt{std::chrono::seconds{timestamp->seconds()} +
4646
std::chrono::nanoseconds{timestamp->nanos()}};
4747
}
4848

49-
void to_proto<std::chrono::microseconds>::operator()(std::chrono::microseconds duration,
50-
google::protobuf::Duration* proto) const {
49+
void to_proto_impl<std::chrono::microseconds>::operator()(std::chrono::microseconds duration,
50+
google::protobuf::Duration* proto) const {
5151
namespace sc = std::chrono;
5252

5353
const sc::seconds seconds = sc::duration_cast<sc::seconds>(duration);
@@ -57,7 +57,7 @@ void to_proto<std::chrono::microseconds>::operator()(std::chrono::microseconds d
5757
proto->set_seconds(seconds.count());
5858
}
5959

60-
std::chrono::microseconds from_proto<google::protobuf::Duration>::operator()(
60+
std::chrono::microseconds from_proto_impl<google::protobuf::Duration>::operator()(
6161
const google::protobuf::Duration* proto) const {
6262
namespace sc = std::chrono;
6363
const sc::seconds seconds_part{proto->seconds()};
@@ -74,12 +74,12 @@ std::chrono::microseconds from_proto<google::protobuf::Duration>::operator()(
7474
return from_seconds + from_nanos;
7575
}
7676

77-
void to_proto<response_metadata>::operator()(const response_metadata& self,
78-
common::v1::ResponseMetadata* proto) const {
77+
void to_proto_impl<response_metadata>::operator()(const response_metadata& self,
78+
common::v1::ResponseMetadata* proto) const {
7979
*(proto->mutable_captured_at()) = v2::to_proto(self.captured_at);
8080
}
8181

82-
response_metadata from_proto<common::v1::ResponseMetadata>::operator()(
82+
response_metadata from_proto_impl<common::v1::ResponseMetadata>::operator()(
8383
const common::v1::ResponseMetadata* proto) const {
8484
return {v2::from_proto(proto->captured_at())};
8585
}

src/viam/sdk/common/utils.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,32 +48,32 @@ bool operator==(const response_metadata& lhs, const response_metadata& rhs);
4848
namespace proto_convert_details {
4949

5050
template <>
51-
struct to_proto<time_pt> {
51+
struct to_proto_impl<time_pt> {
5252
void operator()(time_pt, google::protobuf::Timestamp*) const;
5353
};
5454

5555
template <>
56-
struct from_proto<google::protobuf::Timestamp> {
56+
struct from_proto_impl<google::protobuf::Timestamp> {
5757
time_pt operator()(const google::protobuf::Timestamp*) const;
5858
};
5959

6060
template <>
61-
struct to_proto<std::chrono::microseconds> {
61+
struct to_proto_impl<std::chrono::microseconds> {
6262
void operator()(std::chrono::microseconds, google::protobuf::Duration*) const;
6363
};
6464

6565
template <>
66-
struct from_proto<google::protobuf::Duration> {
66+
struct from_proto_impl<google::protobuf::Duration> {
6767
std::chrono::microseconds operator()(const google::protobuf::Duration*) const;
6868
};
6969

7070
template <>
71-
struct to_proto<response_metadata> {
71+
struct to_proto_impl<response_metadata> {
7272
void operator()(const response_metadata&, common::v1::ResponseMetadata*) const;
7373
};
7474

7575
template <>
76-
struct from_proto<common::v1::ResponseMetadata> {
76+
struct from_proto_impl<common::v1::ResponseMetadata> {
7777
response_metadata operator()(const common::v1::ResponseMetadata*) const;
7878
};
7979

0 commit comments

Comments
 (0)