69 lines
1.7 KiB
C++
69 lines
1.7 KiB
C++
/**
|
|
* @file include/ActivMiddleware/ActivBase/GenericMessages/Formats/Activ/MessageHeaderActiv.h
|
|
*
|
|
* @brief Header for MessageHeader class.
|
|
*/
|
|
|
|
#if (!defined ACTIV_BASE_GENERIC_MESSAGES_FORMATS_ACTIV_MESSAGE_HEADER_ACTIV_H)
|
|
#define ACTIV_BASE_GENERIC_MESSAGES_FORMATS_ACTIV_MESSAGE_HEADER_ACTIV_H
|
|
|
|
#include "ActivMiddleware/ActivBase/GenericMessages/Types.h"
|
|
#include "ActivMiddleware/ActivBase/MessageBuilder.h"
|
|
#include "ActivMiddleware/Misc/BitFields.h"
|
|
|
|
//! Activ namespace.
|
|
namespace Activ
|
|
{
|
|
|
|
//! GenericMessages namespace.
|
|
namespace GenericMessages
|
|
{
|
|
|
|
//! Formats namespace.
|
|
namespace Formats
|
|
{
|
|
|
|
//! ACTIV format namespace.
|
|
namespace Activ
|
|
{
|
|
|
|
//! Message header.
|
|
class MessageHeader : public Bitmap<8, LsbOrigin>
|
|
{
|
|
public:
|
|
/**
|
|
* @brief Serialize the message header.
|
|
*
|
|
* @param messageBuilder
|
|
* @param numberOfFields
|
|
*
|
|
* @return STATUS_CODE_SUCCESS or error status.
|
|
*/
|
|
static StatusCode Serialize(MessageBuilder &messageBuilder, const size_t numberOfFields)
|
|
{
|
|
if (ACTIV_UNLIKELY(numberOfFields > Boost::integer_traits<FieldCount>::const_max))
|
|
return STATUS_CODE_OUT_OF_RANGE;
|
|
|
|
// Message header bitmap. Currently unused.
|
|
Type messageHeader = 0;
|
|
ACTIV_RETURN_RESULT_IF_UNLIKELY(STATUS_CODE_SUCCESS, !=,
|
|
messageBuilder.Append<MessageHandler::ENDIAN_LITTLE>(messageHeader));
|
|
|
|
// Number of fields.
|
|
ACTIV_RETURN_RESULT_IF_UNLIKELY(STATUS_CODE_SUCCESS, !=,
|
|
messageBuilder.Append<MessageHandler::ENDIAN_LITTLE>(static_cast<FieldCount>(numberOfFields)));
|
|
|
|
return STATUS_CODE_SUCCESS;
|
|
}
|
|
};
|
|
|
|
} // namespace Activ
|
|
|
|
} // namespace Formats
|
|
|
|
} // namespace GenericMessages
|
|
|
|
} // namespace Activ
|
|
|
|
#endif // (!defined ACTIV_BASE_GENERIC_MESSAGES_FORMATS_ACTIV_MESSAGE_HEADER_ACTIV_H)
|