new pool ctor which only takes len
This commit is contained in:
parent
1bc7a91869
commit
761a0c9bac
@ -7,13 +7,19 @@
|
|||||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
PoolEntry<T>::PoolEntry(std::initializer_list<T> initValue, bool setValid)
|
PoolEntry<T>::PoolEntry(uint8_t len, bool setValid): length(len), valid(setValid) {
|
||||||
: length(static_cast<uint8_t>(initValue.size())), valid(setValid) {
|
|
||||||
this->address = new T[this->length];
|
this->address = new T[this->length];
|
||||||
if (initValue.size() == 0) {
|
std::memset(this->address, 0, this->getByteSize());
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
PoolEntry<T>::PoolEntry(std::initializer_list<T> initValues, bool setValid)
|
||||||
|
: length(static_cast<uint8_t>(initValues.size())), valid(setValid) {
|
||||||
|
this->address = new T[this->length];
|
||||||
|
if (initValues.size() == 0) {
|
||||||
std::memset(this->address, 0, this->getByteSize());
|
std::memset(this->address, 0, this->getByteSize());
|
||||||
} else {
|
} else {
|
||||||
std::copy(initValue.begin(), initValue.end(), this->address);
|
std::copy(initValues.begin(), initValues.end(), this->address);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,6 +33,9 @@ class PoolEntry : public PoolEntryIF {
|
|||||||
"instead! The ECSS standard defines a boolean as a one bit "
|
"instead! The ECSS standard defines a boolean as a one bit "
|
||||||
"field. Therefore it is preferred to store a boolean as an "
|
"field. Therefore it is preferred to store a boolean as an "
|
||||||
"uint8_t");
|
"uint8_t");
|
||||||
|
|
||||||
|
PoolEntry(uint8_t len = 1, bool setValid = false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief In the classe's constructor, space is allocated on the heap and
|
* @brief In the classe's constructor, space is allocated on the heap and
|
||||||
* potential initialization values are copied to that space.
|
* potential initialization values are copied to that space.
|
||||||
@ -49,7 +52,7 @@ class PoolEntry : public PoolEntryIF {
|
|||||||
* @param setValid
|
* @param setValid
|
||||||
* Sets the initialization flag. It is invalid by default.
|
* Sets the initialization flag. It is invalid by default.
|
||||||
*/
|
*/
|
||||||
PoolEntry(std::initializer_list<T> initValue = {0}, bool setValid = false);
|
PoolEntry(std::initializer_list<T> initValue, bool setValid = false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief In the classe's constructor, space is allocated on the heap and
|
* @brief In the classe's constructor, space is allocated on the heap and
|
||||||
|
Loading…
Reference in New Issue
Block a user