Skip to content

Commit 8b13d45

Browse files
Clean up
1 parent e0c1166 commit 8b13d45

File tree

10 files changed

+31
-45
lines changed

10 files changed

+31
-45
lines changed

src/someipd/BUILD.bazel

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,13 @@ exports_files(
2828
visibility = ["//visibility:public"],
2929
)
3030

31-
# ============================================================================
31+
3232
# Core Types (stack-independent SOME/IP types and constants)
33-
# ============================================================================
3433
cc_library(
3534
name = "someipd_types",
3635
hdrs = ["someipd_types.h"],
3736
)
3837

39-
# ============================================================================
40-
# Abstract Interfaces (Bridge pattern implementor interfaces)
41-
# ============================================================================
4238
cc_library(
4339
name = "i_network_stack",
4440
hdrs = ["i_network_stack.h"],
@@ -50,9 +46,6 @@ cc_library(
5046
hdrs = ["i_internal_ipc.h"],
5147
)
5248

53-
# ============================================================================
54-
# Config Reader (stack-independent)
55-
# ============================================================================
5649
cc_library(
5750
name = "someipd_config",
5851
srcs = ["someipd_config_reader.cpp"],
@@ -63,9 +56,6 @@ cc_library(
6356
],
6457
)
6558

66-
# ============================================================================
67-
# Gateway Routing (Bridge pattern abstraction — core routing logic)
68-
# ============================================================================
6959
cc_library(
7060
name = "gateway_routing",
7161
srcs = ["gateway_routing.cpp"],
@@ -78,9 +68,7 @@ cc_library(
7868
],
7969
)
8070

81-
# ============================================================================
82-
# vsomeip Adapter (Adapter pattern — SOME/IP network stack)
83-
# ============================================================================
71+
8472
cc_library(
8573
name = "vsomeip_adapter",
8674
srcs = ["vsomeip_adapter.cpp"],
@@ -91,9 +79,7 @@ cc_library(
9179
],
9280
)
9381

94-
# ============================================================================
95-
# mw::com Adapter (Adapter pattern — internal IPC framework)
96-
# ============================================================================
82+
9783
cc_library(
9884
name = "mwcom_adapter",
9985
srcs = ["mwcom_adapter.cpp"],
@@ -106,9 +92,6 @@ cc_library(
10692
],
10793
)
10894

109-
# ============================================================================
110-
# Main Binary
111-
# ============================================================================
11295
cc_binary(
11396
name = "someipd",
11497
srcs = ["main.cpp"],

src/someipd/gateway_routing.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ InstanceId GatewayRouting::LookupInstanceId(ServiceId service_id) const {
8585
}
8686
return kAnyInstance;
8787
}
88-
88+
// exchange event data
8989
void GatewayRouting::ProcessMessages(std::atomic<bool>& shutdown_requested) {
9090
static constexpr std::size_t kMaxSampleCount = 10;
9191

@@ -131,8 +131,8 @@ void GatewayRouting::ProcessMessages(std::atomic<bool>& shutdown_requested) {
131131

132132
void GatewayRouting::Run(std::atomic<bool>& shutdown_requested) {
133133
network_stack_->StartProcessing();
134-
SetupSubscriptions();
135-
SetupOfferings();
134+
SetupSubscriptions(); // once per service, not per message
135+
SetupOfferings(); // once per service, not per message
136136
ProcessMessages(shutdown_requested);
137137
network_stack_->StopProcessing();
138138
}

src/someipd/gateway_routing.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,18 @@ namespace score::someip_gateway::someipd {
2525
/// Bridge abstraction that decouples the routing logic from both the SOME/IP
2626
/// network stack and the internal IPC framework.
2727
///
28-
/// GatewayRouting holds references to two abstract interfaces — INetworkStack
29-
/// and IInternalIpc — and delegates all stack-specific and IPC-specific work to
30-
/// them. The two implementation dimensions (network stack and IPC framework)
31-
/// can be varied independently by injecting different adapters.
28+
/// Abstraction:GatewayRouting
29+
/// Implementor: IInternalIpc and INetworkStack (Abstract interfaces)
30+
/// Concrete Implementor (A/B): MwcomAdapter and VsomeipAdapter.
31+
/// Delegation: network_stack_->RequestService(...) or internal_ipc_->SendToGatewayd(...), ... etc
32+
/// Client: main.cpp instantiates GatewayRouting() and calls Run()
33+
3234
class GatewayRouting {
3335
public:
3436
GatewayRouting(std::unique_ptr<INetworkStack> network_stack,
3537
std::unique_ptr<IInternalIpc> internal_ipc, SomeipDConfig config);
3638

37-
/// Run the routing loop. Blocks until @p shutdown_requested becomes true.
39+
/// Run the routing loop. Blocks until shutdown_requested becomes true.
3840
void Run(std::atomic<bool>& shutdown_requested);
3941

4042
private:
@@ -45,8 +47,6 @@ class GatewayRouting {
4547

4648
SomeipDConfig config_;
4749
std::unique_ptr<IInternalIpc> internal_ipc_;
48-
// Declared last so it is destroyed first — ensures the network stack is
49-
// stopped before IPC resources are torn down.
5050
std::unique_ptr<INetworkStack> network_stack_;
5151
};
5252

src/someipd/i_internal_ipc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class IInternalIpc {
2727
virtual ~IInternalIpc() = default;
2828

2929
/// Initialize the IPC runtime, discover services, and establish connections.
30-
virtual bool Init(int argc, const char* argv[]) = 0;
30+
virtual void Init(int argc, const char* argv[]) = 0;
3131

3232
/// Send a raw SOME/IP message to gatewayd (inbound path: network → someipd → gatewayd).
3333
virtual bool SendToGatewayd(const std::byte* data, std::size_t size) = 0;

src/someipd/main.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,7 @@ int main(int argc, const char* argv[]) {
8686

8787
auto internal_ipc =
8888
std::make_unique<MwcomAdapter>("someipd/gatewayd_messages", "someipd/someipd_messages", 10);
89-
if (!internal_ipc->Init(argc, argv)) {
90-
score::mw::log::LogError() << "IPC initialization failed";
91-
return EXIT_FAILURE;
92-
}
89+
internal_ipc->Init(argc, argv);
9390

9491
GatewayRouting routing(std::move(network_stack), std::move(internal_ipc), std::move(config));
9592
routing.Run(shutdown_requested);

src/someipd/mwcom_adapter.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ MwcomAdapter::MwcomAdapter(std::string proxy_instance_specifier,
2828
skeleton_instance_specifier_(std::move(skeleton_instance_specifier)),
2929
max_sample_count_(max_sample_count) {}
3030

31-
bool MwcomAdapter::Init(int argc, const char* argv[]) {
31+
void MwcomAdapter::Init(int argc, const char* argv[]) {
3232
score::mw::com::runtime::InitializeRuntime(argc, argv);
3333

3434
auto handles = Proxy::FindService(
@@ -41,8 +41,6 @@ bool MwcomAdapter::Init(int argc, const char* argv[]) {
4141
score::mw::com::InstanceSpecifier::Create(skeleton_instance_specifier_).value());
4242
skeleton_.emplace(std::move(create_result).value());
4343
(void)skeleton_->OfferService();
44-
45-
return true;
4644
}
4745

4846
bool MwcomAdapter::SendToGatewayd(const std::byte* data, std::size_t size) {

src/someipd/mwcom_adapter.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,18 @@ namespace score::someip_gateway::someipd {
2727
///
2828
/// All mw::com-specific headers and API calls are isolated here.
2929
/// To switch to a different IPC framework, provide another IInternalIpc adapter.
30+
///
31+
///
32+
/// Target (IInternalIpc)
33+
/// Adapter (MwcomAdapter)
34+
/// Adaptee (SomeipMessageTransferProxy & SomeipMessageTransferSkeleton)
35+
/// Client main.cpp
3036
class MwcomAdapter : public IInternalIpc {
3137
public:
3238
MwcomAdapter(std::string proxy_instance_specifier, std::string skeleton_instance_specifier,
3339
std::size_t max_sample_count);
3440

35-
bool Init(int argc, const char* argv[]) override;
41+
void Init(int argc, const char* argv[]) override;
3642
bool SendToGatewayd(const std::byte* data, std::size_t size) override;
3743
void ReceiveFromGatewayd(MessageCallback callback, std::size_t max_count) override;
3844

src/someipd/someipd_config.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ struct ServiceEventConfig {
3131
struct ServiceConfig {
3232
ServiceId service_id;
3333
InstanceId instance_id;
34-
/// UDP port for unreliable (UDP) transport. 0 means no external transport configured.
3534
std::uint16_t unreliable_port{0};
3635
std::vector<ServiceEventConfig> events;
3736
};
@@ -44,9 +43,6 @@ struct SomeipDConfig {
4443
std::vector<ServiceConfig> subscribed_services;
4544
};
4645

47-
/// @brief Parse the someipd service configuration from a JSON file.
48-
/// @param config_path Absolute or relative path to the someipd config JSON file.
49-
/// @throws std::runtime_error if the file cannot be opened or parsed.
5046
SomeipDConfig ReadSomeipDConfig(const std::string& config_path);
5147

5248
} // namespace score::someip_gateway::someipd

src/someipd/someipd_types.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@
1818

1919
namespace score::someip_gateway::someipd {
2020

21-
/// Stack-independent SOME/IP type aliases.
21+
/// Hopefully ;) Stack-independent SOME/IP type aliases.
2222
using ServiceId = std::uint16_t;
2323
using InstanceId = std::uint16_t;
2424
using EventId = std::uint16_t;
2525
using EventGroupId = std::uint16_t;
2626

27-
/// SOME/IP protocol constants (per SOME/IP specification, stack-independent).
27+
/// Hopefully ;) SOME/IP protocol constants (per SOME/IP specification, stack-independent).
2828
constexpr std::size_t kSomeipFullHeaderSize = 16;
2929
constexpr std::size_t kMaxMessageSize = 1500;
3030
constexpr InstanceId kAnyInstance = 0xFFFF;

src/someipd/vsomeip_adapter.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ namespace score::someip_gateway::someipd {
2626
///
2727
/// All vsomeip-specific headers and API calls are isolated here.
2828
/// To switch to a different SOME/IP stack, provide another INetworkStack adapter.
29+
///
30+
/// Target (INetworkStack)
31+
/// Adapter (VsomeipAdapter)
32+
/// Adaptee (vsomeip::application & vsomeip::payload)
33+
/// Client main.cpp , it instantiate the adapter
34+
2935
class VsomeipAdapter : public INetworkStack {
3036
public:
3137
explicit VsomeipAdapter(std::string app_name);

0 commit comments

Comments
 (0)