1
0
forked from fsfw/fsfw
This commit is contained in:
2020-12-03 13:00:04 +01:00
parent 0cf65af506
commit 464988ca61
18 changed files with 1346 additions and 577 deletions

View File

@ -1,6 +1,7 @@
#ifndef FSFW_DATAPOOLLOCAL_LOCALPOOLVARIABLE_H_
#define FSFW_DATAPOOLLOCAL_LOCALPOOLVARIABLE_H_
#include "LocalPoolObjectBase.h"
#include "HasLocalDataPoolIF.h"
#include "LocalDataPoolManager.h"
@ -21,7 +22,7 @@
* @ingroup data_pool
*/
template<typename T>
class LocalPoolVar: public PoolVariableIF, HasReturnvaluesIF {
class LocalPoolVar: public LocalPoolObjectBase {
public:
//! Default ctor is forbidden.
LocalPoolVar() = delete;
@ -42,7 +43,7 @@ public:
* If nullptr, the variable is not registered.
* @param setReadWriteMode Specify the read-write mode of the pool variable.
*/
LocalPoolVar(lp_id_t poolId, HasLocalDataPoolIF* hkOwner,
LocalPoolVar(HasLocalDataPoolIF* hkOwner, lp_id_t poolId,
DataSetIF* dataSet = nullptr,
pool_rwm_t setReadWriteMode = pool_rwm_t::VAR_READ_WRITE);
@ -63,9 +64,17 @@ public:
* @param setReadWriteMode Specify the read-write mode of the pool variable.
*
*/
LocalPoolVar(lp_id_t poolId, object_id_t poolOwner,
LocalPoolVar(object_id_t poolOwner, lp_id_t poolId,
DataSetIF* dataSet = nullptr,
pool_rwm_t setReadWriteMode = pool_rwm_t::VAR_READ_WRITE);
/**
* Variation which takes the global unique identifier of a pool variable.
* @param globalPoolId
* @param dataSet
* @param setReadWriteMode
*/
LocalPoolVar(gp_id_t globalPoolId, DataSetIF* dataSet = nullptr,
pool_rwm_t setReadWriteMode = pool_rwm_t::VAR_READ_WRITE);
virtual~ LocalPoolVar() {};
@ -76,15 +85,6 @@ public:
*/
T value = 0;
pool_rwm_t getReadWriteMode() const override;
lp_id_t getDataPoolId() const override;
void setDataPoolId(lp_id_t poolId);
bool isValid() const override;
void setValid(bool validity) override;
uint8_t getValid() const;
ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
SerializeIF::Endianness streamEndianness) const override;
virtual size_t getSerializedSize() const override;
@ -118,7 +118,25 @@ public:
ReturnValue_t commit(dur_millis_t lockTimeout = MutexIF::BLOCKING) override;
LocalPoolVar<T> &operator=(T newValue);
LocalPoolVar<T> &operator=(const T& newValue);
LocalPoolVar<T> &operator=(const LocalPoolVar<T>& newPoolVariable);
//! Explicit type conversion operator. Allows casting the class to
//! its template type to perform operations on value.
explicit operator T() const;
bool operator==(const LocalPoolVar<T>& other) const;
bool operator==(const T& other) const;
bool operator!=(const LocalPoolVar<T>& other) const;
bool operator!=(const T& other) const;
bool operator<(const LocalPoolVar<T>& other) const;
bool operator<(const T& other) const;
bool operator>(const LocalPoolVar<T>& other) const;
bool operator>(const T& other) const;
protected:
/**
* @brief Like #read, but without a lock protection of the global pool.
@ -145,15 +163,6 @@ protected:
const LocalPoolVar<U> &var);
private:
//! @brief Pool ID of pool entry inside the used local pool.
lp_id_t localPoolId = PoolVariableIF::NO_PARAMETER;
//! @brief Read-write mode of the pool variable
pool_rwm_t readWriteMode = pool_rwm_t::VAR_READ_WRITE;
//! @brief Specifies whether the entry is valid or invalid.
bool valid = false;
//! Pointer to the class which manages the HK pool.
LocalDataPoolManager* hkManager;
};
#include "LocalPoolVariable.tpp"
@ -173,5 +182,4 @@ using lp_int64_t = LocalPoolVar<int64_t>;
using lp_float_t = LocalPoolVar<float>;
using lp_double_t = LocalPoolVar<double>;
#endif /* FSFW_DATAPOOLLOCAL_LOCALPOOLVARIABLE_H_ */