Files
Simple-Protocol-Lib/include/sp/protocol/message/MessageInterfaceBuilder.h
Persson-dev 7f8d9e3f96
All checks were successful
Linux arm64 / Build (push) Successful in 15s
add msg.ToString()
2025-03-04 20:26:42 +01:00

45 lines
1.7 KiB
C++

#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;
// add ToString() if HasToString was provided
using Base8 = typename MessageInterfaceProcessToString<Base7, ParsedOptions::HasToString>::Type;
// The last Base8 must be taken as final type.
using Type = Base8;
};
} // namespace details
} // namespace sp