score/mw/diag: added C++ API for diag-lib#4
Conversation
License Check Results🚀 The license check job ran with the Bazel command: bazel run //:license-checkStatus: Click to expand output |
|
The created documentation from the pull request is available at: docu-html |
|
|
||
| _VISIBILITY = [ | ||
| "//score:__subpackages__", | ||
| "//platform:__subpackages__", |
There was a problem hiding this comment.
question: What is the platform here?
| cc_library( | ||
| name = "simple_operation", | ||
| hdrs = ["simple_operation.h"], | ||
| include_prefix = "score/mw/diag", | ||
| visibility = _VISIBILITY, | ||
| deps = [ | ||
| ":operation", | ||
| ], | ||
| ) |
There was a problem hiding this comment.
nitpick: This should be moved up into libraries section.
| cc_library( | ||
| name = "uds_adapters", | ||
| hdrs = ["uds_adapters.h"], | ||
| include_prefix = "score/mw/diag", | ||
| visibility = _VISIBILITY, | ||
| deps = [ | ||
| ":data_resource", | ||
| ":simple_operation", | ||
| ":uds", | ||
| ], | ||
| ) |
There was a problem hiding this comment.
nitpick: This should be moved up into the libraries section.
There was a problem hiding this comment.
question: How is filename result.h relevant here?
suggestion: This file has multiple types, consider splitting it into multiple small files with relevant types.
There was a problem hiding this comment.
will split this into focused sub-headers for byte_types, attributes, nrc, payloads..
| public: | ||
| using value_type = std::pair<Key, Value>; | ||
| using iterator = typename std::vector<value_type>::iterator; | ||
| using const_iterator = typename std::vector<value_type>::const_iterator; |
There was a problem hiding this comment.
issue: naming style is not consistent with rest of the file:
using ByteVector = std::vector<std::byte>;
using ByteView = score::cpp::span<const std::byte>;
There was a problem hiding this comment.
It is intentional as like other C++ container
| /* DataCategory */ | ||
| /************************************/ | ||
|
|
||
| /// cf. ISO 17978-3:2025 Section 7.9.1, Table 70 |
There was a problem hiding this comment.
cf. is a Latin abbreviation for "see"
There was a problem hiding this comment.
issue: This file requires refactoring to converting DateCategory into a generic type and Specialise it for different Kinds.
There was a problem hiding this comment.
Keeping this PR focused; will address in a dedicated PR..
| DataCategory item; | ||
| std::optional<std::string> category_translation_id; |
There was a problem hiding this comment.
| DataCategory item; | |
| std::optional<std::string> category_translation_id; | |
| DataCategory category; | |
| std::optional<TranslationId> translation_id; |
There was a problem hiding this comment.
issue: In general, use more DSL for all types like std::string. For Example:
std::string id;
std::string name;
std::optional<std::string> translation_id;
std::optional<std::vector<std::string>> groups;
can be written as
struct StringLike { constexpr static std::string value };
using Id = StringLike;
using Name = StringLike;
using Group = StringLike;
using TransactionId = StringLike;
struct OptionalTransactionId { constexpr static std::optional<TransactionId> value };
struct OptionalGroups { constexpr static std::optional<std::vector<Group>> value };
Id id;
Name name;
OptionalTransactionId transaction_id;
OptionalGroups groups
There was a problem hiding this comment.
Aliases added... however the proposed struct StringLike { constexpr static std::string value } pattern seems not viable here, requires C++20
|
|
||
| /// Result type for DataResource::write() — success (monostate) or a DataError. | ||
| /// Corresponds to Rust's WriteValueHandle wrapping Result<(), DataError>. | ||
| using WriteValueResult = std::variant<std::monostate, sovd::DataError>; |
There was a problem hiding this comment.
| using WriteValueResult = std::variant<std::monostate, sovd::DataError>; | |
| using WriteValueReply = std::variant<std::monostate, sovd::DataError>; |
to be consistent with ReadValueReply.
Toolchain setup required to compile this PRThe C++ API introduced in this PR depends on I've opened #5 (build: adopt baselibs-style toolchain settings) which aligns What was blocking the build
After applying #5bazel build --config=bl-x86_64-linux //score/...
# INFO: Found 19 targets...
# INFO: Build completed successfully, 77 total actionsAlso noted: two test files without BUILD entries
|
There was a problem hiding this comment.
that would not be correct. instead, result type from score-baselibs repo must be used instead
There was a problem hiding this comment.
Actually our Error type is score::mw::diag::sovd::Error (with NRC + SOVD fields), while score::Result carries score::result::Error. These are different error types. So is that OK if Error should be replaced with or unified with score::result::Error.
Clarification needed: does this mean our sovd::Error type should be expressed as score::result::Error (wrapping the error code via MakeError/error domain), so that Result becomes score::Result directly? Or should score::Result be aliased with our error type(score::mw::diag::sovd::Error) via the details::expected constructor?
Please explain the intended integration pattern so I can align sovd_error.h accordingly.
|
High-priority validation update after reproducing locally:
Recommended unblock order:
|
Description
This PR introduces a C++ implementation of the diagnostics API, mirroring the design and implementation provided in the Rust version.
References