fsfw/datapoolglob/GlobalDataSet.h

92 lines
2.5 KiB
C
Raw Normal View History

2020-05-17 01:17:11 +02:00
#ifndef DATASET_H_
#define DATASET_H_
2020-05-17 23:41:28 +02:00
#include <framework/datapool/DataSetBase.h>
2020-05-17 01:17:11 +02:00
/**
* @brief The DataSet class manages a set of locally checked out variables
* for the global data pool.
* @details
2020-05-17 23:41:28 +02:00
* This class uses the read-commit() semantic provided by the DataSetBase class.
* It extends the base class by using the global data pool,
* having a valid state and implementing lock und unlock calls for the global
* datapool.
2020-05-17 01:17:11 +02:00
*
2020-05-17 23:41:28 +02:00
* For more information on how this class works, see the DataSetBase
* documentation.
2020-05-17 01:17:11 +02:00
* @author Bastian Baetz
* @ingroup data_pool
*/
2020-05-17 23:41:28 +02:00
class GlobDataSet: public DataSetBase {
2020-05-17 01:17:11 +02:00
public:
/**
2020-05-17 23:41:28 +02:00
* @brief Creates an empty GlobDataSet. Use registerVariable or
* supply a pointer to this dataset to PoolVariable
* initializations to register pool variables.
2020-05-17 01:17:11 +02:00
*/
GlobDataSet();
/**
* @brief The destructor automatically manages writing the valid
* information of variables.
* @details
* In case the data set was read out, but not committed(indicated by state),
* the destructor parses all variables that are still registered to the set.
* For each, the valid flag in the data pool is set to "invalid".
*/
~GlobDataSet();
2020-05-17 23:41:28 +02:00
2020-05-17 01:17:11 +02:00
/**
* Variant of method above which sets validity of all elements of the set.
* @param valid Validity information from PoolVariableIF.
* @return - @c RETURN_OK if all variables were read successfully.
* - @c COMMITING_WITHOUT_READING if set was not read yet and
* contains non write-only variables
*/
ReturnValue_t commit(bool valid);
2020-05-17 23:41:28 +02:00
ReturnValue_t commit() override;
2020-05-17 01:17:11 +02:00
/**
* Set all entries
* @param valid
*/
void setSetValid(bool valid);
/**
* Set the valid information of all variables contained in the set which
* are not read-only
*
* @param valid Validity information from PoolVariableIF.
*/
void setEntriesValid(bool valid);
private:
/**
* If the valid state of a dataset is always relevant to the whole
* data set we can use this flag.
*/
bool valid = false;
2020-05-17 23:41:28 +02:00
2020-05-17 01:17:11 +02:00
/**
* @brief This is a small helper function to facilitate locking
2020-05-17 23:41:28 +02:00
* the global data pool.
2020-05-17 01:17:11 +02:00
* @details
* It makes use of the lockDataPool method offered by the DataPool class.
*/
ReturnValue_t lockDataPool() override;
/**
* @brief This is a small helper function to facilitate
2020-05-17 23:41:28 +02:00
* unlocking the global data pool
2020-05-17 01:17:11 +02:00
* @details
* It makes use of the freeDataPoolLock method offered by the DataPool class.
*/
ReturnValue_t unlockDataPool() override;
void handleAlreadyReadDatasetCommit();
ReturnValue_t handleUnreadDatasetCommit();
};
#endif /* DATASET_H_ */