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

View File

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

View File

@ -119,8 +119,14 @@ ReturnValue_t LocalPoolDataSetBase::unlockDataPool() {
}
ReturnValue_t LocalPoolDataSetBase::serializeLocalPoolIds(uint8_t** buffer,
size_t* size, size_t maxSize,
SerializeIF::Endianness streamEndianness) const {
size_t* size, size_t maxSize,SerializeIF::Endianness streamEndianness,
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++) {
lp_id_t currentPoolId = registeredVariables[count]->getDataPoolId();
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 {
if(withValidityBuffer) {
uint8_t validityMaskSize = std::ceil(static_cast<float>(fillCount)/8.0);

View File

@ -97,7 +97,9 @@ public:
size_t *size, SerializeIF::Endianness streamEndianness);
ReturnValue_t serializeLocalPoolIds(uint8_t** buffer,
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

View File

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

View File

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