fix alignment + refactor
Reviewed-on: #1 Co-authored-by: Persson-dev <sim16.prib@gmail.com> Co-committed-by: Persson-dev <sim16.prib@gmail.com>
This commit was merged in pull request #1.
This commit is contained in:
45
include/sp/protocol/message/MessageImplBuilder.h
Normal file
45
include/sp/protocol/message/MessageImplBuilder.h
Normal file
@@ -0,0 +1,45 @@
|
||||
#pragma once
|
||||
|
||||
namespace sp {
|
||||
namespace details {
|
||||
|
||||
|
||||
// TBase is interface class
|
||||
// TOptions... are the implementation options
|
||||
template <typename TBase, typename... TOptions>
|
||||
struct MessageImplBuilder {
|
||||
// ParsedOptions class is supposed to be defined in comms::Message class
|
||||
using InterfaceOptions = typename TBase::ParsedOptions;
|
||||
|
||||
// Parse implementation options
|
||||
using ImplOptions = MessageImplParsedOptions<TOptions...>;
|
||||
|
||||
// Provide GetIdImpl() if possible
|
||||
static const bool HasStaticNumIdImpl = InterfaceOptions::HasMsgIdType && ImplOptions::HasStaticNumIdImpl;
|
||||
using Base1 = typename MessageImplProcessStaticNumId<TBase, ImplOptions, HasStaticNumIdImpl>::Type;
|
||||
|
||||
// Provide DispatchImpl() if possible
|
||||
static const bool HasDispatchImpl = InterfaceOptions::HasHandler && ImplOptions::HasDispatchImpl;
|
||||
using Base2 = typename MessageImplProcessDispatch<Base1, ImplOptions, HasDispatchImpl>::Type;
|
||||
|
||||
// Provide access to fields if possible
|
||||
using Base3 = typename MessageImplProcessFields<Base2, ImplOptions, ImplOptions::HasFieldsImpl>::Type;
|
||||
|
||||
// Provide ReadImpl() if possible
|
||||
static const bool HasReadImpl = InterfaceOptions::HasReadOperations && ImplOptions::HasFieldsImpl;
|
||||
using Base4 = typename MessageImplProcessReadFields<Base3, HasReadImpl>::Type;
|
||||
|
||||
// Provide WriteImpl() if possible
|
||||
static const bool HasWriteImpl = InterfaceOptions::HasWriteOperations && ImplOptions::HasFieldsImpl;
|
||||
using Base5 = typename MessageImplProcessWriteFields<Base4, HasWriteImpl>::Type;
|
||||
|
||||
// Provide ValidImpl() if possible
|
||||
static const bool HasValidImpl = InterfaceOptions::HasValid && ImplOptions::HasFieldsImpl;
|
||||
using Base6 = typename MessageImplProcessValidFields<Base5, HasValidImpl>::Type;
|
||||
|
||||
// The last BaseN must be taken as final type.
|
||||
using Type = Base6;
|
||||
};
|
||||
|
||||
} // namespace details
|
||||
} // namespace sp
|
||||
Reference in New Issue
Block a user