#include "PoolEntry.h" #include "../serviceinterface/ServiceInterfaceStream.h" #include "../globalfunctions/arrayprinter.h" #include template PoolEntry::PoolEntry(std::initializer_list initValue, uint8_t setLength, bool setValid ) : length(setLength), valid(setValid) { this->address = new T[this->length]; if(initValue.size() == 0) { std::memset(this->address, 0, this->getByteSize()); } else if (initValue.size() != setLength){ sif::warning << "PoolEntry: setLength is not equal to initializer list" "length! Performing zero initialization with given setLength" << std::endl; std::memset(this->address, 0, this->getByteSize()); } else { std::copy(initValue.begin(), initValue.end(), this->address); } } template PoolEntry::PoolEntry( T* initValue, uint8_t setLength, bool setValid ) : length(setLength), valid(setValid) { this->address = new T[this->length]; if (initValue != nullptr) { std::memcpy(this->address, initValue, this->getByteSize() ); } else { std::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 PoolEntry::~PoolEntry() { delete[] this->address; } template uint16_t PoolEntry::getByteSize() { return ( sizeof(T) * this->length ); } template uint8_t PoolEntry::getSize() { return this->length; } template void* PoolEntry::getRawData() { return this->address; } template void PoolEntry::setValid(bool isValid) { this->valid = isValid; } template bool PoolEntry::getValid() { return valid; } template void PoolEntry::print() { sif::debug << "Pool Entry Validity: " << (this->valid? " (valid) " : " (invalid) ") << std::endl; arrayprinter::print(reinterpret_cast(address), length); sif::debug << std::dec << std::endl; } template Type PoolEntry::getType() { return PodTypeConversion::type; } template class PoolEntry; template class PoolEntry; template class PoolEntry; template class PoolEntry; template class PoolEntry; template class PoolEntry; template class PoolEntry; template class PoolEntry;