sid cached now
This commit is contained in:
parent
687e124929
commit
a95bc6b293
@ -5,9 +5,6 @@ PoolDataSetBase::PoolDataSetBase(PoolVariableIF** registeredVariablesArray,
|
|||||||
const size_t maxFillCount):
|
const size_t maxFillCount):
|
||||||
registeredVariables(registeredVariablesArray),
|
registeredVariables(registeredVariablesArray),
|
||||||
maxFillCount(maxFillCount) {
|
maxFillCount(maxFillCount) {
|
||||||
for (uint8_t count = 0; count < maxFillCount; count++) {
|
|
||||||
registeredVariables[count] = nullptr;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PoolDataSetBase::~PoolDataSetBase() {}
|
PoolDataSetBase::~PoolDataSetBase() {}
|
||||||
|
@ -5,32 +5,16 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
LocalDataSet::LocalDataSet(HasLocalDataPoolIF *hkOwner,
|
LocalDataSet::LocalDataSet(HasLocalDataPoolIF *hkOwner, uint32_t setId,
|
||||||
const size_t maxNumberOfVariables):
|
const size_t maxNumberOfVariables): poolVarList(maxNumberOfVariables),
|
||||||
LocalPoolDataSetBase(hkOwner,poolVarList.data(), maxNumberOfVariables) {
|
LocalPoolDataSetBase(hkOwner, setId, nullptr, maxNumberOfVariables) {
|
||||||
poolVarList.reserve(maxNumberOfVariables);
|
this->setContainer(poolVarList.data());
|
||||||
poolVarList.resize(maxNumberOfVariables);
|
|
||||||
if(hkOwner == nullptr) {
|
|
||||||
sif::error << "LocalDataSet::LocalDataSet: Owner can't be nullptr!"
|
|
||||||
<< std::endl;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
hkManager = hkOwner->getHkManagerHandle();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LocalDataSet::LocalDataSet(object_id_t ownerId,
|
LocalDataSet::LocalDataSet(sid_t sid, const size_t maxNumberOfVariables):
|
||||||
const size_t maxNumberOfVariables):
|
LocalPoolDataSetBase(sid, nullptr, maxNumberOfVariables),
|
||||||
LocalPoolDataSetBase(ownerId, poolVarList.data(), maxNumberOfVariables) {
|
poolVarList(maxNumberOfVariables) {
|
||||||
poolVarList.reserve(maxNumberOfVariables);
|
this->setContainer(poolVarList.data());
|
||||||
poolVarList.resize(maxNumberOfVariables);
|
|
||||||
HasLocalDataPoolIF* hkOwner = objectManager->get<HasLocalDataPoolIF>(
|
|
||||||
ownerId);
|
|
||||||
if(hkOwner == nullptr) {
|
|
||||||
sif::error << "LocalDataSet::LocalDataSet: Owner can't be nullptr!"
|
|
||||||
<< std::endl;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
hkManager = hkOwner->getHkManagerHandle();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LocalDataSet::~LocalDataSet() {}
|
LocalDataSet::~LocalDataSet() {}
|
||||||
|
@ -5,8 +5,9 @@
|
|||||||
|
|
||||||
class LocalDataSet: public LocalPoolDataSetBase {
|
class LocalDataSet: public LocalPoolDataSetBase {
|
||||||
public:
|
public:
|
||||||
LocalDataSet(HasLocalDataPoolIF* hkOwner, const size_t maxSize);
|
LocalDataSet(HasLocalDataPoolIF* hkOwner, uint32_t setId,
|
||||||
LocalDataSet(object_id_t owner, const size_t maxSize);
|
const size_t maxSize);
|
||||||
|
LocalDataSet(sid_t sid, const size_t maxSize);
|
||||||
virtual~ LocalDataSet();
|
virtual~ LocalDataSet();
|
||||||
|
|
||||||
//! Copying forbidden for now.
|
//! Copying forbidden for now.
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
LocalPoolDataSetBase::LocalPoolDataSetBase(HasLocalDataPoolIF *hkOwner,
|
LocalPoolDataSetBase::LocalPoolDataSetBase(HasLocalDataPoolIF *hkOwner,
|
||||||
PoolVariableIF** registeredVariablesArray,
|
uint32_t setId, PoolVariableIF** registeredVariablesArray,
|
||||||
const size_t maxNumberOfVariables):
|
const size_t maxNumberOfVariables):
|
||||||
PoolDataSetBase(registeredVariablesArray, maxNumberOfVariables) {
|
PoolDataSetBase(registeredVariablesArray, maxNumberOfVariables) {
|
||||||
if(hkOwner == nullptr) {
|
if(hkOwner == nullptr) {
|
||||||
@ -15,20 +15,23 @@ LocalPoolDataSetBase::LocalPoolDataSetBase(HasLocalDataPoolIF *hkOwner,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
hkManager = hkOwner->getHkManagerHandle();
|
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,
|
PoolVariableIF** registeredVariablesArray,
|
||||||
const size_t maxNumberOfVariables):
|
const size_t maxNumberOfVariables):
|
||||||
PoolDataSetBase(registeredVariablesArray, maxNumberOfVariables) {
|
PoolDataSetBase(registeredVariablesArray, maxNumberOfVariables) {
|
||||||
HasLocalDataPoolIF* hkOwner = objectManager->get<HasLocalDataPoolIF>(
|
HasLocalDataPoolIF* hkOwner = objectManager->get<HasLocalDataPoolIF>(
|
||||||
ownerId);
|
sid.objectId);
|
||||||
if(hkOwner == nullptr) {
|
if(hkOwner == nullptr) {
|
||||||
sif::error << "LocalDataSet::LocalDataSet: Owner can't be nullptr!"
|
sif::error << "LocalDataSet::LocalDataSet: Owner can't be nullptr!"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
hkManager = hkOwner->getHkManagerHandle();
|
hkManager = hkOwner->getHkManagerHandle();
|
||||||
|
this->sid = sid;
|
||||||
}
|
}
|
||||||
|
|
||||||
LocalPoolDataSetBase::~LocalPoolDataSetBase() {
|
LocalPoolDataSetBase::~LocalPoolDataSetBase() {
|
||||||
@ -123,14 +126,6 @@ ReturnValue_t LocalPoolDataSetBase::serializeLocalPoolIds(uint8_t** buffer,
|
|||||||
return HasReturnvaluesIF::RETURN_OK;
|
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 {
|
size_t LocalPoolDataSetBase::getSerializedSize() const {
|
||||||
if(withValidityBuffer) {
|
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) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
uint8_t shiftNumber = position + (7 - 2 * position);
|
uint8_t shiftNumber = position + (7 - 2 * position);
|
||||||
|
@ -30,28 +30,25 @@ class LocalDataPoolManager;
|
|||||||
*
|
*
|
||||||
* @ingroup data_pool
|
* @ingroup data_pool
|
||||||
*/
|
*/
|
||||||
// todo: make withValidityBuffer a member
|
|
||||||
class LocalPoolDataSetBase: public PoolDataSetBase {
|
class LocalPoolDataSetBase: public PoolDataSetBase {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Constructor for the creator of local pool data.
|
* @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,
|
LocalPoolDataSetBase(HasLocalDataPoolIF *hkOwner,
|
||||||
PoolVariableIF** registeredVariablesArray,
|
uint32_t setId, PoolVariableIF** registeredVariablesArray,
|
||||||
const size_t maxNumberOfVariables);
|
const size_t maxNumberOfVariables);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Constructor for users of local pool data. The passed pool
|
* @brief Constructor for users of local pool data. The passed pool
|
||||||
* owner should implement the HasHkPoolParametersIF.
|
* owner should implement the HasHkPoolParametersIF.
|
||||||
* The constructor simply sets the fill_count to zero and sets
|
|
||||||
* the state to "uninitialized".
|
|
||||||
* @details
|
* @details
|
||||||
*
|
* @param sid Unique identifier of dataset consisting of object ID and
|
||||||
|
* set ID.
|
||||||
|
* @param registeredVariablesArray
|
||||||
|
* @param maxNumberOfVariables
|
||||||
*/
|
*/
|
||||||
LocalPoolDataSetBase(object_id_t ownerId,
|
LocalPoolDataSetBase(sid_t sid, PoolVariableIF** registeredVariablesArray,
|
||||||
PoolVariableIF** registeredVariablesArray,
|
|
||||||
const size_t maxNumberOfVariables);
|
const size_t maxNumberOfVariables);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -96,6 +93,7 @@ public:
|
|||||||
bool isValid() const override;
|
bool isValid() const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
sid_t sid;
|
||||||
/**
|
/**
|
||||||
* If the valid state of a dataset is always relevant to the whole
|
* If the valid state of a dataset is always relevant to the whole
|
||||||
* data set we can use this flag.
|
* data set we can use this flag.
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#include "SharedLocalDataSet.h"
|
#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),
|
const size_t maxSize): SystemObject(objectId),
|
||||||
LocalPoolDataSetBase(owner, nullptr, maxSize) {
|
LocalPoolDataSetBase(sid, nullptr, maxSize) {
|
||||||
this->setContainer(poolVarVector.data());
|
this->setContainer(poolVarVector.data());
|
||||||
datasetLock = MutexFactory::instance()->createMutex();
|
datasetLock = MutexFactory::instance()->createMutex();
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ class SharedLocalDataSet: public SystemObject,
|
|||||||
public LocalPoolDataSetBase,
|
public LocalPoolDataSetBase,
|
||||||
public SharedDataSetIF {
|
public SharedDataSetIF {
|
||||||
public:
|
public:
|
||||||
SharedLocalDataSet(object_id_t objectId, object_id_t owner,
|
SharedLocalDataSet(object_id_t objectId, sid_t sid,
|
||||||
const size_t maxSize);
|
const size_t maxSize);
|
||||||
ReturnValue_t lockDataset(dur_millis_t mutexTimeout) override;
|
ReturnValue_t lockDataset(dur_millis_t mutexTimeout) override;
|
||||||
ReturnValue_t unlockDataset() override;
|
ReturnValue_t unlockDataset() override;
|
||||||
|
@ -16,8 +16,8 @@
|
|||||||
template <uint8_t NUM_VARIABLES>
|
template <uint8_t NUM_VARIABLES>
|
||||||
class StaticLocalDataSet: public LocalPoolDataSetBase {
|
class StaticLocalDataSet: public LocalPoolDataSetBase {
|
||||||
public:
|
public:
|
||||||
StaticLocalDataSet(object_id_t owner):
|
StaticLocalDataSet(sid_t sid):
|
||||||
LocalPoolDataSetBase(owner, poolVarList.data(), NUM_VARIABLES) {
|
LocalPoolDataSetBase(sid, poolVarList.data(), NUM_VARIABLES) {
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -12,6 +12,10 @@ union sid_t {
|
|||||||
std::numeric_limits<uint64_t>::max();
|
std::numeric_limits<uint64_t>::max();
|
||||||
sid_t(): raw(INVALID_ADDRESS) {}
|
sid_t(): raw(INVALID_ADDRESS) {}
|
||||||
|
|
||||||
|
sid_t(object_id_t objectId, uint32_t setId):
|
||||||
|
objectId(objectId),
|
||||||
|
ownerSetId(setId) {}
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
object_id_t objectId ;
|
object_id_t objectId ;
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user