bugfixes, owner ptr not const anymore

This commit is contained in:
Robin Müller 2020-09-28 21:09:56 +02:00
parent 88c4b2a539
commit bf574c12e4
6 changed files with 44 additions and 24 deletions

View File

@ -229,7 +229,7 @@ MutexIF* LocalDataPoolManager::getMutexHandle() {
return mutex; return mutex;
} }
const HasLocalDataPoolIF* LocalDataPoolManager::getOwner() const { HasLocalDataPoolIF* LocalDataPoolManager::getOwner() {
return owner; return owner;
} }
@ -374,6 +374,7 @@ ReturnValue_t LocalDataPoolManager::generateSetStructurePacket(sid_t sid,
return HasReturnvaluesIF::RETURN_FAILED; return HasReturnvaluesIF::RETURN_FAILED;
} }
bool targetIsDiagnostics = dataSet->isDiagnostics(); bool targetIsDiagnostics = dataSet->isDiagnostics();
if((targetIsDiagnostics and not isDiagnostics) or if((targetIsDiagnostics and not isDiagnostics) or
(not targetIsDiagnostics and isDiagnostics)) { (not targetIsDiagnostics and isDiagnostics)) {

View File

@ -127,7 +127,7 @@ public:
*/ */
ReturnValue_t initializeHousekeepingPoolEntriesOnce(); ReturnValue_t initializeHousekeepingPoolEntriesOnce();
const HasLocalDataPoolIF* getOwner() const; HasLocalDataPoolIF* getOwner();
ReturnValue_t printPoolEntry(lp_id_t localPoolId); ReturnValue_t printPoolEntry(lp_id_t localPoolId);

View File

@ -119,8 +119,14 @@ ReturnValue_t LocalPoolDataSetBase::unlockDataPool() {
} }
ReturnValue_t LocalPoolDataSetBase::serializeLocalPoolIds(uint8_t** buffer, ReturnValue_t LocalPoolDataSetBase::serializeLocalPoolIds(uint8_t** buffer,
size_t* size, size_t maxSize, size_t* size, size_t maxSize,SerializeIF::Endianness streamEndianness,
SerializeIF::Endianness streamEndianness) const { bool serializeFillCount) const {
// Serialize as uint8_t
uint8_t fillCount = this->fillCount;
if(serializeFillCount) {
SerializeAdapter::serialize(&fillCount, buffer, size, maxSize,
streamEndianness);
}
for (uint16_t count = 0; count < fillCount; count++) { for (uint16_t count = 0; count < fillCount; count++) {
lp_id_t currentPoolId = registeredVariables[count]->getDataPoolId(); lp_id_t currentPoolId = registeredVariables[count]->getDataPoolId();
auto result = SerializeAdapter::serialize(&currentPoolId, buffer, auto result = SerializeAdapter::serialize(&currentPoolId, buffer,
@ -135,6 +141,16 @@ ReturnValue_t LocalPoolDataSetBase::serializeLocalPoolIds(uint8_t** buffer,
} }
uint8_t LocalPoolDataSetBase::getLocalPoolIdsSerializedSize(
bool serializeFillCount) const {
if(serializeFillCount) {
return fillCount * sizeof(lp_id_t) + sizeof(uint8_t);
}
else {
return fillCount * sizeof(lp_id_t);
}
}
size_t LocalPoolDataSetBase::getSerializedSize() const { size_t LocalPoolDataSetBase::getSerializedSize() const {
if(withValidityBuffer) { if(withValidityBuffer) {
uint8_t validityMaskSize = std::ceil(static_cast<float>(fillCount)/8.0); uint8_t validityMaskSize = std::ceil(static_cast<float>(fillCount)/8.0);

View File

@ -97,7 +97,9 @@ public:
size_t *size, SerializeIF::Endianness streamEndianness); size_t *size, SerializeIF::Endianness streamEndianness);
ReturnValue_t serializeLocalPoolIds(uint8_t** buffer, ReturnValue_t serializeLocalPoolIds(uint8_t** buffer,
size_t* size, size_t maxSize, size_t* size, size_t maxSize,
SerializeIF::Endianness streamEndianness) const; SerializeIF::Endianness streamEndianness,
bool serializeFillCount = true) const;
uint8_t getLocalPoolIdsSerializedSize(bool serializeFillCount = true) const;
/** /**
* Set the dataset valid or invalid * Set the dataset valid or invalid

View File

@ -9,14 +9,14 @@ template<typename T>
inline LocalPoolVar<T>::LocalPoolVar(lp_id_t poolId, inline LocalPoolVar<T>::LocalPoolVar(lp_id_t poolId,
HasLocalDataPoolIF* hkOwner, DataSetIF* dataSet, HasLocalDataPoolIF* hkOwner, DataSetIF* dataSet,
pool_rwm_t setReadWriteMode): pool_rwm_t setReadWriteMode):
localPoolId(poolId),readWriteMode(setReadWriteMode) { localPoolId(poolId), readWriteMode(setReadWriteMode) {
if(poolId == PoolVariableIF::NO_PARAMETER) { if(poolId == PoolVariableIF::NO_PARAMETER) {
sif::warning << "LocalPoolVector: 0 passed as pool ID, which is the " sif::warning << "LocalPoolVar<T>::LocalPoolVar: 0 passed as pool ID, "
"NO_PARAMETER value!" << std::endl; << "which is the NO_PARAMETER value!" << std::endl;
} }
if(hkOwner == nullptr) { if(hkOwner == nullptr) {
sif::error << "LocalPoolVariable: The supplied pool owner is a nullptr!" sif::error << "LocalPoolVar<T>::LocalPoolVar: The supplied pool "
<< std::endl; << "owner is a invalid!" << std::endl;
return; return;
} }
hkManager = hkOwner->getHkManagerHandle(); hkManager = hkOwner->getHkManagerHandle();
@ -28,16 +28,17 @@ inline LocalPoolVar<T>::LocalPoolVar(lp_id_t poolId,
template<typename T> template<typename T>
inline LocalPoolVar<T>::LocalPoolVar(lp_id_t poolId, object_id_t poolOwner, inline LocalPoolVar<T>::LocalPoolVar(lp_id_t poolId, object_id_t poolOwner,
DataSetIF *dataSet, pool_rwm_t setReadWriteMode): DataSetIF *dataSet, pool_rwm_t setReadWriteMode):
readWriteMode(setReadWriteMode) { localPoolId(poolId), readWriteMode(setReadWriteMode) {
if(poolId == PoolVariableIF::NO_PARAMETER) { if(poolId == PoolVariableIF::NO_PARAMETER) {
sif::warning << "LocalPoolVector: 0 passed as pool ID, which is the " sif::warning << "LocalPoolVar<T>::LocalPoolVar: 0 passed as pool ID, "
"NO_PARAMETER value!" << std::endl; << "which is the NO_PARAMETER value!" << std::endl;
} }
HasLocalDataPoolIF* hkOwner = HasLocalDataPoolIF* hkOwner =
objectManager->get<HasLocalDataPoolIF>(poolOwner); objectManager->get<HasLocalDataPoolIF>(poolOwner);
if(hkOwner == nullptr) { if(hkOwner == nullptr) {
sif::error << "LocalPoolVariable: The supplied pool owner did not implement" sif::error << "LocalPoolVariable: The supplied pool owner did not "
"the correct interface HasHkPoolParametersIF!" << std::endl; << "implement the correct interface "
<< "HasLocalDataPoolIF!" << std::endl;
return; return;
} }
hkManager = hkOwner->getHkManagerHandle(); hkManager = hkOwner->getHkManagerHandle();

View File

@ -28,7 +28,7 @@ public:
size_t getSerializedSize() const override { size_t getSerializedSize() const override {
size_t linkedSize = SerialLinkedListAdapter::getSerializedSize(); size_t linkedSize = SerialLinkedListAdapter::getSerializedSize();
linkedSize += dataSet->getFillCount() * sizeof(lp_id_t); linkedSize += dataSet->getLocalPoolIdsSerializedSize();
return linkedSize; return linkedSize;
} }