Skip to content

Commit 0a18659

Browse files
committed
fix imports and namespaces for docommond
1 parent 1f7f46c commit 0a18659

File tree

7 files changed

+24
-17
lines changed

7 files changed

+24
-17
lines changed

bin/run-clang-format.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,10 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17+
# Add error checking for clang-format
18+
if ! command -v clang-format >/dev/null 2>&1; then
19+
echo "Error: clang-format is not installed, install it to lint your code."
20+
exit 1
21+
fi
22+
1723
find ./src -not -path "./src/viam/api" -type f \( -name \*.cpp -o -name \*.hpp \) | xargs clang-format -style=file -i -fallback-style=none "$@"

src/viam/sdk/services/discovery.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ API Discovery::api() const {
1111
return API::get<Discovery>();
1212
}
1313

14-
API::traits<Discovery>::api() {
14+
API API::traits<Discovery>::api() {
1515
return {kRDK, kService, "discovery"};
1616
}
1717

src/viam/sdk/services/discovery.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,16 @@ class Discovery : public Service {
2727
public:
2828
/// @brief Discover valid viam configuration of resources that are physically
2929
/// connected to your machine.
30+
/// @ingroup Discovery
3031
inline std::vector<ResourceConfig> discover_resources() {
3132
return discover_resources({});
3233
}
3334

3435
/// @brief Discover valid viam configuration of resources that are physically
3536
/// connected to your machine.
37+
/// @param extra Any additional arguments to the method.
38+
/// @return array of potential viam configurations for hardware physically
39+
// connected to your viam server
3640
virtual std::vector<ResourceConfig> discover_resources(const ProtoStruct& extra) = 0;
3741

3842
/// @brief Do an arbitrary command.

src/viam/sdk/services/private/discovery_client.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@
44
#include <viam/api/service/discovery/v1/discovery.pb.h>
55

66
#include <viam/sdk/common/client_helper.hpp>
7+
#include <viam/sdk/common/private/repeated_ptr_convert.hpp>
8+
#include <viam/sdk/common/proto_value.hpp>
9+
#include <viam/sdk/common/utils.hpp>
10+
#include <viam/sdk/services/discovery.hpp>
711

812
namespace viam {
913
namespace sdk {
1014
namespace impl {
1115

12-
DiscoveryClient::DiscoveryClient(std::string name std::shared_ptr<grpc::Channel> channel)
16+
DiscoveryClient::DiscoveryClient(std::string name, std::shared_ptr<grpc::Channel> channel)
1317
: Discovery(std::move(name)),
1418
stub_(viam::service::discovery::v1::DiscoveryService::NewStub(channel)),
1519
channel_(std::move(channel)) {}
@@ -20,7 +24,7 @@ std::vector<ResourceConfig> DiscoveryClient::discover_resources(const ProtoStruc
2024
.invoke([](auto& response) { return from_proto(response); });
2125
}
2226

23-
ProtoStruct DiscoveryClient::do_command(const ProtoStruct& extra) {
27+
ProtoStruct DiscoveryClient::do_command(const ProtoStruct& command) {
2428
return make_client_helper(this, *stub_, &StubType::DoCommand)
2529
.with([&](auto& request) { *request.mutable_command() = to_proto(command); })
2630
.invoke([](auto& response) { return from_proto(response.result()); });

src/viam/sdk/services/private/discovery_client.hpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ class DiscoveryClient : public Discovery {
2424
std::vector<ResourceConfig> discover_resources(const ProtoStruct& extra) override;
2525
ProtoStruct do_command(const ProtoStruct& command) override;
2626

27-
// Using declarations to introduce convenience overloads of interface which do not need to be
28-
// passed the ProtoStruct parameter.
29-
using Discovery::discover_resources;
30-
3127
private:
3228
using StubType = viam::service::discovery::v1::DiscoveryService::StubInterface;
3329
std::unique_ptr<StubType> stub_;

src/viam/sdk/services/private/discovery_server.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
#include <viam/sdk/services/private/discovery_client.hpp>
22

3-
#include <viam/sdk/common/service_helper.hpp>
3+
#include <viam/sdk/common/private/service_helper.hpp>
44

55
namespace viam {
66
namespace sdk {
77
namespace impl {
88

9-
DiscoveryServer::DiscoveryServer(std::shared_ptr<ResourceManager> manager)
10-
: ResourceServer(std::move(manager)) {}
9+
using namespace service::discovery::v1;
1110

1211
::grpc::Status DiscoveryServer::DiscoverResources(
1312
::grpc::ServerContext*,
@@ -25,8 +24,8 @@ ::grpc::Status DiscoveryServer::DiscoverResources(
2524

2625
::grpc::Status DiscoveryServer::DoCommand(
2726
::grpc::ServerContext*,
28-
const ::viam::service::discovery::v1::DoCommandRequest* request,
29-
::viam::service::discovery::v1::DoCommandResponse* response) noexcept {
27+
const ::viam::common::v1::DoCommandRequest* request,
28+
::viam::common:v1::DoCommandResponse* response) noexcept {
3029
return make_service_helper<Discovery>(
3130
"DiscoveryServer::DoCommand", this, request)([&](auto& helper, auto& discovery) {
3231
const ProtoStruct result = discovery->do_command(from_proto(request->command()));

src/viam/sdk/services/private/discovery_server.hpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,9 @@ class DiscoveryServer : public ResourceServer,
3030
::grpc::ServerContext* context,
3131
const ::viam::service::discovery::v1::DiscoverResourcesRequest* request,
3232
::viam::service::discovery::v1::DiscoverResourcesResponse* response) noexcept override;
33-
34-
::grpc::Status DoCommand(
35-
::grpc::ServerContext* context,
36-
const ::viam::service::discovery::v1::DoCommandRequest* request,
37-
::viam::service::discovery::v1::DoCommandResponse* response) noexcept override;
33+
::grpc::Status DoCommand(::grpc::ServerContext* context,
34+
const ::viam::common::v1::DoCommandRequest* request,
35+
::viam::common::v1::DoCommandResponse* response) noexcept override;
3836
};
3937

4038
} // namespace impl

0 commit comments

Comments
 (0)