compiling again

This commit is contained in:
Robin Müller 2020-07-01 14:17:55 +02:00
parent 6802ff7d71
commit d7bff31a4c
24 changed files with 144 additions and 260 deletions

View File

@ -131,11 +131,11 @@ ReturnValue_t DataSetBase::unlockDataPool() {
}
ReturnValue_t DataSetBase::serialize(uint8_t** buffer, size_t* size,
const size_t maxSize, bool bigEndian) const {
const size_t maxSize, SerializeIF::Endianness streamEndianness) const {
ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED;
for (uint16_t count = 0; count < fillCount; count++) {
result = registeredVariables[count]->serialize(buffer, size, maxSize,
bigEndian);
streamEndianness);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
@ -144,11 +144,11 @@ ReturnValue_t DataSetBase::serialize(uint8_t** buffer, size_t* size,
}
ReturnValue_t DataSetBase::deSerialize(const uint8_t** buffer, size_t* size,
bool bigEndian) {
SerializeIF::Endianness streamEndianness) {
ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED;
for (uint16_t count = 0; count < fillCount; count++) {
result = registeredVariables[count]->deSerialize(buffer, size,
bigEndian);
streamEndianness);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}

View File

@ -105,10 +105,11 @@ public:
/* SerializeIF implementations */
virtual ReturnValue_t serialize(uint8_t** buffer, size_t* size,
const size_t maxSize, bool bigEndian) const override;
const size_t maxSize,
SerializeIF::Endianness streamEndianness) const override;
virtual size_t getSerializedSize() const override;
virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
bool bigEndian) override;
SerializeIF::Endianness streamEndianness) override;
// SHOULDDO we could use a linked list of datapool variables
//!< This definition sets the maximum number of variables to

View File

