Skip to content

Commit e349ca0

Browse files
committed
rename and update comments for fwd header
1 parent 070c340 commit e349ca0

File tree

10 files changed

+101
-78
lines changed

10 files changed

+101
-78
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ if ((VIAMCPPSDK_GRPCXX_VERSION VERSION_GREATER 1.51.1) AND (VIAMCPPSDK_PROTOC_VE
431431
endif()
432432

433433
if (VIAMCPPSDK_GRPCXX_VERSION VERSION_LESS 1.32.0)
434-
set(VIAMCPPSDK_GRPCXX_LEGACY_CLIENT_FWD 1)
434+
set(VIAMCPPSDK_GRPCXX_LEGACY_FWD 1)
435435
endif()
436436

437437
include(FetchContent)

src/viam/sdk/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ message(WARNING "api proto label is ${VIAMCPPSDK_API_PROTO_LABEL}")
3030
configure_file(common/private/version_metadata.hpp.in common/private/version_metadata.hpp @ONLY)
3131

3232
# Configure the grpc client forward declarations file
33-
configure_file(common/grpc_client_fwd.hpp.in common/grpc_client_fwd.hpp)
33+
configure_file(common/grpc_fwd.hpp.in common/grpc_fwd.hpp)
3434

3535
# Set compile and link options based on arguments
3636
if (VIAMCPPSDK_USE_WALL_WERROR)
@@ -192,7 +192,7 @@ target_sources(viamsdk
192192
../../viam/sdk/spatialmath/geometry.hpp
193193
../../viam/sdk/spatialmath/orientation.hpp
194194
../../viam/sdk/spatialmath/orientation_types.hpp
195-
${CMAKE_CURRENT_BINARY_DIR}/../../viam/sdk/common/grpc_client_fwd.hpp
195+
${CMAKE_CURRENT_BINARY_DIR}/../../viam/sdk/common/grpc_fwd.hpp
196196
)
197197

198198
set_target_properties(

src/viam/sdk/common/client_helper.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#pragma once
22

33
#include <viam/sdk/common/exception.hpp>
4-
#include <viam/sdk/common/grpc_client_fwd.hpp>
4+
#include <viam/sdk/common/grpc_fwd.hpp>
55
#include <viam/sdk/common/private/utils.hpp>
66
#include <viam/sdk/common/proto_value.hpp>
77

src/viam/sdk/common/grpc_client_fwd.hpp.in

Lines changed: 0 additions & 63 deletions
This file was deleted.
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
#pragma once
2+
3+
#cmakedefine VIAMCPPSDK_GRPCXX_LEGACY_FWD
4+
5+
// Forward declaration file grpc client and server types.
6+
// This file provides includes for recent (>= 1.32.0) versions of grpc or older
7+
// versions, depending on if `VIAMCPPSDK_GRPCXX_LEGACY_FWD` is defined.
8+
// The default behavior is for the variable to be undefined, providing the behavior for recent
9+
// versions. If you are experiencing compilation errors in an installed version of the SDK it may be
10+
// due to a mismatch with the configured version of this header and the grpc version found by the
11+
// compiler. You may wish to comment/uncomment the define above as needed, or add the definition
12+
// with `-D` to the compiler.
13+
#ifndef VIAMCPPSDK_GRPCXX_LEGACY_FWD
14+
15+
namespace grpc {
16+
17+
class Channel;
18+
19+
class ClientContext;
20+
21+
template <typename>
22+
class ClientReaderInterface;
23+
24+
class Server;
25+
26+
class ServerBuilder;
27+
28+
class ServerCredentials;
29+
30+
} // namespace grpc
31+
32+
namespace viam {
33+
namespace sdk {
34+
35+
using GrpcChannel = ::grpc::Channel;
36+
37+
using GrpcClientContext = ::grpc::ClientContext;
38+
39+
template <typename T>
40+
using GrpcClientReaderInterface = ::grpc::ClientReaderInterface<T>;
41+
42+
using GrpcServer = ::grpc::Server;
43+
44+
using GrpcServerBuilder = ::grpc::ServerBuilder;
45+
46+
using GrpcServerCredentials = ::grpc::ServerCredentials;
47+
48+
} // namespace sdk
49+
} // namespace viam
50+
51+
#else
52+
53+
namespace grpc_impl {
54+
55+
class Channel;
56+
57+
class ClientContext;
58+
59+
template <typename>
60+
class ClientReaderInterface;
61+
62+
class Server;
63+
64+
class ServerBuilder;
65+
66+
class ServerCredentials;
67+
68+
} // namespace grpc_impl
69+
70+
namespace viam {
71+
namespace sdk {
72+
73+
using GrpcChannel = ::grpc_impl::Channel;
74+
75+
using GrpcClientContext = ::grpc_impl::ClientContext;
76+
77+
template <typename T>
78+
using GrpcClientReaderInterface = ::grpc_impl::ClientReaderInterface<T>;
79+
80+
using GrpcServer = ::grpc_impl::Server;
81+
82+
using GrpcServerBuilder = ::grpc_impl::ServerBuilder;
83+
84+
using GrpcServerCredentials = ::grpc_impl::ServerCredentials;
85+
86+
} // namespace sdk
87+
} // namespace viam
88+
89+
#endif

src/viam/sdk/module/module.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#pragma once
22

3-
#include <viam/sdk/common/grpc_client_fwd.hpp>
3+
#include <viam/sdk/common/grpc_fwd.hpp>
44
#include <viam/sdk/module/handler_map.hpp>
55
#include <viam/sdk/resource/resource.hpp>
66
#include <viam/sdk/resource/resource_manager.hpp>

src/viam/sdk/registry/registry.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
#include <string>
77

8-
#include <viam/sdk/common/grpc_client_fwd.hpp>
8+
#include <viam/sdk/common/grpc_fwd.hpp>
99
#include <viam/sdk/config/resource.hpp>
1010
#include <viam/sdk/resource/resource.hpp>
1111
#include <viam/sdk/resource/resource_api.hpp>

src/viam/sdk/robot/client.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include <string>
77
#include <thread>
88

9-
#include <viam/sdk/common/grpc_client_fwd.hpp>
9+
#include <viam/sdk/common/grpc_fwd.hpp>
1010
#include <viam/sdk/common/pose.hpp>
1111
#include <viam/sdk/common/utils.hpp>
1212
#include <viam/sdk/common/world_state.hpp>

src/viam/sdk/rpc/dial.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
#include <boost/optional.hpp>
88

9-
#include <viam/sdk/common/grpc_client_fwd.hpp>
9+
#include <viam/sdk/common/grpc_fwd.hpp>
1010

1111
namespace viam {
1212
namespace sdk {

src/viam/sdk/rpc/server.hpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,14 @@
33
/// @brief Defines the `Server` class.
44
#pragma once
55

6+
#include <viam/sdk/common/grpc_fwd.hpp>
67
#include <viam/sdk/resource/resource.hpp>
78
#include <viam/sdk/resource/resource_api.hpp>
89
#include <viam/sdk/resource/resource_server_base.hpp>
910

1011
namespace grpc {
1112

1213
class Service;
13-
class ServerCredentials;
14-
15-
class Server;
16-
class ServerBuilder;
1714

1815
} // namespace grpc
1916

@@ -58,7 +55,7 @@ class Server {
5855
/// @param creds The server credentials; defaults to a insecure server credentials.
5956
/// @throws `Exception` if called after the server has been `start`ed.
6057
void add_listening_port(const std::string& address,
61-
std::shared_ptr<::grpc::ServerCredentials> creds = nullptr);
58+
std::shared_ptr<GrpcServerCredentials> creds = nullptr);
6259

6360
/// @brief waits on server close, only returning when the server is closed.
6461
void wait();
@@ -71,8 +68,8 @@ class Server {
7168

7269
private:
7370
std::unordered_map<API, std::shared_ptr<ResourceServer>> managed_servers_;
74-
std::unique_ptr<::grpc::ServerBuilder> builder_;
75-
std::unique_ptr<::grpc::Server> server_;
71+
std::unique_ptr<GrpcServerBuilder> builder_;
72+
std::unique_ptr<GrpcServer> server_;
7673
};
7774

7875
} // namespace sdk

0 commit comments

Comments
 (0)