resolve merge conflict
This commit is contained in:
parent
8d966de735
commit
aea4e5d42c
@ -5,212 +5,162 @@
|
|||||||
#error Include LocalPoolVector.h before LocalPoolVector.tpp!
|
#error Include LocalPoolVector.h before LocalPoolVector.tpp!
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
template <typename T, uint16_t vectorSize>
|
template<typename T, uint16_t vectorSize>
|
||||||
inline LocalPoolVector<T, vectorSize>::LocalPoolVector(HasLocalDataPoolIF* hkOwner, lp_id_t poolId,
|
inline LocalPoolVector<T, vectorSize>::LocalPoolVector(
|
||||||
DataSetIF* dataSet,
|
HasLocalDataPoolIF* hkOwner, lp_id_t poolId, DataSetIF* dataSet,
|
||||||
pool_rwm_t setReadWriteMode)
|
pool_rwm_t setReadWriteMode):
|
||||||
: LocalPoolObjectBase(poolId, hkOwner, dataSet, setReadWriteMode) {}
|
LocalPoolObjectBase(poolId, hkOwner, dataSet, setReadWriteMode) {}
|
||||||
|
|
||||||
template <typename T, uint16_t vectorSize>
|
template<typename T, uint16_t vectorSize>
|
||||||
inline LocalPoolVector<T, vectorSize>::LocalPoolVector(object_id_t poolOwner, lp_id_t poolId,
|
inline LocalPoolVector<T, vectorSize>::LocalPoolVector(object_id_t poolOwner,
|
||||||
DataSetIF* dataSet,
|
lp_id_t poolId, DataSetIF *dataSet, pool_rwm_t setReadWriteMode):
|
||||||
pool_rwm_t setReadWriteMode)
|
LocalPoolObjectBase(poolOwner, poolId, dataSet, setReadWriteMode) {}
|
||||||
: LocalPoolObjectBase(poolOwner, poolId, dataSet, setReadWriteMode) {}
|
|
||||||
|
|
||||||
template <typename T, uint16_t vectorSize>
|
template<typename T, uint16_t vectorSize>
|
||||||
inline LocalPoolVector<T, vectorSize>::LocalPoolVector(gp_id_t globalPoolId, DataSetIF* dataSet,
|
inline LocalPoolVector<T, vectorSize>::LocalPoolVector(gp_id_t globalPoolId,
|
||||||
pool_rwm_t setReadWriteMode)
|
DataSetIF *dataSet, pool_rwm_t setReadWriteMode):
|
||||||
: LocalPoolObjectBase(globalPoolId.objectId, globalPoolId.localPoolId, dataSet,
|
LocalPoolObjectBase(globalPoolId.objectId, globalPoolId.localPoolId,
|
||||||
setReadWriteMode) {}
|
dataSet, setReadWriteMode) {}
|
||||||
|
|
||||||
template <typename T, uint16_t vectorSize>
|
template<typename T, uint16_t vectorSize>
|
||||||
inline ReturnValue_t LocalPoolVector<T, vectorSize>::read(MutexIF::TimeoutType timeoutType,
|
inline ReturnValue_t LocalPoolVector<T, vectorSize>::read(
|
||||||
uint32_t timeoutMs) {
|
MutexIF::TimeoutType timeoutType, uint32_t timeoutMs) {
|
||||||
MutexGuard(LocalDpManagerAttorney::getMutexHandle(*hkManager), timeoutType, timeoutMs);
|
MutexGuard(LocalDpManagerAttorney::getMutexHandle(*hkManager), timeoutType, timeoutMs);
|
||||||
return readWithoutLock();
|
return readWithoutLock();
|
||||||
}
|
}
|
||||||
template <typename T, uint16_t vectorSize>
|
template<typename T, uint16_t vectorSize>
|
||||||
inline ReturnValue_t LocalPoolVector<T, vectorSize>::readWithoutLock() {
|
inline ReturnValue_t LocalPoolVector<T, vectorSize>::readWithoutLock() {
|
||||||
if (readWriteMode == pool_rwm_t::VAR_WRITE) {
|
if(readWriteMode == pool_rwm_t::VAR_WRITE) {
|
||||||
object_id_t targetObjectId = hkManager->getCreatorObjectId();
|
object_id_t targetObjectId = hkManager->getCreatorObjectId();
|
||||||
reportReadCommitError("LocalPoolVector", PoolVariableIF::INVALID_READ_WRITE_MODE, true,
|
reportReadCommitError("LocalPoolVector",
|
||||||
targetObjectId, localPoolId);
|
PoolVariableIF::INVALID_READ_WRITE_MODE, true, targetObjectId,
|
||||||
return PoolVariableIF::INVALID_READ_WRITE_MODE;
|
localPoolId);
|
||||||
}
|
return PoolVariableIF::INVALID_READ_WRITE_MODE;
|
||||||
|
}
|
||||||
|
|
||||||
PoolEntry<T>* poolEntry = nullptr;
|
PoolEntry<T>* poolEntry = nullptr;
|
||||||
ReturnValue_t result =
|
ReturnValue_t result = LocalDpManagerAttorney::fetchPoolEntry(*hkManager, localPoolId,
|
||||||
LocalDpManagerAttorney::fetchPoolEntry(*hkManager, localPoolId, &poolEntry);
|
&poolEntry);
|
||||||
memset(this->value, 0, vectorSize * sizeof(T));
|
memset(this->value, 0, vectorSize * sizeof(T));
|
||||||
|
|
||||||
if (result != RETURN_OK) {
|
if(result != RETURN_OK) {
|
||||||
object_id_t targetObjectId = hkManager->getCreatorObjectId();
|
object_id_t targetObjectId = hkManager->getCreatorObjectId();
|
||||||
reportReadCommitError("LocalPoolVector", result, true, targetObjectId, localPoolId);
|
reportReadCommitError("LocalPoolVector", result, true, targetObjectId,
|
||||||
return result;
|
localPoolId);
|
||||||
}
|
return result;
|
||||||
std::memcpy(this->value, poolEntry->getDataPtr(), poolEntry->getByteSize());
|
}
|
||||||
this->valid = poolEntry->getValid();
|
std::memcpy(this->value, poolEntry->getDataPtr(), poolEntry->getByteSize());
|
||||||
return RETURN_OK;
|
this->valid = poolEntry->getValid();
|
||||||
|
return RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, uint16_t vectorSize>
|
template<typename T, uint16_t vectorSize>
|
||||||
inline ReturnValue_t LocalPoolVector<T, vectorSize>::commit(bool valid,
|
inline ReturnValue_t LocalPoolVector<T, vectorSize>::commit(bool valid,
|
||||||
MutexIF::TimeoutType timeoutType,
|
MutexIF::TimeoutType timeoutType, uint32_t timeoutMs) {
|
||||||
uint32_t timeoutMs) {
|
this->setValid(valid);
|
||||||
this->setValid(valid);
|
return commit(timeoutType, timeoutMs);
|
||||||
return commit(timeoutType, timeoutMs);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, uint16_t vectorSize>
|
template<typename T, uint16_t vectorSize>
|
||||||
inline ReturnValue_t LocalPoolVector<T, vectorSize>::commit(MutexIF::TimeoutType timeoutType,
|
inline ReturnValue_t LocalPoolVector<T, vectorSize>::commit(
|
||||||
uint32_t timeoutMs) {
|
MutexIF::TimeoutType timeoutType, uint32_t timeoutMs) {
|
||||||
MutexGuard(LocalDpManagerAttorney::getMutexHandle(*hkManager), timeoutType, timeoutMs);
|
MutexGuard(LocalDpManagerAttorney::getMutexHandle(*hkManager), timeoutType, timeoutMs);
|
||||||
return commitWithoutLock();
|
return commitWithoutLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, uint16_t vectorSize>
|
template<typename T, uint16_t vectorSize>
|
||||||
inline ReturnValue_t LocalPoolVector<T, vectorSize>::commitWithoutLock() {
|
inline ReturnValue_t LocalPoolVector<T, vectorSize>::commitWithoutLock() {
|
||||||
if (readWriteMode == pool_rwm_t::VAR_READ) {
|
if(readWriteMode == pool_rwm_t::VAR_READ) {
|
||||||
object_id_t targetObjectId = hkManager->getCreatorObjectId();
|
object_id_t targetObjectId = hkManager->getCreatorObjectId();
|
||||||
reportReadCommitError("LocalPoolVector", PoolVariableIF::INVALID_READ_WRITE_MODE, false,
|
reportReadCommitError("LocalPoolVector",
|
||||||
targetObjectId, localPoolId);
|
PoolVariableIF::INVALID_READ_WRITE_MODE, false, targetObjectId,
|
||||||
return PoolVariableIF::INVALID_READ_WRITE_MODE;
|
localPoolId);
|
||||||
}
|
return PoolVariableIF::INVALID_READ_WRITE_MODE;
|
||||||
PoolEntry<T>* poolEntry = nullptr;
|
}
|
||||||
ReturnValue_t result =
|
PoolEntry<T>* poolEntry = nullptr;
|
||||||
LocalDpManagerAttorney::fetchPoolEntry(*hkManager, localPoolId, &poolEntry);
|
ReturnValue_t result = LocalDpManagerAttorney::fetchPoolEntry(*hkManager, localPoolId,
|
||||||
if (result != RETURN_OK) {
|
&poolEntry);
|
||||||
object_id_t targetObjectId = hkManager->getCreatorObjectId();
|
if(result != RETURN_OK) {
|
||||||
reportReadCommitError("LocalPoolVector", result, false, targetObjectId, localPoolId);
|
object_id_t targetObjectId = hkManager->getCreatorObjectId();
|
||||||
|
reportReadCommitError("LocalPoolVector", result, false, targetObjectId,
|
||||||
|
localPoolId);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
std::memcpy(poolEntry->getDataPtr(), this->value, poolEntry->getByteSize());
|
||||||
|
poolEntry->setValid(this->valid);
|
||||||
|
return RETURN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T, uint16_t vectorSize>
|
||||||
|
inline T& LocalPoolVector<T, vectorSize>::operator [](size_t i) {
|
||||||
|
if(i < vectorSize) {
|
||||||
|
return value[i];
|
||||||
|
}
|
||||||
|
// If this happens, I have to set some value. I consider this
|
||||||
|
// a configuration error, but I wont exit here.
|
||||||
|
FSFW_LOGW("LocalPoolVector: Invalid index. Setting or returning last value\n");
|
||||||
|
return value[vectorSize - 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T, uint16_t vectorSize>
|
||||||
|
inline const T& LocalPoolVector<T, vectorSize>::operator [](size_t i) const {
|
||||||
|
if(i < vectorSize) {
|
||||||
|
return value[i];
|
||||||
|
}
|
||||||
|
// If this happens, I have to set some value. I consider this
|
||||||
|
// a configuration error, but I wont exit here.
|
||||||
|
FSFW_LOGW("LocalPoolVector: Invalid index. Setting or returning last value\n");
|
||||||
|
return value[vectorSize - 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T, uint16_t vectorSize>
|
||||||
|
inline ReturnValue_t LocalPoolVector<T, vectorSize>::serialize(uint8_t** buffer,
|
||||||
|
size_t* size, size_t maxSize,
|
||||||
|
SerializeIF::Endianness streamEndianness) const {
|
||||||
|
ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED;
|
||||||
|
for (uint16_t i = 0; i < vectorSize; i++) {
|
||||||
|
result = SerializeAdapter::serialize(&(value[i]), buffer, size,
|
||||||
|
maxSize, streamEndianness);
|
||||||
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
|
||||||
std::memcpy(poolEntry->getDataPtr(), this->value, poolEntry->getByteSize());
|
|
||||||
poolEntry->setValid(this->valid);
|
|
||||||
return RETURN_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, uint16_t vectorSize>
|
template<typename T, uint16_t vectorSize>
|
||||||
inline T& LocalPoolVector<T, vectorSize>::operator[](size_t i) {
|
|
||||||
if (i < vectorSize) {
|
|
||||||
return value[i];
|
|
||||||
}
|
|
||||||
// If this happens, I have to set some value. I consider this
|
|
||||||
// a configuration error, but I wont exit here.
|
|
||||||
FSFW_LOGWT("{}", "operator[]: Invalid index. Setting or returning last value\n");
|
|
||||||
return value[vectorSize - 1];
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T, uint16_t vectorSize>
|
|
||||||
inline const T& LocalPoolVector<T, vectorSize>::operator[](size_t i) const {
|
|
||||||
if (i < vectorSize) {
|
|
||||||
return value[i];
|
|
||||||
}
|
|
||||||
// If this happens, I have to set some value. I consider this
|
|
||||||
// a configuration error, but I wont exit here.
|
|
||||||
FSFW_LOGWT("{}", "operator[]: Invalid index. Setting or returning last value\n");
|
|
||||||
return value[vectorSize - 1];
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T, uint16_t vectorSize>
|
|
||||||
inline ReturnValue_t LocalPoolVector<T, vectorSize>::serialize(
|
|
||||||
uint8_t** buffer, size_t* size, size_t maxSize,
|
|
||||||
SerializeIF::Endianness streamEndianness) const {
|
|
||||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED;
|
|
||||||
for (uint16_t i = 0; i < vectorSize; i++) {
|
|
||||||
result = SerializeAdapter::serialize(&(value[i]), buffer, size, maxSize, streamEndianness);
|
|
||||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
std::memcpy(poolEntry->getDataPtr(), this->value, poolEntry->getByteSize());
|
|
||||||
poolEntry->setValid(this->valid);
|
|
||||||
return RETURN_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T, uint16_t vectorSize>
|
|
||||||
inline T& LocalPoolVector<T, vectorSize>::operator[](size_t i) {
|
|
||||||
if (i < vectorSize) {
|
|
||||||
return value[i];
|
|
||||||
}
|
|
||||||
// If this happens, I have to set some value. I consider this
|
|
||||||
// a configuration error, but I wont exit here.
|
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
|
||||||
sif::warning << "LocalPoolVector: Invalid index. Setting or returning"
|
|
||||||
" last value!"
|
|
||||||
<< std::endl;
|
|
||||||
#else
|
|
||||||
sif::printWarning(
|
|
||||||
"LocalPoolVector: Invalid index. Setting or returning"
|
|
||||||
" last value!\n");
|
|
||||||
#endif
|
|
||||||
return value[vectorSize - 1];
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T, uint16_t vectorSize>
|
|
||||||
inline const T& LocalPoolVector<T, vectorSize>::operator[](size_t i) const {
|
|
||||||
if (i < vectorSize) {
|
|
||||||
return value[i];
|
|
||||||
}
|
|
||||||
// If this happens, I have to set some value. I consider this
|
|
||||||
// a configuration error, but I wont exit here.
|
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
|
||||||
sif::warning << "LocalPoolVector: Invalid index. Setting or returning"
|
|
||||||
" last value!"
|
|
||||||
<< std::endl;
|
|
||||||
#else
|
|
||||||
sif::printWarning(
|
|
||||||
"LocalPoolVector: Invalid index. Setting or returning"
|
|
||||||
" last value!\n");
|
|
||||||
#endif
|
|
||||||
return value[vectorSize - 1];
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T, uint16_t vectorSize>
|
|
||||||
inline ReturnValue_t LocalPoolVector<T, vectorSize>::serialize(
|
|
||||||
uint8_t** buffer, size_t* size, size_t maxSize,
|
|
||||||
SerializeIF::Endianness streamEndianness) const {
|
|
||||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED;
|
|
||||||
for (uint16_t i = 0; i < vectorSize; i++) {
|
|
||||||
result = SerializeAdapter::serialize(&(value[i]), buffer, size, maxSize, streamEndianness);
|
|
||||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T, uint16_t vectorSize>
|
|
||||||
inline size_t LocalPoolVector<T, vectorSize>::getSerializedSize() const {
|
inline size_t LocalPoolVector<T, vectorSize>::getSerializedSize() const {
|
||||||
return vectorSize * SerializeAdapter::getSerializedSize(value);
|
return vectorSize * SerializeAdapter::getSerializedSize(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, uint16_t vectorSize>
|
template<typename T, uint16_t vectorSize>
|
||||||
inline ReturnValue_t LocalPoolVector<T, vectorSize>::deSerialize(
|
inline ReturnValue_t LocalPoolVector<T, vectorSize>::deSerialize(
|
||||||
const uint8_t** buffer, size_t* size, SerializeIF::Endianness streamEndianness) {
|
const uint8_t** buffer, size_t* size,
|
||||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED;
|
SerializeIF::Endianness streamEndianness) {
|
||||||
for (uint16_t i = 0; i < vectorSize; i++) {
|
ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED;
|
||||||
result = SerializeAdapter::deSerialize(&(value[i]), buffer, size, streamEndianness);
|
for (uint16_t i = 0; i < vectorSize; i++) {
|
||||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
result = SerializeAdapter::deSerialize(&(value[i]), buffer, size,
|
||||||
break;
|
streamEndianness);
|
||||||
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
return result;
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
template <typename T, uint16_t vectorSize>
|
template<typename T, uint16_t vectorSize>
|
||||||
inline std::ostream& operator<<(std::ostream& out, const LocalPoolVector<T, vectorSize>& var) {
|
inline std::ostream& operator<< (std::ostream &out,
|
||||||
out << "Vector: [";
|
const LocalPoolVector<T, vectorSize> &var) {
|
||||||
for (int i = 0; i < vectorSize; i++) {
|
out << "Vector: [";
|
||||||
out << var.value[i];
|
for(int i = 0;i < vectorSize; i++) {
|
||||||
if (i < vectorSize - 1) {
|
out << var.value[i];
|
||||||
out << ", ";
|
if(i < vectorSize - 1) {
|
||||||
|
out << ", ";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
out << "]";
|
||||||
out << "]";
|
return out;
|
||||||
return out;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user