mw/com/impl: Internally use memory::DataTypeSizeInfo - #813
Conversation
098d64a to
a84541a
Compare
LittleHuba
left a comment
There was a problem hiding this comment.
I'd like to discuss different approaches to this topic.
This is not a hard no, I just want to brainstorm for ideas.
Sure! I'm curious for your proposals! Low level I want to "extend" a type used in the public API ... and I have no clue how to do this minimal invasive - opposed to creating a NEW type and deprecate all APIs with the old type and introduce new/overloads with the new Type! In this case that would even cascade as |
7802866 to
a0334af
Compare
|
|
||
| TEST(MakeDataTypeSizeInfoTest, ConvertsValidMetaInfo) | ||
| { | ||
| RecordProperty("Description", |
There was a problem hiding this comment.
We shouldn't have these properties if we're not linking a requirement imo. They can easily get out of sync with the code and the tests should be clear from the name and given/when/then documentation.
| namespace | ||
| { | ||
|
|
||
| TEST(MakeDataTypeSizeInfoTest, ConvertsValidMetaInfo) |
There was a problem hiding this comment.
ConvertsSizeMultipleOfAlignment
|
|
||
| TEST_F(GenericSkeletonTest, CreateWithInvalidDataTypeMetaInfoAlignmentFails) | ||
| { | ||
| RecordProperty("Description", |
There was a problem hiding this comment.
Same thing, remove recordproperty
| GenericSkeletonServiceElementInfo params; | ||
| params.events = event_storage; | ||
|
|
||
| // The event factory must never be called for invalid meta-info |
There was a problem hiding this comment.
| // The event factory must never be called for invalid meta-info | |
| // Expecting that the event factory is never be called for invalid meta-info |
| { | ||
| score::mw::log::LogError("GenericSkeleton") | ||
| << "Invalid data type meta-info provided for event: " << info.name; | ||
| return MakeUnexpected(ComErrc::kInvalidConfiguration); |
There was a problem hiding this comment.
Should this really be an invalidConfiguration error? I associate kInvalidConfiguration with the mw_com_config. But this is an error coming from C++. And do we want to return an error here or simply terminate? Because they can only be providing a data_type_meta_info which is invalid if they are doing something weird and not simply creating with sizeof / alignof.
There was a problem hiding this comment.
kInvalidConfiguration was the only available/existing error-code, which looked not completely "off" :)
... and the DataTypeMetaInfo can be imho sen as the configuration of a GenericSkeleton ...
I could introduce a new error code, if you really want:
kInvalidDataTypeSize ?
In this case, I would "prefer" not to terminate ... (it is always a philosophical question): This is not a somewhat internal broken state, where we can't recover from. It is a clear call/argument violation. And if you look at how GenericSkeleton is being used, it makes sense NOT to terminate! The typical users (like these data-collectors) get some info from the backend! They are not doing sizeof/alignof! If they could do sizeof/alignof, thzen there would be no need for a GenericSkeleton ... so imho terminate is too harsh here!
There was a problem hiding this comment.
Why is this file here and not in plumbing?
There was a problem hiding this comment.
good question! Will fix in a separate commit.
| #ifndef SCORE_MW_COM_IMPL_PLUMBING_SKELETON_SERVICE_ELEMENT_BINDING_FACTORY_IMPL_H | ||
| #define SCORE_MW_COM_IMPL_PLUMBING_SKELETON_SERVICE_ELEMENT_BINDING_FACTORY_IMPL_H | ||
|
|
||
| #include "score/memory/data_type_size_info.h" |
There was a problem hiding this comment.
The first block of includes are includes from the same package/ component, so this should be in the second block i.e. with logging
| #define SCORE_MW_COM_IMPL_PLUMBING_GENERIC_SKELETON_EVENT_BINDING_FACTORY_MOCK_H | ||
|
|
||
| #include "score/mw/com/impl/data_type_meta_info.h" | ||
| #include "score/memory/data_type_size_info.h" |
There was a problem hiding this comment.
The first block of includes are includes from the same package/ component, so this should be in a separate second block
| #include "score/memory/data_type_size_info.h" | |
| #include "score/mw/com/impl/i_generic_skeleton_event_binding_factory.h" | |
| #include "score/memory/data_type_size_info.h" |
|
|
||
| #include "score/mw/com/impl/data_type_meta_info.h" | ||
| #include "score/memory/data_type_size_info.h" | ||
| #include "score/mw/com/impl/i_generic_skeleton_event_binding_factory.h" |
There was a problem hiding this comment.
| #include "score/mw/com/impl/i_generic_skeleton_event_binding_factory.h" | |
| #include "score/mw/com/impl/i_generic_skeleton_event_binding_factory.h" | |
| #include "score/memory/data_type_size_info.h" |
| #ifndef SCORE_MW_COM_IMPL_BINDINGS_LOLA_GENERIC_SKELETON_EVENT_H_ | ||
| #define SCORE_MW_COM_IMPL_BINDINGS_LOLA_GENERIC_SKELETON_EVENT_H_ | ||
|
|
||
| #include "score/memory/data_type_size_info.h" |
There was a problem hiding this comment.
| #include "score/memory/data_type_size_info.h" | |
| #include "score/mw/com/impl/bindings/lola/element_fq_id.h" | |
| #include "score/mw/com/impl/bindings/lola/event_data_storage.h" | |
| #include "score/mw/com/impl/bindings/lola/skeleton_event_common.h" | |
| #include "score/mw/com/impl/bindings/lola/skeleton_event_properties.h" | |
| #include "score/mw/com/impl/generic_skeleton_event_binding.h" | |
| #include "score/mw/com/impl/sample_allocatee_guard.h" | |
| #include "score/memory/data_type_size_info.h" |
| "//score/mw/com/impl/test:dummy_instance_identifier_builder", | ||
| "//score/mw/com/impl/test:runtime_mock_guard", | ||
| "@googletest//:gtest", | ||
| "@score_baselibs//score/memory:data_type_size_info", |
There was a problem hiding this comment.
Should now be referencing target in the com repo?
There was a problem hiding this comment.
nope. //score/memory hasn't been moved.
a0334af to
ee884f0
Compare
ee884f0 to
25fead2
Compare
The type DataTypeMetaInfo, which we use on our public interface is too weak! It doesn't assure invariants on size/alignment, which C++ demands: size has to be always a power of two and be an integer multiple of tzhe alignment. This commit switches to internal use of memory::DataTypeSizeInfo which forces this. On the public interface we keep the weak DataTypeMetaInfo for now to avoid a breaking change! In the public layer we transform DataTypeMetaInfo to DataTypeSizeInfo. In case this isn't possible because DataTypeMetaInfo is invalid, we return an error in the public API.
IGenericSkeletonEventBindingFactory has been shifted to plumbing folder.
25fead2 to
6e9aa5c
Compare
| const SkeletonEventProperties& event_properties, | ||
| const ElementFqId& element_fq_id, | ||
| const DataTypeMetaInfo& size_info, | ||
| const memory::DataTypeSizeInfo& size_info, |
The type DataTypeMetaInfo, which we use on our
public interface is too weak! It doesn't assure
invariants on size/alignment, which C++ demands:
size has to be always a power of two and be an
integer multiple of tzhe alignment.
This commit switches to internal use of memory::DataTypeSizeInfo which forces this. On the public interface we keep the weak DataTypeMetaInfo for now to avoid a breaking change! In the public layer we transform DataTypeMetaInfo to DataTypeSizeInfo. In case this isn't possible because DataTypeMetaInfo is invalid, we return an error in the public API.