diff --git a/datapool/PoolEntry.cpp b/datapool/PoolEntry.cpp index af5584d8..898d226e 100644 --- a/datapool/PoolEntry.cpp +++ b/datapool/PoolEntry.cpp @@ -12,6 +12,17 @@ PoolEntry::PoolEntry(std::initializer_list initValue, uint8_t set_length, } } +template +PoolEntry::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 != NULL) { + memcpy(this->address, initValue, this->getByteSize() ); + } else { + memset(this->address, 0, this->getByteSize() ); + } +} + + //As the data pool is global, this dtor is only be called on program exit. //Warning! Never copy pool entries! template diff --git a/datapool/PoolEntry.h b/datapool/PoolEntry.h index 97364bf0..a02c6c60 100644 --- a/datapool/PoolEntry.h +++ b/datapool/PoolEntry.h @@ -33,6 +33,7 @@ public: * \param set_valid Sets the initialization flag. It is invalid (0) by default. */ PoolEntry( std::initializer_list initValue = {}, uint8_t set_length = 1, uint8_t set_valid = 0 ); + PoolEntry( T* initValue = NULL, uint8_t set_length = 1, uint8_t set_valid = 0 ); /** * \brief The allocated memory for the variable is freed in the destructor. * \details As the data pool is global, this dtor is only called on program exit.