Ulrich Mohr
ad4adc7cba
Some checks failed
fsfw/fsfw/pipeline/head There was a failure building this commit
115 lines
2.1 KiB
C++
115 lines
2.1 KiB
C++
#pragma once
|
|
|
|
#include <fsfw/returnvalues/returnvalue.h>
|
|
#include <fsfw/introspection/Enum.h>
|
|
#include <fsfw/ipc/MutexIF.h>
|
|
#include <stdint.h>
|
|
|
|
#include <vector>
|
|
|
|
#include "DatasetEntryIF.h"
|
|
#include "HasDatapoolIF.h"
|
|
|
|
class Dataset {
|
|
protected:
|
|
#ifdef FSFW_INTROSPECTION
|
|
Dataset(HasDatapoolIF* owner, bool allowUserCommit);
|
|
Dataset(uint32_t owner_id);
|
|
void setEnum(EnumIF* theEnum);
|
|
#else
|
|
Dataset(HasDatapoolIF* owner, uint8_t id, bool allowUserCommit);
|
|
Dataset(uint32_t owner_id, uint8_t id);
|
|
#endif
|
|
public:
|
|
~Dataset();
|
|
/**
|
|
* Copy content of local copies into actual variable
|
|
*
|
|
*/
|
|
void commit();
|
|
|
|
/**
|
|
* Copy content of local copies into actual variable
|
|
*
|
|
* calls setValit(valid) before committing
|
|
*
|
|
*/
|
|
void commit(bool valid);
|
|
|
|
/**
|
|
* set all contained variables to #valid
|
|
*
|
|
*/
|
|
void setAllValid(bool valid);
|
|
|
|
/**
|
|
* Copy content of actual variables into local copies
|
|
*
|
|
*
|
|
*/
|
|
void read();
|
|
|
|
/**
|
|
* returns true if local copies and actual variables differ
|
|
*
|
|
* implicitely calls read()
|
|
*/
|
|
bool hasChanged();
|
|
|
|
/**
|
|
* returns true if local copies and actual variables differ
|
|
* or time since last time true has been returned is greater than
|
|
* supplied time
|
|
*
|
|
* implicitely calls read()
|
|
*
|
|
*/
|
|
bool hasChangedOrOlderThan(uint32_t seconds);
|
|
|
|
/**
|
|
* get List of contained Valiables
|
|
*/
|
|
virtual const std::vector<DatasetEntryIF*>* getVariables() const;
|
|
|
|
|
|
ReturnValue_t initialize();
|
|
|
|
// operator[]
|
|
|
|
uint8_t getId() const;
|
|
|
|
#ifdef FSFW_INTROSPECTION
|
|
const char* getDescription() const;
|
|
#endif
|
|
|
|
/**
|
|
* returns whether the set is the actual owned set (entries should allocate actual variables)
|
|
*/
|
|
bool registerEntry(DatasetEntryIF*);
|
|
|
|
protected:
|
|
bool allocated;
|
|
bool allowUserCommit;
|
|
union {
|
|
uint32_t id;
|
|
HasDatapoolIF* pointer;
|
|
} owner;
|
|
uint8_t id;
|
|
MutexIF* mutex;
|
|
#ifdef FSFW_INTROSPECTION
|
|
const char* description;
|
|
#endif
|
|
std::vector<DatasetEntryIF*> variables;
|
|
|
|
/**
|
|
* lock the mutex of the set
|
|
*/
|
|
void lock();
|
|
|
|
/**
|
|
* unlock the mutex of the set
|
|
*/
|
|
void unlock();
|
|
|
|
bool hasChangedNoRead();
|
|
}; |