1
0
forked from fsfw/fsfw

new initializer list ctor

This commit is contained in:
2020-05-08 14:38:10 +02:00
parent 6dc05e4951
commit fadebe2eb4
2 changed files with 62 additions and 35 deletions

View File

@ -2,9 +2,22 @@
#include <framework/serviceinterface/ServiceInterfaceStream.h>
template <typename T>
PoolEntry<T>::PoolEntry( T* initValue, uint8_t set_length, uint8_t set_valid ) : length(set_length), valid(set_valid) {
PoolEntry<T>::PoolEntry(std::initializer_list<T> initValue, uint8_t set_length,
uint8_t set_valid ) : length(set_length), valid(set_valid) {
this->address = new T[this->length];
if (initValue != NULL) {
if(initValue.size() == 0) {
memset(this->address, 0, this->getByteSize());
}
else {
memcpy(this->address, initValue.begin(), this->getByteSize());
}
}
template <typename T>
PoolEntry<T>::PoolEntry( T* initValue, uint8_t set_length, uint8_t set_valid ) :
length(set_length), valid(set_valid) {
this->address = new T[this->length];
if (initValue != nullptr) {
memcpy(this->address, initValue, this->getByteSize() );
} else {
memset(this->address, 0, this->getByteSize() );
@ -57,6 +70,7 @@ Type PoolEntry<T>::getType() {
return PodTypeConversion<T>::type;
}
template class PoolEntry<bool>;
template class PoolEntry<uint8_t>;
template class PoolEntry<uint16_t>;
template class PoolEntry<uint32_t>;