#include "fsfw/datapool/PoolEntry.h" #include #include #include "fsfw/globalfunctions/arrayprinter.h" #include "fsfw/serviceinterface/ServiceInterface.h" template PoolEntry::PoolEntry(uint8_t len, bool setValid) : length(len), valid(setValid) { this->address = new T[this->length](); std::memset(this->address, 0, this->getByteSize()); } template PoolEntry::PoolEntry(std::initializer_list initValues, bool setValid) : length(static_cast(initValues.size())), valid(setValid) { this->address = new T[this->length](); if (initValues.size() > 0) { std::copy(initValues.begin(), initValues.end(), this->address); } } template PoolEntry::PoolEntry(const 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()); } } // 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() { const char* validString = nullptr; if (valid) { validString = "Valid"; } else { validString = "Invalid"; } #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::info << "PoolEntry information." << std::endl; sif::info << "PoolEntry validity: " << validString << std::endl; #else sif::printInfo("PoolEntry information.\n"); sif::printInfo("PoolEntry validity: %s\n", validString); #endif arrayprinter::print(reinterpret_cast(address), getByteSize()); } template inline T* PoolEntry::getDataPtr() { return this->address; } 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; template class PoolEntry; template class PoolEntry;