Skip to content

Commit fd62464

Browse files
committed
Added new NodeRegistryClient entity
1 parent 211c35e commit fd62464

File tree

6 files changed

+112
-2
lines changed

6 files changed

+112
-2
lines changed

include/ocvsmd/sdk/daemon.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include "file_server.hpp"
1010
#include "node_command_client.hpp"
11+
#include "node_registry_client.hpp"
1112

1213
#include <cetl/cetl.hpp>
1314
#include <cetl/pf17/cetlpf.hpp>
@@ -67,6 +68,13 @@ class Daemon
6768
///
6869
virtual NodeCommandClient::Ptr getNodeCommandClient() const = 0;
6970

71+
/// Gets a pointer to the shared entity which represents the Node Registry component of the OCVSMD engine.
72+
///
73+
/// @return Shared pointer to the client side of the Node Registry component.
74+
/// The component is always present in the OCVSMD engine, so the result is never `nullptr`.
75+
///
76+
virtual NodeRegistryClient::Ptr getNodeRegistryClient() const = 0;
77+
7078
protected:
7179
Daemon() = default;
7280

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//
2+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
// SPDX-License-Identifier: MIT
4+
//
5+
6+
#ifndef OCVSMD_SDK_NODE_REGISTRY_CLIENT_HPP_INCLUDED
7+
#define OCVSMD_SDK_NODE_REGISTRY_CLIENT_HPP_INCLUDED
8+
9+
#include <memory>
10+
11+
namespace ocvsmd
12+
{
13+
namespace sdk
14+
{
15+
16+
/// Defines client side interface of the OCVSMD Node Registry component.
17+
///
18+
class NodeRegistryClient
19+
{
20+
public:
21+
/// Defines the shared pointer type for the interface.
22+
///
23+
using Ptr = std::shared_ptr<NodeRegistryClient>;
24+
25+
NodeRegistryClient(NodeRegistryClient&&) = delete;
26+
NodeRegistryClient(const NodeRegistryClient&) = delete;
27+
NodeRegistryClient& operator=(NodeRegistryClient&&) = delete;
28+
NodeRegistryClient& operator=(const NodeRegistryClient&) = delete;
29+
30+
virtual ~NodeRegistryClient() = default;
31+
32+
protected:
33+
NodeRegistryClient() = default;
34+
35+
}; // NodeRegistryClient
36+
37+
} // namespace sdk
38+
} // namespace ocvsmd
39+
40+
#endif // OCVSMD_SDK_NODE_REGISTRY_CLIENT_HPP_INCLUDED

src/sdk/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ add_library(ocvsmd_sdk
2020
daemon.cpp
2121
file_server.cpp
2222
node_command_client.cpp
23+
node_registry_client.cpp
2324
svc/node/exec_cmd_client.cpp
2425
svc/file_server/list_roots_client.cpp
2526
svc/file_server/pop_root_client.cpp

src/sdk/daemon.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "ipc/pipe/socket_client.hpp"
1212
#include "logging.hpp"
1313
#include "ocvsmd/sdk/node_command_client.hpp"
14+
#include "ocvsmd/sdk/node_registry_client.hpp"
1415
#include "sdk_factory.hpp"
1516

1617
#include <cetl/cetl.hpp>
@@ -59,8 +60,9 @@ class DaemonImpl final : public Daemon
5960

6061
ipc_router_ = common::ipc::ClientRouter::make(memory_, std::move(client_pipe));
6162

62-
file_server_ = Factory::makeFileServer(memory_, ipc_router_);
63-
node_command_client_ = Factory::makeNodeCommandClient(memory_, ipc_router_);
63+
file_server_ = Factory::makeFileServer(memory_, ipc_router_);
64+
node_command_client_ = Factory::makeNodeCommandClient(memory_, ipc_router_);
65+
node_registry_client_ = Factory::makeNodeRegistryClient(memory_, ipc_router_);
6466

6567
if (const int err = ipc_router_->start())
6668
{
@@ -84,13 +86,19 @@ class DaemonImpl final : public Daemon
8486
return node_command_client_;
8587
}
8688

89+
NodeRegistryClient::Ptr getNodeRegistryClient() const override
90+
{
91+
return node_registry_client_;
92+
}
93+
8794
private:
8895
cetl::pmr::memory_resource& memory_;
8996
libcyphal::IExecutor& executor_;
9097
common::LoggerPtr logger_;
9198
common::ipc::ClientRouter::Ptr ipc_router_;
9299
FileServer::Ptr file_server_;
93100
NodeCommandClient::Ptr node_command_client_;
101+
NodeRegistryClient::Ptr node_registry_client_;
94102

95103
}; // DaemonImpl
96104

src/sdk/node_registry_client.cpp

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
//
2+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
// SPDX-License-Identifier: MIT
4+
//
5+
6+
#include <ocvsmd/sdk/node_registry_client.hpp>
7+
8+
#include "ipc/client_router.hpp"
9+
#include "logging.hpp"
10+
#include "sdk_factory.hpp"
11+
12+
#include <cetl/pf17/cetlpf.hpp>
13+
14+
namespace ocvsmd
15+
{
16+
namespace sdk
17+
{
18+
namespace
19+
{
20+
21+
class NodeRegistryClientImpl final : public NodeRegistryClient
22+
{
23+
public:
24+
NodeRegistryClientImpl(cetl::pmr::memory_resource& memory, common::ipc::ClientRouter::Ptr ipc_router)
25+
: memory_{memory}
26+
, ipc_router_{std::move(ipc_router)}
27+
, logger_{common::getLogger("sdk")}
28+
{
29+
}
30+
31+
// NodeRegistryClient
32+
33+
private:
34+
cetl::pmr::memory_resource& memory_;
35+
common::LoggerPtr logger_;
36+
common::ipc::ClientRouter::Ptr ipc_router_;
37+
38+
}; // NodeRegistryClientImpl
39+
40+
} // namespace
41+
42+
CETL_NODISCARD NodeRegistryClient::Ptr Factory::makeNodeRegistryClient(cetl::pmr::memory_resource& memory,
43+
common::ipc::ClientRouter::Ptr ipc_router)
44+
{
45+
return std::make_shared<NodeRegistryClientImpl>(memory, std::move(ipc_router));
46+
}
47+
48+
} // namespace sdk
49+
} // namespace ocvsmd

src/sdk/sdk_factory.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include <ocvsmd/sdk/file_server.hpp>
1010
#include <ocvsmd/sdk/node_command_client.hpp>
11+
#include <ocvsmd/sdk/node_registry_client.hpp>
1112

1213
#include "ipc/client_router.hpp"
1314

@@ -27,6 +28,9 @@ struct Factory
2728
CETL_NODISCARD static NodeCommandClient::Ptr makeNodeCommandClient(cetl::pmr::memory_resource& memory,
2829
common::ipc::ClientRouter::Ptr ipc_router);
2930

31+
CETL_NODISCARD static NodeRegistryClient::Ptr makeNodeRegistryClient(cetl::pmr::memory_resource& memory,
32+
common::ipc::ClientRouter::Ptr ipc_router);
33+
3034
}; // Factory
3135

3236
} // namespace sdk

0 commit comments

Comments
 (0)