refactor
This commit is contained in:
41
include/sp/protocol/message/MessageInterfaceBuilder.h
Normal file
41
include/sp/protocol/message/MessageInterfaceBuilder.h
Normal file
@@ -0,0 +1,41 @@
|
||||
#pragma once
|
||||
|
||||
#include <sp/protocol/message/MessageInterfaces.h>
|
||||
|
||||
namespace sp {
|
||||
namespace details {
|
||||
|
||||
class EmptyBase {};
|
||||
|
||||
template <typename... TOptions>
|
||||
struct MessageInterfaceBuilder {
|
||||
// Parse the options
|
||||
using ParsedOptions = MessageInterfaceParsedOptions<TOptions...>;
|
||||
|
||||
// Add ID retrieval functionality if ID type was provided
|
||||
using Base1 = typename MessageInterfaceProcessMsgId<EmptyBase, ParsedOptions, ParsedOptions::HasMsgIdType>::Type;
|
||||
|
||||
// Add ReadData() and WriteData(), that use the right endian
|
||||
using Base2 = typename MessageInterfaceProcessEndian<Base1, ParsedOptions::HasLittleEndian>::Type;
|
||||
|
||||
// Add read functionality if Read type was provided
|
||||
using Base3 = typename MessageInterfaceProcessRead<Base2, ParsedOptions::HasReadOperations>::Type;
|
||||
|
||||
// Add write functionality if Write type was provided
|
||||
using Base4 = typename MessageInterfaceProcessWrite<Base3, ParsedOptions::HasWriteOperations>::Type;
|
||||
|
||||
// add dispatch functionality if Handler type was provided
|
||||
using Base5 = typename MessageInterfaceProcessHandler<Base4, ParsedOptions, ParsedOptions::HasHandler>::Type;
|
||||
|
||||
// add valid functionality if Valid tpe was provided
|
||||
using Base6 = typename MessageInterfaceProcessValid<Base5, ParsedOptions::HasValid>::Type;
|
||||
|
||||
// add write id functionality if write id and write was provided
|
||||
using Base7 = typename MessageInterfaceProcessWriteId<Base6, ParsedOptions::HasWriteId && ParsedOptions::HasWriteOperations>::Type;
|
||||
|
||||
// The last Base6 must be taken as final type.
|
||||
using Type = Base7;
|
||||
};
|
||||
|
||||
} // namespace details
|
||||
} // namespace sp
|
||||
Reference in New Issue
Block a user