@ -24,8 +24,9 @@ PoolRawAccessHelper::~PoolRawAccessHelper() {
}
ReturnValue_t PoolRawAccessHelper::serialize(uint8_t **buffer, size_t *size,
const size_t max_size, bool bigEndian) {
SerializationArgs serializationArgs = {buffer, size, max_size, bigEndian};
const size_t max_size, SerializeIF::Endianness streamEndianness) {
SerializationArgs serializationArgs = {buffer, size, max_size,
streamEndianness};
ReturnValue_t result = RETURN_OK;
size_t remainingParametersSize = numberOfParameters * 4;
for(uint8_t count=0; count < numberOfParameters; count++) {
@ -44,9 +45,10 @@ ReturnValue_t PoolRawAccessHelper::serialize(uint8_t **buffer, size_t *size,
}
ReturnValue_t PoolRawAccessHelper::serializeWithValidityMask(uint8_t ** buffer,
size_t * size, const size_t max_size, bool bigEndian) {
size_t * size, const size_t max_size,
SerializeIF::Endianness streamEndianness) {
ReturnValue_t result = RETURN_OK;
SerializationArgs argStruct = {buffer, size, max_size, bigEndian};
SerializationArgs argStruct = {buffer, size, max_size, streamEndianness};
size_t remainingParametersSize = numberOfParameters * 4;
uint8_t validityMaskSize = ceil((float)numberOfParameters/8.0);
uint8_t validityMask[validityMaskSize];
@ -76,8 +78,8 @@ ReturnValue_t PoolRawAccessHelper::serializeCurrentPoolEntryIntoBuffer(
bool withValidMask, uint8_t * validityMask) {
uint32_t currentPoolId;
// Deserialize current pool ID from pool ID buffer
ReturnValue_t result = AutoSerializeAdapter::deSerialize(&currentPoolId,
&poolIdBuffer,remainingParameters, false);
ReturnValue_t result = SerializeAdapter::deSerialize(&currentPoolId,
&poolIdBuffer,remainingParameters, SerializeIF::Endianness::MACHINE);
if(result != RETURN_OK) {
sif::debug << std::hex << "PoolRawAccessHelper: Error deSeralizing "
"pool IDs" << std::dec << std::endl;
@ -109,8 +111,8 @@ ReturnValue_t PoolRawAccessHelper::handlePoolEntrySerialization(
GlobDataSet currentDataSet;
//debug << "Current array position: " << (int)arrayPosition << std::endl;
PoolRawAccess currentPoolRawAccess(currentPoolId,arrayPosition,
&currentDataSet,PoolVariableIF::VAR_READ);
PoolRawAccess currentPoolRawAccess(currentPoolId, arrayPosition,
&currentDataSet, PoolVariableIF::VAR_READ);
result = currentDataSet.read();
if (result != RETURN_OK) {
@ -137,7 +139,7 @@ ReturnValue_t PoolRawAccessHelper::handlePoolEntrySerialization(
}
result = currentDataSet.serialize(argStruct.buffer, argStruct.size,
argStruct.max_size, argStruct.bigEndian);
argStruct.max_size, argStruct.streamEndianness);
if (result != RETURN_OK) {
sif::debug << "Pool Raw Access Helper: Error serializing pool data with "
"ID 0x" << std::hex << currentPoolId << " into send buffer "

View File

@ -43,7 +43,7 @@ public:
* @c RETURN_FAILED on failure
*/
ReturnValue_t serialize(uint8_t ** buffer, size_t * size,
const size_t max_size, bool bigEndian);
const size_t max_size, SerializeIF::Endianness streamEndianness);
/**
* Serializes data pool entries into provided buffer with the validity mask buffer
@ -56,7 +56,7 @@ public:
* @c RETURN_FAILED on failure
*/
ReturnValue_t serializeWithValidityMask(uint8_t ** buffer, size_t * size,
const size_t max_size, bool bigEndian);
const size_t max_size, SerializeIF::Endianness streamEndianness);
private:
@ -71,7 +71,7 @@ private:
uint8_t ** buffer;
size_t * size;
const size_t max_size;
bool bigEndian;
SerializeIF::Endianness streamEndianness;
};
/**
* Helper function to serialize single pool entries

View File

@ -181,18 +181,20 @@ public:
}
virtual ReturnValue_t serialize(uint8_t** buffer, size_t* size,
const size_t max_size, bool bigEndian) const override {
return SerializeAdapter<T>::serialize(&value, buffer, size, max_size,
bigEndian);
const size_t max_size,
SerializeIF::Endianness streamEndianness) const override {
return SerializeAdapter::serialize(&value, buffer, size, max_size,
streamEndianness);
}
virtual size_t getSerializedSize() const {
return SerializeAdapter<T>::getSerializedSize(&value);
return SerializeAdapter::getSerializedSize(&value);
}
virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
bool bigEndian) {
return SerializeAdapter<T>::deSerialize(&value, buffer, size, bigEndian);
SerializeIF::Endianness streamEndianness) {
return SerializeAdapter::deSerialize(&value, buffer, size,
streamEndianness);
}
};

View File

@ -109,10 +109,10 @@ public:
const T &operator [](int i) const {return value[i];}
virtual ReturnValue_t serialize(uint8_t** buffer, size_t* size,
const size_t max_size, bool bigEndian) const override;
size_t max_size, Endianness streamEndianness) const override;
virtual size_t getSerializedSize() const override;
virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
bool bigEndian) override;
Endianness streamEndianness) override;
/**
* @brief This is a call to read the array's values

View File

@ -79,12 +79,13 @@ inline ReturnValue_t GlobPoolVector<T, vectorSize>::commitWithoutLock() {
template<typename T, uint16_t vectorSize>
inline ReturnValue_t GlobPoolVector<T, vectorSize>::serialize(uint8_t** buffer,
size_t* size, const size_t max_size, bool bigEndian) const {
size_t* size, size_t max_size,
SerializeIF::Endianness streamEndianness) const {
uint16_t i;
ReturnValue_t result;
for (i = 0; i < vectorSize; i++) {
result = SerializeAdapter<T>::serialize(&(value[i]), buffer, size,
max_size, bigEndian);
result = SerializeAdapter::serialize(&(value[i]), buffer, size,
max_size, streamEndianness);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
@ -94,17 +95,18 @@ inline ReturnValue_t GlobPoolVector<T, vectorSize>::serialize(uint8_t** buffer,
template<typename T, uint16_t vectorSize>
inline size_t GlobPoolVector<T, vectorSize>::getSerializedSize() const {
return vectorSize * SerializeAdapter<T>::getSerializedSize(value);
return vectorSize * SerializeAdapter::getSerializedSize(value);
}
template<typename T, uint16_t vectorSize>
inline ReturnValue_t GlobPoolVector<T, vectorSize>::deSerialize(
const uint8_t** buffer, size_t* size, bool bigEndian) {
const uint8_t** buffer, size_t* size,
SerializeIF::Endianness streamEndianness) {
uint16_t i;
ReturnValue_t result;
for (i = 0; i < vectorSize; i++) {
result = SerializeAdapter<T>::deSerialize(&(value[i]), buffer, size,
bigEndian);
result = SerializeAdapter::deSerialize(&(value[i]), buffer, size,
streamEndianness);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}

View File

@ -16,9 +16,9 @@ protected:
uint32_t parameterId;
uint8_t valid;
ReturnValue_t readWithoutLock() {
uint8_t arrayIndex = DataPool::PIDToArrayIndex(parameterId);
PoolEntry<T> *read_out = ::dataPool.getData<T>(
DataPool::PIDToDataPoolId(parameterId), arrayIndex);
uint8_t arrayIndex = GlobalDataPool::PIDToArrayIndex(parameterId);
PoolEntry<T> *read_out = glob::dataPool.getData<T>(
GlobalDataPool::PIDToDataPoolId(parameterId), arrayIndex);
if (read_out != NULL) {
valid = read_out->valid;
value = read_out->address[arrayIndex];

View File

@ -145,27 +145,29 @@ ReturnValue_t PoolRawAccess::getEntryEndianSafe(uint8_t* buffer,
ReturnValue_t PoolRawAccess::serialize(uint8_t** buffer, size_t* size,
const size_t max_size, bool bigEndian) const {
if (typeSize + *size <= max_size) {
if (bigEndian) {
size_t maxSize, Endianness streamEndianness) const {
//TODO integer overflow
if (typeSize + *size <= maxSize) {
#warning use endian swapper
if (1) {
#ifndef BYTE_ORDER_SYSTEM
#error BYTE_ORDER_SYSTEM not defined
#elif BYTE_ORDER_SYSTEM == LITTLE_ENDIAN
for (uint8_t count = 0; count < typeSize; count++) {
(*buffer)[count] = value[typeSize - count - 1];
}
for (uint8_t count = 0; count < typeSize; count++) {
(*buffer)[count] = value[typeSize - count - 1];
}
#elif BYTE_ORDER_SYSTEM == BIG_ENDIAN
memcpy(*buffer, value, typeSize);
memcpy(*buffer, value, typeSize);
#endif
} else {
memcpy(*buffer, value, typeSize);
}
*size += typeSize;
(*buffer) += typeSize;
return HasReturnvaluesIF::RETURN_OK;
} else {
return SerializeIF::BUFFER_TOO_SHORT;
}
} else {
memcpy(*buffer, value, typeSize);
}
*size += typeSize;
(*buffer) += typeSize;
return HasReturnvaluesIF::RETURN_OK;
} else {
return SerializeIF::BUFFER_TOO_SHORT;
}
}
@ -231,28 +233,26 @@ size_t PoolRawAccess::getSerializedSize() const {
}
ReturnValue_t PoolRawAccess::deSerialize(const uint8_t** buffer, size_t* size,
bool bigEndian) {
// TODO: Needs to be tested!!!
if (*size >= typeSize) {
*size -= typeSize;
if (bigEndian) {
Endianness streamEndianness) {
if (*size >= typeSize) {
*size -= typeSize;
if (1) {
#ifndef BYTE_ORDER_SYSTEM
#error BYTE_ORDER_SYSTEM not defined
#elif BYTE_ORDER_SYSTEM == LITTLE_ENDIAN
for (uint8_t count = 0; count < typeSize; count++) {
value[count] = (*buffer)[typeSize - count - 1];
}
for (uint8_t count = 0; count < typeSize; count++) {
value[count] = (*buffer)[typeSize - count - 1];
}
#elif BYTE_ORDER_SYSTEM == BIG_ENDIAN
memcpy(value, *buffer, typeSize);
memcpy(value, *buffer, typeSize);
#endif
}
else {
memcpy(value, *buffer, typeSize);
}
*buffer += typeSize;
return HasReturnvaluesIF::RETURN_OK;
}
else {
return SerializeIF::STREAM_TOO_SHORT;
}
} else {
memcpy(value, *buffer, typeSize);
}
*buffer += typeSize;
return HasReturnvaluesIF::RETURN_OK;
} else {
return SerializeIF::STREAM_TOO_SHORT;
}
}

View File

@ -69,8 +69,13 @@ public:
* @return - @c RETURN_OK if serialization was successfull
* - @c SerializeIF::BUFFER_TOO_SHORT if range check failed
*/
ReturnValue_t serialize(uint8_t** buffer, size_t* size,
const size_t max_size, bool bigEndian) const;
ReturnValue_t serialize(uint8_t **buffer, size_t *size,
size_t maxSize, Endianness streamEndianness) const override;
size_t getSerializedSize() const override;
ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size,
Endianness streamEndianness) override;
/**
* With this method, the content can be set from a big endian buffer safely.
@ -130,11 +135,6 @@ public:
*/
uint16_t getSizeTillEnd() const;
size_t getSerializedSize() const;
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
bool bigEndian);
/**
* @brief This is a call to read the value from the global data pool.
* @details

View File

@ -173,7 +173,7 @@ ReturnValue_t LocalDataPoolManager::generateSetStructurePacket(sid_t sid) {
}
size_t size = 0;
result = dataSet->serializeLocalPoolIds(&storePtr, &size,
expectedSize, false);
expectedSize, SerializeIF::Endianness::BIG);
if(expectedSize != size) {
sif::error << "HousekeepingManager::generateSetStructurePacket: "
"Expected size is not equal to serialized size" << std::endl;
@ -198,10 +198,11 @@ ReturnValue_t LocalDataPoolManager::serializeHkPacketIntoStore(
if(appendValidityBuffer) {
result = dataSet->serializeWithValidityBuffer(&storePtr,
&size, hkSize, false);
&size, hkSize, SerializeIF::Endianness::MACHINE);
}
else {
result = dataSet->serialize(&storePtr, &size, hkSize, false);
result = dataSet->serialize(&storePtr, &size, hkSize,
SerializeIF::Endianness::MACHINE);
}
if(result != HasReturnvaluesIF::RETURN_OK) {

View File

@ -32,7 +32,8 @@ ReturnValue_t LocalDataSet::lockDataPool(uint32_t timeoutMs) {
}
ReturnValue_t LocalDataSet::serializeWithValidityBuffer(uint8_t **buffer,
size_t *size, const size_t maxSize, bool bigEndian) const {
size_t *size, size_t maxSize,
SerializeIF::Endianness streamEndianness) const {
ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED;
uint8_t validityMaskSize = std::ceil(static_cast<float>(fillCount)/8.0);
uint8_t validityMask[validityMaskSize];
@ -52,7 +53,7 @@ ReturnValue_t LocalDataSet::serializeWithValidityBuffer(uint8_t **buffer,
}
}
result = registeredVariables[count]->serialize(buffer, size, maxSize,
bigEndian);
streamEndianness);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
@ -69,11 +70,12 @@ ReturnValue_t LocalDataSet::unlockDataPool() {
}
ReturnValue_t LocalDataSet::serializeLocalPoolIds(uint8_t** buffer,
size_t* size, const size_t maxSize, bool bigEndian) const {
size_t* size, size_t maxSize,
SerializeIF::Endianness streamEndianness) const {
for (uint16_t count = 0; count < fillCount; count++) {
lp_id_t currentPoolId = registeredVariables[count]->getDataPoolId();
auto result = AutoSerializeAdapter::serialize(&currentPoolId, buffer,
size, maxSize, bigEndian);
auto result = SerializeAdapter::serialize(&currentPoolId, buffer,
size, maxSize, streamEndianness);
if(result != HasReturnvaluesIF::RETURN_OK) {
sif::warning << "LocalDataSet::serializeLocalPoolIds: Serialization"
" error!" << std::endl;

View File

@ -68,10 +68,12 @@ public:
* @return
*/
ReturnValue_t serializeWithValidityBuffer(uint8_t** buffer,
size_t* size, const size_t maxSize, bool bigEndian) const;
size_t* size, size_t maxSize,
SerializeIF::Endianness streamEndianness) const;
ReturnValue_t serializeLocalPoolIds(uint8_t** buffer,
size_t* size, const size_t maxSize, bool bigEndian) const;
size_t* size, size_t maxSize,
SerializeIF::Endianness streamEndianness) const;
protected:
private:
/**

View File

@ -84,11 +84,11 @@ public:
void setValid(bool validity) override;
uint8_t getValid() const;
ReturnValue_t serialize(uint8_t** buffer, size_t* size,
const size_t max_size, bool bigEndian) const override;
ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
SerializeIF::Endianness streamEndianness) const override;
virtual size_t getSerializedSize() const override;
virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
bool bigEndian) override;
SerializeIF::Endianness streamEndianness) override;
/**
* @brief This is a call to read the array's values

View File

@ -133,20 +133,20 @@ inline uint8_t LocalPoolVar<T>::getValid() const {
template<typename T>
inline ReturnValue_t LocalPoolVar<T>::serialize(uint8_t** buffer, size_t* size,
const size_t max_size, bool bigEndian) const {
return AutoSerializeAdapter::serialize(&value,
buffer, size ,max_size, bigEndian);
const size_t max_size, SerializeIF::Endianness streamEndianness) const {
return SerializeAdapter::serialize(&value,
buffer, size ,max_size, streamEndianness);
}
template<typename T>
inline size_t LocalPoolVar<T>::getSerializedSize() const {
return AutoSerializeAdapter::getSerializedSize(&value);
return SerializeAdapter::getSerializedSize(&value);
}
template<typename T>
inline ReturnValue_t LocalPoolVar<T>::deSerialize(const uint8_t** buffer,
size_t* size, bool bigEndian) {
return AutoSerializeAdapter::deSerialize(&value, buffer, size, bigEndian);
size_t* size, SerializeIF::Endianness streamEndianness) {
return SerializeAdapter::deSerialize(&value, buffer, size, streamEndianness);
}
template<typename T>

View File

@ -114,10 +114,11 @@ public:
const T &operator [](int i) const;
virtual ReturnValue_t serialize(uint8_t** buffer, size_t* size,
const size_t max_size, bool bigEndian) const override;
const size_t maxSize,
SerializeIF::Endianness streamEndiannes) const override;
virtual size_t getSerializedSize() const override;
virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
bool bigEndian) override;
SerializeIF::Endianness streamEndianness) override;
/**
* @brief This is a call to read the array's values

View File

@ -125,11 +125,12 @@ inline const T& LocalPoolVector<T, vectorSize>::operator [](int i) const {
template<typename T, uint16_t vectorSize>
inline ReturnValue_t LocalPoolVector<T, vectorSize>::serialize(uint8_t** buffer,
size_t* size, const size_t max_size, bool bigEndian) const {
size_t* size, size_t maxSize,
SerializeIF::Endianness streamEndianness) const {
ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED;
for (uint16_t i = 0; i < vectorSize; i++) {
result = SerializeAdapter<T>::serialize(&(value[i]), buffer, size,
max_size, bigEndian);
result = SerializeAdapter::serialize(&(value[i]), buffer, size,
maxSize, streamEndianness);
if (result != HasReturnvaluesIF::RETURN_OK) {
break;
}
@ -139,16 +140,17 @@ inline ReturnValue_t LocalPoolVector<T, vectorSize>::serialize(uint8_t** buffer,
template<typename T, uint16_t vectorSize>
inline size_t LocalPoolVector<T, vectorSize>::getSerializedSize() const {
return vectorSize * SerializeAdapter<T>::getSerializedSize(value);
return vectorSize * SerializeAdapter::getSerializedSize(value);
}
template<typename T, uint16_t vectorSize>
inline ReturnValue_t LocalPoolVector<T, vectorSize>::deSerialize(
const uint8_t** buffer, size_t* size, bool bigEndian) {
const uint8_t** buffer, size_t* size,
SerializeIF::Endianness streamEndianness) {
ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED;
for (uint16_t i = 0; i < vectorSize; i++) {
result = SerializeAdapter<T>::deSerialize(&(value[i]), buffer, size,
bigEndian);
result = SerializeAdapter::deSerialize(&(value[i]), buffer, size,
streamEndianness);
if (result != HasReturnvaluesIF::RETURN_OK) {
break;
}

View File

@ -19,7 +19,7 @@ public:
HasHealthIF::HealthState initilialState = HasHealthIF::HEALTHY) = 0;
virtual uint32_t getPrintSize() = 0;
virtual void printAll(uint8_t *pointer, uint32_t maxSize) = 0;
virtual void printAll(uint8_t *pointer, size_t maxSize) = 0;
protected:
virtual ReturnValue_t iterate(std::pair<object_id_t,HasHealthIF::HealthState> *value, bool reset = false) = 0;

View File

@ -20,21 +20,12 @@ public:
float getMax();
ReturnValue_t serialize(uint8_t** buffer, size_t* size,
<<<<<<< HEAD
const size_t max_size, bool bigEndian) const;
size_t getSerializedSize() const;
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
bool bigEndian);
=======
size_t maxSize, Endianness streamEndianness) const override;
size_t getSerializedSize() const override;
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
Endianness streamEndianness) override;
>>>>>>> upstream/mohr_serialize
ReturnValue_t getParameter(uint8_t domainId, uint16_t parameterId,
ParameterWrapper *parameterWrapper,

View File

@ -36,18 +36,18 @@ ReturnValue_t SerialBufferAdapter<T>::serialize(uint8_t** buffer, size_t* size,
maxSize, streamEndianness);
}
if (constBuffer != nullptr) {
memcpy(*buffer_, this->constBuffer, bufferLength);
memcpy(*buffer, this->constBuffer, bufferLength);
}
else if (buffer != nullptr) {
// This will propably be never reached, constBuffer should always be
// set if non-const buffer is set.
memcpy(*buffer_, this->buffer, bufferLength);
memcpy(*buffer, this->buffer, bufferLength);
}
else {
return HasReturnvaluesIF::RETURN_FAILED;
}
*size_ += bufferLength;
(*buffer_) += bufferLength;
*size += bufferLength;
(*buffer) += bufferLength;
return HasReturnvaluesIF::RETURN_OK;
}
}

View File

@ -39,30 +39,25 @@ public:
*/
template<typename... Args>
SerialFixedArrayListAdapter(Args... args) :
FixedArrayList<BUFFER_TYPE, MAX_SIZE, count_t>(std::forward<Args>(args)...)
{}
FixedArrayList<BUFFER_TYPE, MAX_SIZE, count_t>(
std::forward<Args>(args)...){}
virtual ReturnValue_t serialize(uint8_t** buffer, size_t* size,
const size_t max_size, bool bigEndian) const override {
return SerialArrayListAdapter<BUFFER_TYPE, count_t>::serialize(this,
buffer, size, max_size, bigEndian);
}
ReturnValue_t serialize(uint8_t** buffer, size_t* size,
size_t maxSize, Endianness streamEndianness) const {
return SerialArrayListAdapter<BUFFER_TYPE, count_t>::serialize(this,
buffer, size, maxSize, streamEndianness);
}
ReturnValue_t serialize(uint8_t** buffer, size_t* size,
size_t maxSize, Endianness streamEndianness) const {
return SerialArrayListAdapter<T, count_t>::serialize(this, buffer, size, maxSize, streamEndianness);
}
size_t getSerializedSize() const {
return SerialArrayListAdapter<BUFFER_TYPE, count_t>::getSerializedSize(this);
}
size_t getSerializedSize() const {
return SerialArrayListAdapter<T, count_t>::getSerializedSize(this);
}
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
Endianness streamEndianness) {
return SerialArrayListAdapter<BUFFER_TYPE, count_t>::deSerialize(this,
buffer, size, streamEndianness);
}
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
Endianness streamEndianness) {
return SerialArrayListAdapter<T, count_t>::deSerialize(this, buffer, size, streamEndianness);
}
};
#endif /* SERIALFIXEDARRAYLISTADAPTER_H_ */

