switching to non template set, added valid flag handling
This commit is contained in:
parent
753d587b69
commit
4c0d9ae039
@ -8,14 +8,14 @@
|
||||
#include "HasDatapoolIF.h"
|
||||
|
||||
#ifdef FSFW_INTROSPECTION
|
||||
Dataset::Dataset(HasDatapoolIF* owner, bool allowUserCommit)
|
||||
: HousekeepingSet(owner), allocated(true), allowUserCommit(allowUserCommit) {
|
||||
Dataset::Dataset(HasDatapoolIF* owner, const EnumIF &id, bool allowUserCommit)
|
||||
: HousekeepingSet(owner, id), allocated(true), allowUserCommit(allowUserCommit) {
|
||||
this->owner.pointer = owner;
|
||||
mutex = MutexFactory::instance()->createMutex();
|
||||
}
|
||||
|
||||
Dataset::Dataset(uint32_t owner_id)
|
||||
: HousekeepingSet(nullptr), allocated(false), allowUserCommit(false) {
|
||||
Dataset::Dataset(uint32_t owner_id, const EnumIF &id)
|
||||
: HousekeepingSet(nullptr, id), allocated(false), allowUserCommit(false) {
|
||||
this->owner.id = owner_id;
|
||||
}
|
||||
#else
|
||||
|
@ -46,8 +46,8 @@ class HasDatapoolIF;
|
||||
class Dataset : public HousekeepingSet {
|
||||
protected:
|
||||
#ifdef FSFW_INTROSPECTION
|
||||
Dataset(HasDatapoolIF* owner, bool allowUserCommit);
|
||||
Dataset(uint32_t owner_id);
|
||||
Dataset(HasDatapoolIF* owner, const EnumIF &id, bool allowUserCommit);
|
||||
Dataset(uint32_t owner_id, const EnumIF &id);
|
||||
#else
|
||||
Dataset(HasDatapoolIF* owner, HousekeepingSetId_t id, bool allowUserCommit);
|
||||
Dataset(uint32_t owner_id, HousekeepingSetId_t id);
|
||||
|
@ -1,128 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "Dataset.h"
|
||||
#include "DatasetEntryIF.h"
|
||||
|
||||
template <typename T>
|
||||
class DatasetEntry : public DatasetEntryIF {
|
||||
protected:
|
||||
#ifdef FSFW_INTROSPECTION
|
||||
DatasetEntry(Dataset* set, const char* name) : name(name) {
|
||||
#else
|
||||
DatasetEntry(Dataset* set) {
|
||||
#endif
|
||||
allocated = set->registerEntry(this);
|
||||
if (!allocated) {
|
||||
return;
|
||||
}
|
||||
storedValue = new T();
|
||||
storedValid = new bool;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
#ifdef FSFW_INTROSPECTION
|
||||
Types::ParameterType getType() override {
|
||||
return enumHelper<std::is_base_of<EnumIF, T>::value>::template getType<T>();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef FSFW_INTROSPECTION
|
||||
static DatasetEntry createEntry(Dataset* set, const char *name) {
|
||||
return DatasetEntry(set, name);
|
||||
}
|
||||
#else
|
||||
static DatasetEntry createEntry(Dataset* set) { return DatasetEntry(set); }
|
||||
#endif
|
||||
|
||||
~DatasetEntry() {
|
||||
if (allocated) {
|
||||
delete storedValue;
|
||||
delete storedValid;
|
||||
}
|
||||
}
|
||||
|
||||
operator T() {
|
||||
return value;
|
||||
}
|
||||
|
||||
DatasetEntry &operator=(T newValue){
|
||||
value = newValue;
|
||||
return *this;
|
||||
}
|
||||
|
||||
void setValid(bool isValid) override { valid = isValid; }
|
||||
|
||||
bool getValid() override { return valid; }
|
||||
|
||||
// TODO this is generic with the action parameter
|
||||
#ifdef FSFW_INTROSPECTION
|
||||
double getFloating() override { return (double)value; }
|
||||
int64_t getSigned() override { return (int64_t)value; }
|
||||
|
||||
bool setFloating(double value) override {
|
||||
if (getType() != Types::FLOATING) {
|
||||
return false;
|
||||
}
|
||||
this->value = value;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool setSigned(int64_t value) override {
|
||||
if ((getType() != Types::SIGNED) && (getType() != Types::ENUM)) {
|
||||
return false;
|
||||
}
|
||||
this->value = value;
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<int64_t> getEnumValues() override {
|
||||
return enumHelper<std::is_base_of<EnumIF, T>::value>::getEnumValues(&value);
|
||||
}
|
||||
const char* const* getEnumDescriptions() override {
|
||||
return enumHelper<std::is_base_of<EnumIF, T>::value>::getEnumDescriptions(&value);
|
||||
}
|
||||
|
||||
const char* getName() override { return name; }
|
||||
|
||||
private:
|
||||
const char* name;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void commit() override {
|
||||
*storedValue = value;
|
||||
*storedValid = valid;
|
||||
}
|
||||
|
||||
void read() override {
|
||||
value = *storedValue;
|
||||
valid = *storedValid;
|
||||
}
|
||||
|
||||
void connect(DatasetEntryIF* entry) override {
|
||||
DatasetEntry<T>* theOther = dynamic_cast<DatasetEntry<T>*>(entry);
|
||||
if (theOther == nullptr) {
|
||||
// Configuration error
|
||||
return;
|
||||
}
|
||||
this->storedValue = theOther->storedValue;
|
||||
this->storedValid = theOther->storedValid;
|
||||
}
|
||||
|
||||
bool changed() override { return ((value != *storedValue) || (valid != *storedValid)); }
|
||||
|
||||
private:
|
||||
T value;
|
||||
T* storedValue;
|
||||
bool* storedValid;
|
||||
bool valid;
|
||||
bool allocated;
|
||||
};
|
||||
|
||||
#ifdef FSFW_INTROSPECTION
|
||||
#define createEntry(p1, p2) createEntry(p1, p2)
|
||||
#else
|
||||
#define createEntry(p1, p2) createEntry(p1)
|
||||
#endif
|
@ -1,25 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "Dataset.h"
|
||||
|
||||
//TODO use object_id_t
|
||||
|
||||
template <typename HkIDs>
|
||||
class TemplateSet : public Dataset {
|
||||
public:
|
||||
#ifdef FSFW_INTROSPECTION
|
||||
TemplateSet(HasDatapoolIF* owner, HkIDs id, bool allowUserCommit)
|
||||
: Dataset(owner, allowUserCommit) {
|
||||
setEnum(&id);
|
||||
owner->getDatapoolHelper()->registerSet(this);
|
||||
}
|
||||
TemplateSet(uint32_t owner_id, HkIDs id) : Dataset(owner_id) { setEnum(&id); }
|
||||
#else
|
||||
TemplateSet(HasDatapoolIF* owner, HkIDs id, bool allowUserCommit)
|
||||
: Dataset(owner, static_cast<HousekeepingSetId_t>(id), allowUserCommit) {
|
||||
owner->getDatapoolHelper()->registerSet(this);
|
||||
}
|
||||
TemplateSet(uint32_t owner_id, HkIDs id) : Dataset(owner_id, static_cast<HousekeepingSetId_t>(id)) {}
|
||||
#endif
|
||||
virtual ~TemplateSet() = default;
|
||||
};
|
@ -5,16 +5,13 @@
|
||||
#include "GeneratesHousekeepingIF.h"
|
||||
|
||||
#ifdef FSFW_INTROSPECTION
|
||||
HousekeepingSet::HousekeepingSet(GeneratesHousekeepingIF* owner) {
|
||||
HousekeepingSet::HousekeepingSet(GeneratesHousekeepingIF* owner, const EnumIF &id) {
|
||||
if (owner != nullptr) {
|
||||
helper = owner->getHousekeepingHelper();
|
||||
helper->registerSet(this);
|
||||
}
|
||||
}
|
||||
|
||||
void HousekeepingSet::setEnum(EnumIF* theEnum) {
|
||||
id = theEnum->getValue();
|
||||
description = theEnum->getDescription();
|
||||
this->id = id.getValue();
|
||||
description = id.getDescription();
|
||||
}
|
||||
|
||||
const char* HousekeepingSet::getDescription() const { return description; }
|
||||
|
@ -17,8 +17,7 @@ class HousekeepingSet : public HasTmTcParametersIF, public SerializeIF {
|
||||
|
||||
public:
|
||||
#ifdef FSFW_INTROSPECTION
|
||||
HousekeepingSet(GeneratesHousekeepingIF* owner);
|
||||
void setEnum(EnumIF* theEnum);
|
||||
HousekeepingSet(GeneratesHousekeepingIF* owner, const EnumIF &id);
|
||||
#else
|
||||
HousekeepingSet(GeneratesHousekeepingIF* owner, HousekeepingSetId_t id);
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user