some adaptions
This commit is contained in:
parent
c3f9d6e6b0
commit
5a3946a267
@ -9,9 +9,9 @@
|
||||
|
||||
PoolDataSetBase::PoolDataSetBase(PoolVariableIF** registeredVariablesArray,
|
||||
const size_t maxFillCount, bool serializeWithValidityBlob)
|
||||
: registeredVariables(registeredVariablesArray),
|
||||
maxFillCount(maxFillCount),
|
||||
serializeWithValidityBlob(serializeWithValidityBlob) {}
|
||||
: serializeWithValidityBlob(serializeWithValidityBlob),
|
||||
registeredVariables(registeredVariablesArray),
|
||||
maxFillCount(maxFillCount) {}
|
||||
|
||||
PoolDataSetBase::~PoolDataSetBase() = default;
|
||||
|
||||
|
@ -139,6 +139,8 @@ class PoolDataSetBase : public PoolDataSetIF, public SerializeIF {
|
||||
*/
|
||||
void setChildrenValidity(bool valid);
|
||||
|
||||
bool serializeWithValidityBlob = false;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* @brief The fill_count attribute ensures that the variables
|
||||
@ -166,7 +168,6 @@ class PoolDataSetBase : public PoolDataSetIF, public SerializeIF {
|
||||
*/
|
||||
PoolVariableIF** registeredVariables = nullptr;
|
||||
const size_t maxFillCount = 0;
|
||||
bool serializeWithValidityBlob = false;
|
||||
|
||||
void setContainer(PoolVariableIF** variablesContainer);
|
||||
PoolVariableIF** getContainer() const;
|
||||
|
@ -3,7 +3,7 @@
|
||||
using namespace dp;
|
||||
|
||||
SharedSet::SharedSet(dp::SharedPool& sharedPool, uint32_t setId, const size_t maxNumberOfVariables,
|
||||
bool serializeWithValídityBlob)
|
||||
bool serializeWithValidityBlob)
|
||||
: SharedSetBase(sharedPool, setId, nullptr, maxNumberOfVariables, serializeWithValidityBlob),
|
||||
poolVarList(maxNumberOfVariables) {
|
||||
this->setContainer(poolVarList.data());
|
||||
|
@ -105,9 +105,6 @@ ReturnValue_t SharedSetBase::deSerialize(const uint8_t **buffer, size_t *size,
|
||||
|
||||
ReturnValue_t SharedSetBase::serialize(uint8_t **buffer, size_t *size, size_t maxSize,
|
||||
SerializeIF::Endianness streamEndianness) const {
|
||||
if (serializeWithValidityBlob) {
|
||||
return base.doSerializeWithValidityBlob(buffer, size, maxSize, streamEndianness);
|
||||
}
|
||||
return base.serialize(buffer, size, maxSize, streamEndianness);
|
||||
}
|
||||
|
||||
@ -165,3 +162,8 @@ void SharedSetBase::setContainer(PoolVariableIF **variablesContainer) {
|
||||
return base.setContainer(variablesContainer);
|
||||
}
|
||||
PoolVariableIF **SharedSetBase::getContainer() const { return base.getContainer(); }
|
||||
|
||||
void SharedSetBase::updateValidityBlobSerialization(bool enable) {
|
||||
base.serializeWithValidityBlob = enable;
|
||||
}
|
||||
bool SharedSetBase::getValidityBlobSerialization() const { return base.serializeWithValidityBlob; }
|
||||
|
@ -159,11 +159,8 @@ class SharedSetBase : public SerializeIF, public PoolDataSetIF {
|
||||
*/
|
||||
void setChildrenValidity(bool valid);
|
||||
|
||||
/**
|
||||
* If the valid state of a dataset is always relevant to the whole
|
||||
* data set we can use this flag.
|
||||
*/
|
||||
bool serializeWithValidityBlob = false;
|
||||
void updateValidityBlobSerialization(bool enable);
|
||||
bool getValidityBlobSerialization() const;
|
||||
|
||||
protected:
|
||||
PoolDataSetBase base;
|
||||
|
@ -62,6 +62,7 @@ TEST_CASE("Pool Dataset Test", "[datapool]") {
|
||||
size_t serLen = 0;
|
||||
uint8_t* dataPtr = buf;
|
||||
dataset.serializeWithValidityBlob = true;
|
||||
CHECK(dataset.getSerializedSize() == 6);
|
||||
CHECK(dataset.serialize(&dataPtr, &serLen, sizeof(buf), SerializeIF::Endianness::NETWORK) ==
|
||||
returnvalue::OK);
|
||||
CHECK(buf[5] == 0b11000000);
|
||||
@ -70,7 +71,7 @@ TEST_CASE("Pool Dataset Test", "[datapool]") {
|
||||
SECTION("Larger Pool Dataset Serialization With Validity") {
|
||||
uint8_t buf[64]{};
|
||||
TestDatasetLarger datasetLarge;
|
||||
datasetLarge.setAllChildrenValidity(true);
|
||||
datasetLarge.setChildrenValidity(true);
|
||||
size_t serLen = 0;
|
||||
uint8_t* dataPtr = buf;
|
||||
datasetLarge.serializeWithValidityBlob = true;
|
||||
|
@ -23,6 +23,7 @@ TEST_CASE("DataSetTest", "[datapool]") {
|
||||
SECTION("BasicTest") {
|
||||
/* Test some basic functions */
|
||||
CHECK(localSet.getReportingEnabled() == false);
|
||||
CHECK(localSet.getSerializedSize() == 11);
|
||||
CHECK(localSet.getLocalPoolIdsSerializedSize() == 3 * sizeof(dp::id_t));
|
||||
CHECK(localSet.getStructureId() == lpool::testSid1);
|
||||
CHECK(localSet.getCreatorObjectId() == objects::TEST_LOCAL_POOL_OWNER_BASE);
|
||||
@ -156,7 +157,7 @@ TEST_CASE("DataSetTest", "[datapool]") {
|
||||
}
|
||||
|
||||
SECTION("Serialize with Validity Blob") {
|
||||
localSet.serializeWithValidityBlob = true;
|
||||
localSet.updateValidityBlobSerialization(true);
|
||||
CHECK(!localSet.localPoolVarUint8.isValid());
|
||||
CHECK(!localSet.localPoolUint16Vec.isValid());
|
||||
CHECK(!localSet.localPoolVarFloat.isValid());
|
||||
@ -168,6 +169,7 @@ TEST_CASE("DataSetTest", "[datapool]") {
|
||||
// Already reserve additional space for validity buffer, will be needed later
|
||||
uint8_t buffer[128]{};
|
||||
uint8_t* buffPtr = buffer;
|
||||
CHECK(localSet.getSerializedSize() == 12);
|
||||
CHECK(localSet.serialize(&buffPtr, &serSize, sizeof(buffer),
|
||||
SerializeIF::Endianness::MACHINE) == returnvalue::OK);
|
||||
CHECK(serSize == 12);
|
||||
|
Loading…
Reference in New Issue
Block a user