FSFW Update #4
@ -1,5 +1,8 @@
|
|||||||
#include "PoolDataSetBase.h"
|
#include "PoolDataSetBase.h"
|
||||||
|
#include "ReadCommitIFAttorney.h"
|
||||||
|
|
||||||
#include "../serviceinterface/ServiceInterfaceStream.h"
|
#include "../serviceinterface/ServiceInterfaceStream.h"
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
PoolDataSetBase::PoolDataSetBase(PoolVariableIF** registeredVariablesArray,
|
PoolDataSetBase::PoolDataSetBase(PoolVariableIF** registeredVariablesArray,
|
||||||
@ -76,12 +79,12 @@ uint16_t PoolDataSetBase::getFillCount() const {
|
|||||||
ReturnValue_t PoolDataSetBase::readVariable(uint16_t count) {
|
ReturnValue_t PoolDataSetBase::readVariable(uint16_t count) {
|
||||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||||
if(registeredVariables[count] == nullptr) {
|
if(registeredVariables[count] == nullptr) {
|
||||||
// configuration error.
|
/* Configuration error. */
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
// These checks are often performed by the respective
|
/* These checks are often performed by the respective variable implementation too, but I guess
|
||||||
// variable implementation too, but I guess a double check does not hurt.
|
a double check does not hurt. */
|
||||||
if (registeredVariables[count]->getReadWriteMode() !=
|
if (registeredVariables[count]->getReadWriteMode() !=
|
||||||
PoolVariableIF::VAR_WRITE and
|
PoolVariableIF::VAR_WRITE and
|
||||||
registeredVariables[count]->getDataPoolId()
|
registeredVariables[count]->getDataPoolId()
|
||||||
@ -93,7 +96,7 @@ ReturnValue_t PoolDataSetBase::readVariable(uint16_t count) {
|
|||||||
mutexTimeoutForSingleVars);
|
mutexTimeoutForSingleVars);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
result = registeredVariables[count]->readWithoutLock();
|
result = ReadCommitIFAttorney::readWithoutLock(registeredVariables[count]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
@ -128,7 +131,7 @@ void PoolDataSetBase::handleAlreadyReadDatasetCommit(
|
|||||||
mutexTimeoutForSingleVars);
|
mutexTimeoutForSingleVars);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
registeredVariables[count]->commitWithoutLock();
|
ReadCommitIFAttorney::commitWithoutLock(registeredVariables[count]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,8 @@
|
|||||||
* @author Bastian Baetz
|
* @author Bastian Baetz
|
||||||
* @ingroup data_pool
|
* @ingroup data_pool
|
||||||
*/
|
*/
|
||||||
class PoolDataSetBase: public PoolDataSetIF,
|
class PoolDataSetBase:
|
||||||
|
public PoolDataSetIF,
|
||||||
public SerializeIF,
|
public SerializeIF,
|
||||||
public HasReturnvaluesIF {
|
public HasReturnvaluesIF {
|
||||||
public:
|
public:
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
#ifndef FSFW_DATAPOOL_POOLVARIABLEIF_H_
|
#ifndef FSFW_DATAPOOL_POOLVARIABLEIF_H_
|
||||||
#define FSFW_DATAPOOL_POOLVARIABLEIF_H_
|
#define FSFW_DATAPOOL_POOLVARIABLEIF_H_
|
||||||
|
|
||||||
|
#include "ReadCommitIF.h"
|
||||||
#include "../returnvalues/HasReturnvaluesIF.h"
|
#include "../returnvalues/HasReturnvaluesIF.h"
|
||||||
#include "../serialize/SerializeIF.h"
|
#include "../serialize/SerializeIF.h"
|
||||||
#include "ReadCommitIF.h"
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This interface is used to control data pool
|
* @brief This interface is used to control data pool
|
||||||
@ -18,10 +19,10 @@
|
|||||||
* @author Bastian Baetz
|
* @author Bastian Baetz
|
||||||
* @ingroup data_pool
|
* @ingroup data_pool
|
||||||
*/
|
*/
|
||||||
class PoolVariableIF : public SerializeIF,
|
class PoolVariableIF :
|
||||||
|
public SerializeIF,
|
||||||
public ReadCommitIF {
|
public ReadCommitIF {
|
||||||
friend class PoolDataSetBase;
|
|
||||||
friend class LocalPoolDataSetBase;
|
|
||||||
public:
|
public:
|
||||||
static constexpr uint8_t INTERFACE_ID = CLASS_ID::POOL_VARIABLE_IF;
|
static constexpr uint8_t INTERFACE_ID = CLASS_ID::POOL_VARIABLE_IF;
|
||||||
static constexpr ReturnValue_t INVALID_READ_WRITE_MODE = MAKE_RETURN_CODE(0xA0);
|
static constexpr ReturnValue_t INVALID_READ_WRITE_MODE = MAKE_RETURN_CODE(0xA0);
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
* semantics.
|
* semantics.
|
||||||
*/
|
*/
|
||||||
class ReadCommitIF {
|
class ReadCommitIF {
|
||||||
|
friend class ReadCommitIFAttorney;
|
||||||
public:
|
public:
|
||||||
virtual ~ReadCommitIF() {}
|
virtual ~ReadCommitIF() {}
|
||||||
virtual ReturnValue_t read(MutexIF::TimeoutType timeoutType,
|
virtual ReturnValue_t read(MutexIF::TimeoutType timeoutType,
|
||||||
@ -16,11 +17,10 @@ public:
|
|||||||
virtual ReturnValue_t commit(MutexIF::TimeoutType timeoutType,
|
virtual ReturnValue_t commit(MutexIF::TimeoutType timeoutType,
|
||||||
uint32_t timeoutMs) = 0;
|
uint32_t timeoutMs) = 0;
|
||||||
|
|
||||||
protected:
|
public:
|
||||||
|
|
||||||
//! Optional and protected because this is interesting for classes grouping
|
/* Optional and protected because this is interesting for classes grouping members with commit
|
||||||
//! members with commit and read semantics where the lock is only necessary
|
and read semantics where the lock is only necessary once. */
|
||||||
//! once.
|
|
||||||
virtual ReturnValue_t readWithoutLock() {
|
virtual ReturnValue_t readWithoutLock() {
|
||||||
return read(MutexIF::TimeoutType::WAITING, 20);
|
return read(MutexIF::TimeoutType::WAITING, 20);
|
||||||
}
|
}
|
||||||
|
32
datapool/ReadCommitIFAttorney.h
Normal file
32
datapool/ReadCommitIFAttorney.h
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
#ifndef FSFW_DATAPOOL_READCOMMITIFATTORNEY_H_
|
||||||
|
#define FSFW_DATAPOOL_READCOMMITIFATTORNEY_H_
|
||||||
|
|
||||||
|
#include <fsfw/datapool/ReadCommitIF.h>
|
||||||
|
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This class determines which members are allowed to access protected members
|
||||||
|
* of the ReadCommitIF.
|
||||||
|
*/
|
||||||
|
class ReadCommitIFAttorney {
|
||||||
|
private:
|
||||||
|
static ReturnValue_t readWithoutLock(ReadCommitIF* readCommitIF) {
|
||||||
|
if(readCommitIF == nullptr) {
|
||||||
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
|
}
|
||||||
|
return readCommitIF->readWithoutLock();
|
||||||
|
}
|
||||||
|
|
||||||
|
static ReturnValue_t commitWithoutLock(ReadCommitIF* readCommitIF) {
|
||||||
|
if(readCommitIF == nullptr) {
|
||||||
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
|
}
|
||||||
|
return readCommitIF->commitWithoutLock();
|
||||||
|
}
|
||||||
|
|
||||||
|
friend class PoolDataSetBase;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* FSFW_DATAPOOL_READCOMMITIFATTORNEY_H_ */
|
Loading…
Reference in New Issue
Block a user