77
88#include < google/protobuf/descriptor.h>
99#include < google/protobuf/message.h>
10- #include < grpcpp/channel.h>
1110#include < grpcpp/impl/service_type.h>
1211#include < grpcpp/server.h>
1312
13+ #include < viam/sdk/common/grpc_client_fwd.hpp>
1414#include < viam/sdk/config/resource.hpp>
1515#include < viam/sdk/resource/resource.hpp>
1616#include < viam/sdk/resource/resource_api.hpp>
@@ -24,6 +24,8 @@ namespace sdk {
2424// TODO(RSDK-6617): one class per header
2525class ResourceServerRegistration {
2626 public:
27+ ResourceServerRegistration (const google::protobuf::ServiceDescriptor* service_descriptor);
28+
2729 virtual ~ResourceServerRegistration ();
2830
2931 // / @brief Create a resource's gRPC server.
@@ -36,9 +38,6 @@ class ResourceServerRegistration {
3638 // / @brief Returns a reference to the `ResourceServerRegistration`'s service descriptor.
3739 const google::protobuf::ServiceDescriptor* service_descriptor () const ;
3840
39- ResourceServerRegistration (const google::protobuf::ServiceDescriptor* service_descriptor)
40- : service_descriptor_(service_descriptor){};
41-
4241 private:
4342 const google::protobuf::ServiceDescriptor* service_descriptor_;
4443};
@@ -47,16 +46,16 @@ class ResourceServerRegistration {
4746// / @brief Defines registered `Resource` client creation functionality.
4847class ResourceClientRegistration {
4948 public:
49+ ResourceClientRegistration () = default ;
50+
5051 virtual ~ResourceClientRegistration ();
5152
5253 // / @brief Create gRPC client to a resource.
5354 // / @param name The name of the resource.
5455 // / @param channel A channel connected to the client.
5556 // / @return A `shared_ptr` to the resource client.
5657 virtual std::shared_ptr<Resource> create_rpc_client (
57- std::string name, std::shared_ptr<grpc::Channel> channel) const = 0;
58-
59- ResourceClientRegistration () = default ;
58+ std::string name, std::shared_ptr<GrpcChannel> channel) const = 0;
6059};
6160
6261// TODO(RSDK-6616): instead of std::functions, consider making these functions
@@ -68,21 +67,13 @@ class ModelRegistration {
6867 ModelRegistration (
6968 API api,
7069 Model model,
71- std::function<std::shared_ptr<Resource>(Dependencies, ResourceConfig)> constructor)
72- : construct_resource(std::move(constructor)),
73- validate (default_validator),
74- model_(std::move(model)),
75- api_(std::move(api)){};
70+ std::function<std::shared_ptr<Resource>(Dependencies, ResourceConfig)> constructor);
7671
7772 ModelRegistration (
7873 API api,
7974 Model model,
8075 std::function<std::shared_ptr<Resource>(Dependencies, ResourceConfig)> constructor,
81- std::function<std::vector<std::string>(ResourceConfig)> validator)
82- : construct_resource(std::move(constructor)),
83- validate(std::move(validator)),
84- model_(std::move(model)),
85- api_(std::move(api)){};
76+ std::function<std::vector<std::string>(ResourceConfig)> validator);
8677
8778 const API& api () const ;
8879 const Model& model () const ;
@@ -134,7 +125,7 @@ class Registry {
134125 using ResourceClientRegistration::ResourceClientRegistration;
135126
136127 std::shared_ptr<Resource> create_rpc_client (
137- std::string name, std::shared_ptr<grpc::Channel > chan) const override {
128+ std::string name, std::shared_ptr<GrpcChannel > chan) const override {
138129 return std::make_shared<ResourceClientT>(std::move (name), std::move (chan));
139130 }
140131 };
0 commit comments