View File

@ -2,8 +2,9 @@
#define SERIALIZEADAPTER_H_
#include <framework/returnvalues/HasReturnvaluesIF.h>
#include <framework/serialize/EndianSwapper.h>
#include <framework/container/IsDerivedFrom.h>
#include <framework/serialize/SerializeIF.h>
#include <framework/serialize/SerializeAdapterInternal.h>
#include <type_traits>
/**

View File

@ -1,118 +0,0 @@
/**
* @file SerializeAdapterInternal.h
*
* @date 13.04.2020
* @author R. Mueller
*/
#ifndef FRAMEWORK_SERIALIZE_SERIALIZEADAPTERINTERNAL_H_
#define FRAMEWORK_SERIALIZE_SERIALIZEADAPTERINTERNAL_H_
#include <framework/returnvalues/HasReturnvaluesIF.h>
#include <framework/container/IsDerivedFrom.h>
#include <framework/serialize/EndianSwapper.h>
/**
* This template specialization will be chosen for fundamental types or
* anything else not implementing SerializeIF, based on partial
* template specialization.
* @tparam T
* @tparam
*/
template<typename T, int>
class SerializeAdapter_ {
public:
/**
*
* @param object
* @param buffer
* @param size
* @param max_size
* @param bigEndian
* @return
*/
static ReturnValue_t serialize(const T* object, uint8_t** buffer,
size_t* size, const size_t max_size, bool bigEndian) {
// function eventuelly serializes structs here.
// does this work on every architecture?
// static_assert(std::is_fundamental<T>::value);
size_t ignoredSize = 0;
if (size == nullptr) {
size = &ignoredSize;
}
if (sizeof(T) + *size <= max_size) {
T tmp;
if (bigEndian) {
tmp = EndianSwapper::swap<T>(*object);
} else {
tmp = *object;
}
memcpy(*buffer, &tmp, sizeof(T));
*size += sizeof(T);
(*buffer) += sizeof(T);
return HasReturnvaluesIF::RETURN_OK;
} else {
return SerializeIF::BUFFER_TOO_SHORT;
}
}
/**
* Deserialize buffer into object
* @param object [out] Object to be deserialized with buffer data
* @param buffer contains the data. Non-Const pointer to non-const
* pointer to const data.
* @param size Size to deSerialize. wil be decremented by sizeof(T)
* @param bigEndian Specify endianness
* @return
*/
ReturnValue_t deSerialize(T* object, const uint8_t** buffer, size_t* size,
bool bigEndian) {
T tmp;
if (*size >= sizeof(T)) {
*size -= sizeof(T);
memcpy(&tmp, *buffer, sizeof(T));
if (bigEndian) {
*object = EndianSwapper::swap<T>(tmp);
} else {
*object = tmp;
}
*buffer += sizeof(T);
return HasReturnvaluesIF::RETURN_OK;
} else {
return SerializeIF::STREAM_TOO_SHORT;
}
}
size_t getSerializedSize(const T * object) {
return sizeof(T);
}
};
/**
* This template specialization will be chosen for class derived from
* SerializeIF, based on partial template specialization.
* @tparam T
* @tparam
*/
template<typename T>
class SerializeAdapter_<T, true> {
public:
ReturnValue_t serialize(const T* object, uint8_t** buffer, size_t* size,
const size_t max_size, bool bigEndian) const {
size_t ignoredSize = 0;
if (size == NULL) {
size = &ignoredSize;
}
return object->serialize(buffer, size, max_size, bigEndian);
}
size_t getSerializedSize(const T* object) const {
return object->getSerializedSize();
}
ReturnValue_t deSerialize(T* object, const uint8_t** buffer, size_t* size,
bool bigEndian) {
return object->deSerialize(buffer, size, bigEndian);
}
};
#endif /* FRAMEWORK_SERIALIZE_SERIALIZEADAPTERINTERNAL_H_ */

View File

@ -84,7 +84,7 @@ void TmPacketStored::deletePacket() {
void TmPacketStored::setStoreAddress(store_address_t setAddress) {
storeAddress = setAddress;
const uint8_t *temp_data = NULL;
uint32_t temp_size;
size_t temp_size;
if (!checkAndSetStore()) {
return;
}