#pragma once #include namespace sp { namespace details { template struct MessageInterfaceParsedOptions {}; template <> struct MessageInterfaceParsedOptions<> { static const bool HasMsgIdType = false; static const bool HasLittleEndian = false; static const bool HasReadOperations = false; static const bool HasWriteOperations = false; static const bool HasHandler = false; static const bool HasValid = false; }; template struct MessageInterfaceParsedOptions, TOptions...> : public MessageInterfaceParsedOptions { static const bool HasMsgIdType = true; using MsgIdType = T; }; template struct MessageInterfaceParsedOptions : public MessageInterfaceParsedOptions { static const bool HasLittleEndian = true; }; template struct MessageInterfaceParsedOptions : public MessageInterfaceParsedOptions { static const bool HasReadOperations = true; }; template struct MessageInterfaceParsedOptions : public MessageInterfaceParsedOptions { static const bool HasWriteOperations = true; }; template struct MessageInterfaceParsedOptions, TOptions...> : public MessageInterfaceParsedOptions { static const bool HasHandler = true; using HandlerType = option::Handler; }; template struct MessageInterfaceParsedOptions : public MessageInterfaceParsedOptions { static const bool HasValid = true; }; // ID retrieval chunk template class MessageInterfaceIdTypeBase : public TBase { public: using MsgIdType = TId; MsgIdType GetId() const { return GetIdImpl(); } protected: virtual MsgIdType GetIdImpl() const = 0; }; // Big endian serialisation chunk template class MessageInterfaceBigEndian : public TBase { protected: template static T ReadData(DataBuffer& buffer) { // use big endian } template static void WriteData(T value, DataBuffer& buffer) { // use big endian } }; // Little endian serialisation chunk template class MessageInterfaceLittleEndian : public TBase { protected: template static T ReadData(DataBuffer& buffer) { // use little endian } template static void WriteData(const T& value, DataBuffer& buffer) { // use little endian } }; // Read functionality chunk template class MessageInterfaceReadBase : public TBase { public: void Read(DataBuffer& buffer) { return ReadImpl(buffer); } protected: virtual void ReadImpl(DataBuffer& buffer) = 0; }; // Write functionality chunk template class MessageInterfaceWriteBase : public TBase { public: void Write(DataBuffer& buffer) { return WriteImpl(buffer); } protected: virtual void WriteImpl(DataBuffer& buffer) = 0; }; // Handler functionality chunk template class MessageInterfaceHandlerBase : public TBase { public: using HandlerType = typename THandler::HandlerT; void Dispatch(HandlerType& handler) { DispatchImpl(handler); } protected: virtual void DispatchImpl(HandlerType& handler) = 0; }; // Validity functionality chunk template class MessageInterfaceValidityBase : public TBase { public: bool Valid() const { return ValidImpl(); } protected: virtual bool ValidImpl() const = 0; }; // Build message Id template struct MessageInterfaceProcessMsgId; template struct MessageInterfaceProcessMsgId { using Type = MessageInterfaceIdTypeBase; }; template struct MessageInterfaceProcessMsgId { using Type = TBase; }; // Build endianess template struct MessageInterfaceProcessEndian; template struct MessageInterfaceProcessEndian { using Type = MessageInterfaceLittleEndian; }; template struct MessageInterfaceProcessEndian { using Type = MessageInterfaceBigEndian; }; // Build read template struct MessageInterfaceProcessRead; template struct MessageInterfaceProcessRead { using Type = MessageInterfaceReadBase; }; template struct MessageInterfaceProcessRead { using Type = TBase; }; // Build write template struct MessageInterfaceProcessWrite; template struct MessageInterfaceProcessWrite { using Type = MessageInterfaceWriteBase; }; template struct MessageInterfaceProcessWrite { using Type = TBase; }; // Build handler template struct MessageInterfaceProcessHandler; template struct MessageInterfaceProcessHandler { using Type = MessageInterfaceHandlerBase; }; template struct MessageInterfaceProcessHandler { using Type = TBase; }; // Build valid template struct MessageInterfaceProcessValid; template struct MessageInterfaceProcessValid { using Type = MessageInterfaceValidityBase; }; template struct MessageInterfaceProcessValid { using Type = TBase; }; } // namespace details } // namespace sp