From a95bc6b293683e63c3070b5f2ce33a5e2b3f942f Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sun, 23 Aug 2020 22:33:22 +0200 Subject: [PATCH] sid cached now --- datapool/PoolDataSetBase.cpp | 3 --- datapoollocal/LocalDataSet.cpp | 32 +++++++------------------ datapoollocal/LocalDataSet.h | 5 ++-- datapoollocal/LocalPoolDataSetBase.cpp | 33 ++++++++++++++++---------- datapoollocal/LocalPoolDataSetBase.h | 16 ++++++------- datapoollocal/SharedLocalDataSet.cpp | 4 ++-- datapoollocal/SharedLocalDataSet.h | 2 +- datapoollocal/StaticLocalDataSet.h | 4 ++-- housekeeping/HousekeepingMessage.h | 4 ++++ 9 files changed, 47 insertions(+), 56 deletions(-) diff --git a/datapool/PoolDataSetBase.cpp b/datapool/PoolDataSetBase.cpp index f9a6f391..1acd3fd3 100644 --- a/datapool/PoolDataSetBase.cpp +++ b/datapool/PoolDataSetBase.cpp @@ -5,9 +5,6 @@ PoolDataSetBase::PoolDataSetBase(PoolVariableIF** registeredVariablesArray, const size_t maxFillCount): registeredVariables(registeredVariablesArray), maxFillCount(maxFillCount) { - for (uint8_t count = 0; count < maxFillCount; count++) { - registeredVariables[count] = nullptr; - } } PoolDataSetBase::~PoolDataSetBase() {} diff --git a/datapoollocal/LocalDataSet.cpp b/datapoollocal/LocalDataSet.cpp index fe9b7d59..f6f13313 100644 --- a/datapoollocal/LocalDataSet.cpp +++ b/datapoollocal/LocalDataSet.cpp @@ -5,32 +5,16 @@ #include #include -LocalDataSet::LocalDataSet(HasLocalDataPoolIF *hkOwner, - const size_t maxNumberOfVariables): - LocalPoolDataSetBase(hkOwner,poolVarList.data(), maxNumberOfVariables) { - poolVarList.reserve(maxNumberOfVariables); - poolVarList.resize(maxNumberOfVariables); - if(hkOwner == nullptr) { - sif::error << "LocalDataSet::LocalDataSet: Owner can't be nullptr!" - << std::endl; - return; - } - hkManager = hkOwner->getHkManagerHandle(); +LocalDataSet::LocalDataSet(HasLocalDataPoolIF *hkOwner, uint32_t setId, + const size_t maxNumberOfVariables): poolVarList(maxNumberOfVariables), + LocalPoolDataSetBase(hkOwner, setId, nullptr, maxNumberOfVariables) { + this->setContainer(poolVarList.data()); } -LocalDataSet::LocalDataSet(object_id_t ownerId, - const size_t maxNumberOfVariables): - LocalPoolDataSetBase(ownerId, poolVarList.data(), maxNumberOfVariables) { - poolVarList.reserve(maxNumberOfVariables); - poolVarList.resize(maxNumberOfVariables); - HasLocalDataPoolIF* hkOwner = objectManager->get( - ownerId); - if(hkOwner == nullptr) { - sif::error << "LocalDataSet::LocalDataSet: Owner can't be nullptr!" - << std::endl; - return; - } - hkManager = hkOwner->getHkManagerHandle(); +LocalDataSet::LocalDataSet(sid_t sid, const size_t maxNumberOfVariables): + LocalPoolDataSetBase(sid, nullptr, maxNumberOfVariables), + poolVarList(maxNumberOfVariables) { + this->setContainer(poolVarList.data()); } LocalDataSet::~LocalDataSet() {} diff --git a/datapoollocal/LocalDataSet.h b/datapoollocal/LocalDataSet.h index d306fae3..5641ebfb 100644 --- a/datapoollocal/LocalDataSet.h +++ b/datapoollocal/LocalDataSet.h @@ -5,8 +5,9 @@ class LocalDataSet: public LocalPoolDataSetBase { public: - LocalDataSet(HasLocalDataPoolIF* hkOwner, const size_t maxSize); - LocalDataSet(object_id_t owner, const size_t maxSize); + LocalDataSet(HasLocalDataPoolIF* hkOwner, uint32_t setId, + const size_t maxSize); + LocalDataSet(sid_t sid, const size_t maxSize); virtual~ LocalDataSet(); //! Copying forbidden for now. diff --git a/datapoollocal/LocalPoolDataSetBase.cpp b/datapoollocal/LocalPoolDataSetBase.cpp index cbf2eeef..8abdc0e3 100644 --- a/datapoollocal/LocalPoolDataSetBase.cpp +++ b/datapoollocal/LocalPoolDataSetBase.cpp @@ -6,7 +6,7 @@ #include LocalPoolDataSetBase::LocalPoolDataSetBase(HasLocalDataPoolIF *hkOwner, - PoolVariableIF** registeredVariablesArray, + uint32_t setId, PoolVariableIF** registeredVariablesArray, const size_t maxNumberOfVariables): PoolDataSetBase(registeredVariablesArray, maxNumberOfVariables) { if(hkOwner == nullptr) { @@ -15,20 +15,23 @@ LocalPoolDataSetBase::LocalPoolDataSetBase(HasLocalDataPoolIF *hkOwner, return; } hkManager = hkOwner->getHkManagerHandle(); + this->sid.objectId = hkOwner->getObjectId(); + this->sid.ownerSetId = setId; } -LocalPoolDataSetBase::LocalPoolDataSetBase(object_id_t ownerId, +LocalPoolDataSetBase::LocalPoolDataSetBase(sid_t sid, PoolVariableIF** registeredVariablesArray, const size_t maxNumberOfVariables): PoolDataSetBase(registeredVariablesArray, maxNumberOfVariables) { HasLocalDataPoolIF* hkOwner = objectManager->get( - ownerId); + sid.objectId); if(hkOwner == nullptr) { sif::error << "LocalDataSet::LocalDataSet: Owner can't be nullptr!" << std::endl; return; } hkManager = hkOwner->getHkManagerHandle(); + this->sid = sid; } LocalPoolDataSetBase::~LocalPoolDataSetBase() { @@ -123,14 +126,6 @@ ReturnValue_t LocalPoolDataSetBase::serializeLocalPoolIds(uint8_t** buffer, return HasReturnvaluesIF::RETURN_OK; } -void LocalPoolDataSetBase::bitSetter(uint8_t* byte, uint8_t position) const { - if(position > 7) { - sif::debug << "Pool Raw Access: Bit setting invalid position" << std::endl; - return; - } - uint8_t shiftNumber = position + (7 - 2 * position); - *byte |= 1 << shiftNumber; -} size_t LocalPoolDataSetBase::getSerializedSize() const { if(withValidityBuffer) { @@ -170,9 +165,21 @@ ReturnValue_t LocalPoolDataSetBase::serialize(uint8_t **buffer, size_t *size, } } -bool LocalPoolDataSetBase::bitGetter(const uint8_t* byte, uint8_t position) const { +void LocalPoolDataSetBase::bitSetter(uint8_t* byte, uint8_t position) const { if(position > 7) { - sif::debug << "Pool Raw Access: Bit setting invalid position" << std::endl; + sif::debug << "Pool Raw Access: Bit setting invalid position" + << std::endl; + return; + } + uint8_t shiftNumber = position + (7 - 2 * position); + *byte |= 1 << shiftNumber; +} + +bool LocalPoolDataSetBase::bitGetter(const uint8_t* byte, + uint8_t position) const { + if(position > 7) { + sif::debug << "Pool Raw Access: Bit setting invalid position" + << std::endl; return false; } uint8_t shiftNumber = position + (7 - 2 * position); diff --git a/datapoollocal/LocalPoolDataSetBase.h b/datapoollocal/LocalPoolDataSetBase.h index 091670cf..bd127db4 100644 --- a/datapoollocal/LocalPoolDataSetBase.h +++ b/datapoollocal/LocalPoolDataSetBase.h @@ -30,28 +30,25 @@ class LocalDataPoolManager; * * @ingroup data_pool */ -// todo: make withValidityBuffer a member class LocalPoolDataSetBase: public PoolDataSetBase { public: /** * @brief Constructor for the creator of local pool data. - * The constructor simply sets the fill_count to zero and sets - * the state to "uninitialized". */ LocalPoolDataSetBase(HasLocalDataPoolIF *hkOwner, - PoolVariableIF** registeredVariablesArray, + uint32_t setId, PoolVariableIF** registeredVariablesArray, const size_t maxNumberOfVariables); /** * @brief Constructor for users of local pool data. The passed pool * owner should implement the HasHkPoolParametersIF. - * The constructor simply sets the fill_count to zero and sets - * the state to "uninitialized". * @details - * + * @param sid Unique identifier of dataset consisting of object ID and + * set ID. + * @param registeredVariablesArray + * @param maxNumberOfVariables */ - LocalPoolDataSetBase(object_id_t ownerId, - PoolVariableIF** registeredVariablesArray, + LocalPoolDataSetBase(sid_t sid, PoolVariableIF** registeredVariablesArray, const size_t maxNumberOfVariables); /** @@ -96,6 +93,7 @@ public: bool isValid() const override; protected: + sid_t sid; /** * If the valid state of a dataset is always relevant to the whole * data set we can use this flag. diff --git a/datapoollocal/SharedLocalDataSet.cpp b/datapoollocal/SharedLocalDataSet.cpp index d44d1eb3..73e0e1fb 100644 --- a/datapoollocal/SharedLocalDataSet.cpp +++ b/datapoollocal/SharedLocalDataSet.cpp @@ -1,8 +1,8 @@ #include "SharedLocalDataSet.h" -SharedLocalDataSet::SharedLocalDataSet(object_id_t objectId, object_id_t owner, +SharedLocalDataSet::SharedLocalDataSet(object_id_t objectId, sid_t sid, const size_t maxSize): SystemObject(objectId), - LocalPoolDataSetBase(owner, nullptr, maxSize) { + LocalPoolDataSetBase(sid, nullptr, maxSize) { this->setContainer(poolVarVector.data()); datasetLock = MutexFactory::instance()->createMutex(); } diff --git a/datapoollocal/SharedLocalDataSet.h b/datapoollocal/SharedLocalDataSet.h index c5949e0a..f6748e4d 100644 --- a/datapoollocal/SharedLocalDataSet.h +++ b/datapoollocal/SharedLocalDataSet.h @@ -16,7 +16,7 @@ class SharedLocalDataSet: public SystemObject, public LocalPoolDataSetBase, public SharedDataSetIF { public: - SharedLocalDataSet(object_id_t objectId, object_id_t owner, + SharedLocalDataSet(object_id_t objectId, sid_t sid, const size_t maxSize); ReturnValue_t lockDataset(dur_millis_t mutexTimeout) override; ReturnValue_t unlockDataset() override; diff --git a/datapoollocal/StaticLocalDataSet.h b/datapoollocal/StaticLocalDataSet.h index 1819cc2d..b3e8422c 100644 --- a/datapoollocal/StaticLocalDataSet.h +++ b/datapoollocal/StaticLocalDataSet.h @@ -16,8 +16,8 @@ template class StaticLocalDataSet: public LocalPoolDataSetBase { public: - StaticLocalDataSet(object_id_t owner): - LocalPoolDataSetBase(owner, poolVarList.data(), NUM_VARIABLES) { + StaticLocalDataSet(sid_t sid): + LocalPoolDataSetBase(sid, poolVarList.data(), NUM_VARIABLES) { } private: diff --git a/housekeeping/HousekeepingMessage.h b/housekeeping/HousekeepingMessage.h index ff4b39f9..75b31505 100644 --- a/housekeeping/HousekeepingMessage.h +++ b/housekeeping/HousekeepingMessage.h @@ -12,6 +12,10 @@ union sid_t { std::numeric_limits::max(); sid_t(): raw(INVALID_ADDRESS) {} + sid_t(object_id_t objectId, uint32_t setId): + objectId(objectId), + ownerSetId(setId) {} + struct { object_id_t objectId ; /**