Files
fsfw/datapool/ReadCommitIF.h
T

35 lines
951 B
C++
Raw Normal View History

2020-12-27 01:52:48 +01:00
#ifndef FSFW_DATAPOOL_READCOMMITIF_H_
#define FSFW_DATAPOOL_READCOMMITIF_H_
2021-01-13 12:18:05 +01:00
#include "../returnvalues/HasReturnvaluesIF.h"
#include "../ipc/MutexIF.h"
2020-12-27 01:52:48 +01:00
/**
* @brief Common interface for all software objects which employ read-commit
* semantics.
*/
class ReadCommitIF {
2021-02-28 13:48:53 +01:00
friend class ReadCommitIFAttorney;
2020-12-27 01:52:48 +01:00
public:
virtual ~ReadCommitIF() {}
2021-01-13 11:53:34 +01:00
virtual ReturnValue_t read(MutexIF::TimeoutType timeoutType,
uint32_t timeoutMs) = 0;
virtual ReturnValue_t commit(MutexIF::TimeoutType timeoutType,
uint32_t timeoutMs) = 0;
2020-12-27 01:52:48 +01:00
2021-02-28 14:41:43 +01:00
protected:
2020-12-27 01:52:48 +01:00
2021-02-28 13:48:53 +01:00
/* Optional and protected because this is interesting for classes grouping members with commit
and read semantics where the lock is only necessary once. */
2020-12-27 01:52:48 +01:00
virtual ReturnValue_t readWithoutLock() {
2021-01-13 11:53:34 +01:00
return read(MutexIF::TimeoutType::WAITING, 20);
2020-12-27 01:52:48 +01:00
}
virtual ReturnValue_t commitWithoutLock() {
2021-01-13 11:53:34 +01:00
return commit(MutexIF::TimeoutType::WAITING, 20);
2020-12-27 01:52:48 +01:00
}
};
#endif /* FSFW_DATAPOOL_READCOMMITIF_H_ */