From 1d28e1398ea927a74a0fc492e4db468122d41afa Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sun, 17 May 2020 23:41:28 +0200 Subject: [PATCH] DataSetBase class finished --- datapool/DataSetBase.cpp | 148 ++++++++++++++++++++++++ datapool/DataSetBase.h | 135 +++++++++++++++++++++ datapool/DataSetIF.h | 21 ++++ datapool/PIDReader.h | 2 +- datapool/PoolRawAccess.cpp | 2 +- datapool/PoolRawAccessHelper.cpp | 6 +- datapool/PoolRawAccessHelper.h | 1 + datapool/PoolVariableIF.h | 1 + datapoolglob/DataPoolAdmin.cpp | 4 +- datapoolglob/GlobalDataSet.cpp | 140 ++-------------------- datapoolglob/GlobalDataSet.h | 126 +++----------------- datapoolglob/GlobalPoolVariable.h | 2 +- devicehandlers/DeviceHandlerBase.cpp | 2 +- internalError/InternalErrorReporter.cpp | 2 +- power/Fuse.h | 1 + thermal/TemperatureSensor.h | 1 + 16 files changed, 344 insertions(+), 250 deletions(-) create mode 100644 datapool/DataSetBase.cpp create mode 100644 datapool/DataSetBase.h diff --git a/datapool/DataSetBase.cpp b/datapool/DataSetBase.cpp new file mode 100644 index 00000000..6ff2fc83 --- /dev/null +++ b/datapool/DataSetBase.cpp @@ -0,0 +1,148 @@ +#include +#include + +DataSetBase::DataSetBase() { + for (uint8_t count = 0; count < DATA_SET_MAX_SIZE; count++) { + registeredVariables[count] = nullptr; + } +} + +DataSetBase::~DataSetBase() {} + +ReturnValue_t DataSetBase::registerVariable( + PoolVariableIF *variable) { + if (state != States::DATA_SET_UNINITIALISED) { + sif::error << "DataSet::registerVariable: " + "Call made in wrong position." << std::endl; + return DataSetIF::DATA_SET_UNINITIALISED; + } + if (variable == nullptr) { + sif::error << "DataSet::registerVariable: " + "Pool variable is nullptr." << std::endl; + return DataSetIF::POOL_VAR_NULL; + } + if (fillCount >= DATA_SET_MAX_SIZE) { + sif::error << "DataSet::registerVariable: " + "DataSet is full." << std::endl; + return DataSetIF::DATA_SET_FULL; + } + registeredVariables[fillCount] = variable; + fillCount++; + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t DataSetBase::read() { + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + if (state == States::DATA_SET_UNINITIALISED) { + lockDataPool(); + for (uint16_t count = 0; count < fillCount; count++) { + if (registeredVariables[count]->getReadWriteMode() + != PoolVariableIF::VAR_WRITE + && registeredVariables[count]->getDataPoolId() + != PoolVariableIF::NO_PARAMETER) { + ReturnValue_t status = registeredVariables[count]->read(); + if (status != HasReturnvaluesIF::RETURN_OK) { + result = INVALID_PARAMETER_DEFINITION; + break; + } + } + } + state = States::DATA_SET_WAS_READ; + unlockDataPool(); + } + else { + sif::error << "DataSet::read(): " + "Call made in wrong position." << std::endl; + result = SET_WAS_ALREADY_READ; + } + return result; +} + +ReturnValue_t DataSetBase::commit() { + if (state == States::DATA_SET_WAS_READ) { + handleAlreadyReadDatasetCommit(); + return HasReturnvaluesIF::RETURN_OK; + } + else { + return handleUnreadDatasetCommit(); + } +} + +ReturnValue_t DataSetBase::lockDataPool() { + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t DataSetBase::unlockDataPool() { + return HasReturnvaluesIF::RETURN_FAILED; +} + +void DataSetBase::handleAlreadyReadDatasetCommit() { + lockDataPool(); + for (uint16_t count = 0; count < fillCount; count++) { + if (registeredVariables[count]->getReadWriteMode() + != PoolVariableIF::VAR_READ + && registeredVariables[count]->getDataPoolId() + != PoolVariableIF::NO_PARAMETER) { + registeredVariables[count]->commit(); + } + } + state = States::DATA_SET_UNINITIALISED; + unlockDataPool(); +} + +ReturnValue_t DataSetBase::handleUnreadDatasetCommit() { + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + lockDataPool(); + for (uint16_t count = 0; count < fillCount; count++) { + if (registeredVariables[count]->getReadWriteMode() + == PoolVariableIF::VAR_WRITE + && registeredVariables[count]->getDataPoolId() + != PoolVariableIF::NO_PARAMETER) { + registeredVariables[count]->commit(); + } else if (registeredVariables[count]->getDataPoolId() + != PoolVariableIF::NO_PARAMETER) { + if (result != COMMITING_WITHOUT_READING) { + sif::error << "DataSet::commit(): commit-without-read call made " + "with non write-only variable." << std::endl; + result = COMMITING_WITHOUT_READING; + } + } + } + state = States::DATA_SET_UNINITIALISED; + unlockDataPool(); + return result; +} + +ReturnValue_t DataSetBase::serialize(uint8_t** buffer, size_t* size, + const size_t maxSize, bool bigEndian) const { + ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED; + for (uint16_t count = 0; count < fillCount; count++) { + result = registeredVariables[count]->serialize(buffer, size, maxSize, + bigEndian); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + } + return result; +} + +ReturnValue_t DataSetBase::deSerialize(const uint8_t** buffer, size_t* size, + bool bigEndian) { + ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED; + for (uint16_t count = 0; count < fillCount; count++) { + result = registeredVariables[count]->deSerialize(buffer, size, + bigEndian); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + } + return result; +} + +size_t DataSetBase::getSerializedSize() const { + uint32_t size = 0; + for (uint16_t count = 0; count < fillCount; count++) { + size += registeredVariables[count]->getSerializedSize(); + } + return size; +} diff --git a/datapool/DataSetBase.h b/datapool/DataSetBase.h new file mode 100644 index 00000000..6b468c11 --- /dev/null +++ b/datapool/DataSetBase.h @@ -0,0 +1,135 @@ +#ifndef FRAMEWORK_DATAPOOL_DATASETBASE_H_ +#define FRAMEWORK_DATAPOOL_DATASETBASE_H_ +#include +#include + +/** + * @brief The DataSetBase class manages a set of locally checked out variables. + * @details + * This class manages a list, where a set of local variables (or pool variables) + * are registered. They are checked-out (i.e. their values are looked + * up and copied) with the read call. After the user finishes working with the + * pool variables, he can write back all variable values to the pool with + * the commit call. The data set manages locking and freeing the data pool, + * to ensure that all values are read and written back at once. + * + * An internal state manages usage of this class. Variables may only be + * registered before the read call is made, and the commit call only + * after the read call. + * + * If pool variables are writable and not committed until destruction + * of the set, the DataSet class automatically sets the valid flag in the + * data pool to invalid (without) changing the variable's value. + * + * The base class lockDataPo + * @author Bastian Baetz + * @ingroup data_pool + */ +class DataSetBase: public DataSetIF, + public SerializeIF, + public HasReturnvaluesIF { +public: + + /** + * @brief Creates an empty dataset. Use registerVariable or + * supply a pointer to this dataset to PoolVariable + * initializations to register pool variables. + */ + DataSetBase(); + virtual~ DataSetBase(); + + /** + * @brief The read call initializes reading out all registered variables. + * @details + * It iterates through the list of registered variables and calls all read() + * functions of the registered pool variables (which read out their values + * from the data pool) which are not write-only. + * In case of an error (e.g. a wrong data type, or an invalid data pool id), + * the operation is aborted and @c INVALID_PARAMETER_DEFINITION returned. + * + * The data pool is locked during the whole read operation and + * freed afterwards.The state changes to "was written" after this operation. + * @return - @c RETURN_OK if all variables were read successfully. + * - @c INVALID_PARAMETER_DEFINITION if PID, size or type of the + * requested variable is invalid. + * - @c SET_WAS_ALREADY_READ if read() is called twice without calling + * commit() in between + */ + virtual ReturnValue_t read(); + + /** + * @brief The commit call initializes writing back the registered variables. + * @details + * It iterates through the list of registered variables and calls the + * commit() method of the remaining registered variables (which write back + * their values to the pool). + * + * The data pool is locked during the whole commit operation and + * freed afterwards. The state changes to "was committed" after this operation. + * + * If the set does contain at least one variable which is not write-only commit() + * can only be called after read(). If the set only contains variables which are + * write only, commit() can be called without a preceding read() call. + * @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 + */ + virtual ReturnValue_t commit(); + + /* DataSetIF implementation */ + virtual ReturnValue_t registerVariable( PoolVariableIF* variable) override; + /** + * Provides the means to lock the underlying data structure to ensure + * thread-safety. Default implementation is empty + * @return Always returns -@c RETURN_OK + */ + virtual ReturnValue_t lockDataPool() override; + /** + * Provides the means to unlock the underlying data structure to ensure + * thread-safety. Default implementation is empty + * @return Always returns -@c RETURN_OK + */ + virtual ReturnValue_t unlockDataPool() override; + + /* SerializeIF implementations */ + ReturnValue_t serialize(uint8_t** buffer, size_t* size, + const size_t maxSize, bool bigEndian) const override; + virtual size_t getSerializedSize() const override; + virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, + bool bigEndian) override; + + //SHOULDDO we could use a linked list of datapool variables + //!< This definition sets the maximum number of variables to + //! register in one DataSet. + static const uint8_t DATA_SET_MAX_SIZE = 63; +protected: + + /** + * @brief The fill_count attribute ensures that the variables + * register in the correct array position and that the maximum + * number of variables is not exceeded. + */ + uint16_t fillCount = 0; + /** + * States of the seet. + */ + enum class States { + DATA_SET_UNINITIALISED, //!< DATA_SET_UNINITIALISED + DATA_SET_WAS_READ //!< DATA_SET_WAS_READ + }; + /** + * @brief state manages the internal state of the data set, + * which is important e.g. for the behavior on destruction. + */ + States state = States::DATA_SET_UNINITIALISED; + + /** + * @brief This array represents all pool variables registered in this set. + */ + PoolVariableIF* registeredVariables[DATA_SET_MAX_SIZE] = { }; + + void handleAlreadyReadDatasetCommit(); + ReturnValue_t handleUnreadDatasetCommit(); +}; + +#endif /* FRAMEWORK_DATAPOOL_DATASETBASE_H_ */ diff --git a/datapool/DataSetIF.h b/datapool/DataSetIF.h index 4e351416..d9cc4966 100644 --- a/datapool/DataSetIF.h +++ b/datapool/DataSetIF.h @@ -16,6 +16,17 @@ class PoolVariableIF; */ class DataSetIF { public: + static constexpr uint8_t INTERFACE_ID = CLASS_ID::DATA_SET_CLASS; + static constexpr ReturnValue_t INVALID_PARAMETER_DEFINITION = + MAKE_RETURN_CODE( 0x01 ); + static constexpr ReturnValue_t SET_WAS_ALREADY_READ = MAKE_RETURN_CODE( 0x02 ); + static constexpr ReturnValue_t COMMITING_WITHOUT_READING = + MAKE_RETURN_CODE(0x03); + + static constexpr ReturnValue_t DATA_SET_UNINITIALISED = MAKE_RETURN_CODE( 0x04 ); + static constexpr ReturnValue_t DATA_SET_FULL = MAKE_RETURN_CODE( 0x05 ); + static constexpr ReturnValue_t POOL_VAR_NULL = MAKE_RETURN_CODE( 0x06 ); + /** * @brief This is an empty virtual destructor, * as it is proposed for C++ interfaces. @@ -29,7 +40,17 @@ public: */ virtual ReturnValue_t registerVariable( PoolVariableIF* variable ) = 0; + /** + * @brief Most underlying data structures will have a pool like structure + * and will require a lock and unlock mechanism to ensure + * thread-safety + * @return Lock operation result + */ virtual ReturnValue_t lockDataPool() = 0; + /** + * @brief Unlock call corresponding to the lock call. + * @return Unlock operation result + */ virtual ReturnValue_t unlockDataPool() = 0; }; diff --git a/datapool/PIDReader.h b/datapool/PIDReader.h index f83fa3b9..11206611 100644 --- a/datapool/PIDReader.h +++ b/datapool/PIDReader.h @@ -1,9 +1,9 @@ #ifndef PIDREADER_H_ #define PIDREADER_H_ #include +#include #include #include -#include #include #include diff --git a/datapool/PoolRawAccess.cpp b/datapool/PoolRawAccess.cpp index aea84612..c0bd3c09 100644 --- a/datapool/PoolRawAccess.cpp +++ b/datapool/PoolRawAccess.cpp @@ -1,6 +1,6 @@ +#include #include #include -#include #include #include diff --git a/datapool/PoolRawAccessHelper.cpp b/datapool/PoolRawAccessHelper.cpp index cf02b20a..6e289303 100644 --- a/datapool/PoolRawAccessHelper.cpp +++ b/datapool/PoolRawAccessHelper.cpp @@ -6,10 +6,12 @@ */ #include +#include +#include +#include #include - -#include +#include PoolRawAccessHelper::PoolRawAccessHelper(uint32_t * poolIdBuffer_, uint8_t numberOfParameters_): diff --git a/datapool/PoolRawAccessHelper.h b/datapool/PoolRawAccessHelper.h index ab881a5f..f2434241 100644 --- a/datapool/PoolRawAccessHelper.h +++ b/datapool/PoolRawAccessHelper.h @@ -7,6 +7,7 @@ #ifndef FRAMEWORK_DATAPOOL_POOLRAWACCESSHELPER_H_ #define FRAMEWORK_DATAPOOL_POOLRAWACCESSHELPER_H_ +#include #include #include diff --git a/datapool/PoolVariableIF.h b/datapool/PoolVariableIF.h index 9935ef75..0cbc18c5 100644 --- a/datapool/PoolVariableIF.h +++ b/datapool/PoolVariableIF.h @@ -18,6 +18,7 @@ * @ingroup data_pool */ class PoolVariableIF : public SerializeIF { + friend class DataSetBase; friend class GlobDataSet; friend class LocalDataSet; protected: diff --git a/datapoolglob/DataPoolAdmin.cpp b/datapoolglob/DataPoolAdmin.cpp index 2779ce5c..f32ff567 100644 --- a/datapoolglob/DataPoolAdmin.cpp +++ b/datapoolglob/DataPoolAdmin.cpp @@ -1,5 +1,7 @@ -#include #include +#include +#include +#include #include #include #include diff --git a/datapoolglob/GlobalDataSet.cpp b/datapoolglob/GlobalDataSet.cpp index 6e09a398..503d068e 100644 --- a/datapoolglob/GlobalDataSet.cpp +++ b/datapoolglob/GlobalDataSet.cpp @@ -1,61 +1,12 @@ -#include #include +#include #include -GlobDataSet::GlobDataSet() : - fill_count(0), state(DATA_SET_UNINITIALISED) { - for (unsigned count = 0; count < DATA_SET_MAX_SIZE; count++) { - registeredVariables[count] = nullptr; - } -} +GlobDataSet::GlobDataSet(): DataSetBase() {} -GlobDataSet::~GlobDataSet() { - //Don't do anything with your variables, they are dead already! - // (Destructor is already called) -} - -ReturnValue_t GlobDataSet::registerVariable(PoolVariableIF* variable) { - if (state != DATA_SET_UNINITIALISED) { - sif::error << "DataSet::registerVariable: Call made in wrong position." << std::endl; - return DATA_SET_UNINITIALISED; - } - if (variable == nullptr) { - sif::error << "DataSet::registerVariable: Pool variable is nullptr." << std::endl; - return POOL_VAR_NULL; - } - if (fill_count >= DATA_SET_MAX_SIZE) { - sif::error << "DataSet::registerVariable: DataSet is full." << std::endl; - return DATA_SET_FULL; - } - registeredVariables[fill_count] = variable; - fill_count++; - return RETURN_OK; -} - -ReturnValue_t GlobDataSet::read() { - ReturnValue_t result = RETURN_OK; - if (state == DATA_SET_UNINITIALISED) { - lockDataPool(); - for (uint16_t count = 0; count < fill_count; count++) { - if (registeredVariables[count]->getReadWriteMode() - != PoolVariableIF::VAR_WRITE - && registeredVariables[count]->getDataPoolId() - != PoolVariableIF::NO_PARAMETER) { - ReturnValue_t status = registeredVariables[count]->read(); - if (status != RETURN_OK) { - result = INVALID_PARAMETER_DEFINITION; - break; - } - } - } - state = DATA_SET_WAS_READ; - unlockDataPool(); - } else { - sif::error << "DataSet::read(): Call made in wrong position." << std::endl; - result = SET_WAS_ALREADY_READ; - } - return result; -} +// Don't do anything with your variables, they are dead already! +// (Destructor is already called) +GlobDataSet::~GlobDataSet() {} ReturnValue_t GlobDataSet::commit(bool valid) { setEntriesValid(valid); @@ -64,50 +15,7 @@ ReturnValue_t GlobDataSet::commit(bool valid) { } ReturnValue_t GlobDataSet::commit() { - if (state == DATA_SET_WAS_READ) { - handleAlreadyReadDatasetCommit(); - return RETURN_OK; - } - else { - return handleUnreadDatasetCommit(); - } -} - -void GlobDataSet::handleAlreadyReadDatasetCommit() { - lockDataPool(); - for (uint16_t count = 0; count < fill_count; count++) { - if (registeredVariables[count]->getReadWriteMode() - != PoolVariableIF::VAR_READ - && registeredVariables[count]->getDataPoolId() - != PoolVariableIF::NO_PARAMETER) { - registeredVariables[count]->commit(); - } - } - state = DATA_SET_UNINITIALISED; - unlockDataPool(); -} - -ReturnValue_t GlobDataSet::handleUnreadDatasetCommit() { - ReturnValue_t result = RETURN_OK; - lockDataPool(); - for (uint16_t count = 0; count < fill_count; count++) { - if (registeredVariables[count]->getReadWriteMode() - == PoolVariableIF::VAR_WRITE - && registeredVariables[count]->getDataPoolId() - != PoolVariableIF::NO_PARAMETER) { - registeredVariables[count]->commit(); - } else if (registeredVariables[count]->getDataPoolId() - != PoolVariableIF::NO_PARAMETER) { - if (result != COMMITING_WITHOUT_READING) { - sif::error << "DataSet::commit(): commit-without-read call made " - "with non write-only variable." << std::endl; - result = COMMITING_WITHOUT_READING; - } - } - } - state = DATA_SET_UNINITIALISED; - unlockDataPool(); - return result; + return DataSetBase::commit(); } ReturnValue_t GlobDataSet::unlockDataPool() { @@ -118,29 +26,8 @@ ReturnValue_t GlobDataSet::lockDataPool() { return glob::dataPool.lockDataPool(); } -ReturnValue_t GlobDataSet::serialize(uint8_t** buffer, size_t* size, - const size_t max_size, bool bigEndian) const { - ReturnValue_t result = RETURN_FAILED; - for (uint16_t count = 0; count < fill_count; count++) { - result = registeredVariables[count]->serialize(buffer, size, max_size, - bigEndian); - if (result != RETURN_OK) { - return result; - } - } - return result; -} - -size_t GlobDataSet::getSerializedSize() const { - uint32_t size = 0; - for (uint16_t count = 0; count < fill_count; count++) { - size += registeredVariables[count]->getSerializedSize(); - } - return size; -} - void GlobDataSet::setEntriesValid(bool valid) { - for (uint16_t count = 0; count < fill_count; count++) { + for (uint16_t count = 0; count < fillCount; count++) { if (registeredVariables[count]->getReadWriteMode() != PoolVariableIF::VAR_READ) { registeredVariables[count]->setValid(valid); @@ -152,15 +39,4 @@ void GlobDataSet::setSetValid(bool valid) { this->valid = valid; } -ReturnValue_t GlobDataSet::deSerialize(const uint8_t** buffer, size_t* size, - bool bigEndian) { - ReturnValue_t result = RETURN_FAILED; - for (uint16_t count = 0; count < fill_count; count++) { - result = registeredVariables[count]->deSerialize(buffer, size, - bigEndian); - if (result != RETURN_OK) { - return result; - } - } - return result; -} + diff --git a/datapoolglob/GlobalDataSet.h b/datapoolglob/GlobalDataSet.h index 365de380..c2e0b577 100644 --- a/datapoolglob/GlobalDataSet.h +++ b/datapoolglob/GlobalDataSet.h @@ -1,63 +1,32 @@ #ifndef DATASET_H_ #define DATASET_H_ -#include -#include -#include +#include -#include /** * @brief The DataSet class manages a set of locally checked out variables * for the global data pool. - * * @details - * This class manages a list, where a set of local variables (or pool variables) - * are registered. They are checked-out (i.e. their values are looked - * up and copied) with the read call. After the user finishes working with the - * pool variables, he can write back all variable values to the pool with - * the commit call. The data set manages locking and freeing the data pool, - * to ensure that all values are read and written back at once. + * 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. * - * An internal state manages usage of this class. Variables may only be - * registered before the read call is made, and the commit call only - * after the read call. - * - * If pool variables are writable and not committed until destruction - * of the set, the DataSet class automatically sets the valid flag in the - * data pool to invalid (without) changing the variable's value. + * For more information on how this class works, see the DataSetBase + * documentation. * @author Bastian Baetz * @ingroup data_pool */ -class GlobDataSet: public DataSetIF, public HasReturnvaluesIF, public SerializeIF { +class GlobDataSet: public DataSetBase { public: - //SHOULDDO we could use a linked list of datapool variables - //!< This definition sets the maximum number of variables to - //! register in one DataSet. - static const uint8_t DATA_SET_MAX_SIZE = 63; - - static constexpr uint8_t INTERFACE_ID = CLASS_ID::DATA_SET_CLASS; - static constexpr ReturnValue_t INVALID_PARAMETER_DEFINITION = - MAKE_RETURN_CODE( 0x01 ); - static constexpr ReturnValue_t SET_WAS_ALREADY_READ = MAKE_RETURN_CODE( 0x02 ); - static constexpr ReturnValue_t COMMITING_WITHOUT_READING = - MAKE_RETURN_CODE(0x03); - - static constexpr ReturnValue_t DATA_SET_UNINITIALIZED = MAKE_RETURN_CODE( 0x04 ); - static constexpr ReturnValue_t DATA_SET_FULL = MAKE_RETURN_CODE( 0x05 ); - static constexpr ReturnValue_t POOL_VAR_NULL = MAKE_RETURN_CODE( 0x06 ); /** - * @brief The constructor simply sets the fill_count to zero and sets - * the state to "uninitialized". + * @brief Creates an empty GlobDataSet. Use registerVariable or + * supply a pointer to this dataset to PoolVariable + * initializations to register pool variables. */ GlobDataSet(); - /** - * @brief This operation is used to register the local variables in the set. - * @details It stores the pool variable pointer in a variable list. - */ - ReturnValue_t registerVariable(PoolVariableIF* variable) override; - /** * @brief The destructor automatically manages writing the valid * information of variables. @@ -67,42 +36,7 @@ public: * For each, the valid flag in the data pool is set to "invalid". */ ~GlobDataSet(); - /** - * @brief The read call initializes reading out all registered variables. - * @details - * It iterates through the list of registered variables and calls all read() - * functions of the registered pool variables (which read out their values - * from the data pool) which are not write-only. - * In case of an error (e.g. a wrong data type, or an invalid data pool id), - * the operation is aborted and @c INVALID_PARAMETER_DEFINITION returned. - * - * The data pool is locked during the whole read operation and - * freed afterwards.The state changes to "was written" after this operation. - * @return - @c RETURN_OK if all variables were read successfully. - * - @c INVALID_PARAMETER_DEFINITION if PID, size or type of the - * requested variable is invalid. - * - @c SET_WAS_ALREADY_READ if read() is called twice without calling - * commit() in between - */ - ReturnValue_t read(); - /** - * @brief The commit call initializes writing back the registered variables. - * @details - * It iterates through the list of registered variables and calls the - * commit() method of the remaining registered variables (which write back - * their values to the pool). - * - * The data pool is locked during the whole commit operation and - * freed afterwards. The state changes to "was committed" after this operation. - * - * If the set does contain at least one variable which is not write-only commit() - * can only be called after read(). If the set only contains variables which are - * write only, commit() can be called without a preceding read() call. - * @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(void); + /** * Variant of method above which sets validity of all elements of the set. * @param valid Validity information from PoolVariableIF. @@ -111,6 +45,7 @@ public: * contains non write-only variables */ ReturnValue_t commit(bool valid); + ReturnValue_t commit() override; /** * Set all entries @@ -126,45 +61,16 @@ public: */ void setEntriesValid(bool valid); - ReturnValue_t serialize(uint8_t** buffer, size_t* size, - const size_t max_size, bool bigEndian) const override; - - size_t getSerializedSize() const override; - - ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, - bool bigEndian) override; private: - - /** - * @brief This array represents all pool variables registered in this set. - */ - PoolVariableIF* registeredVariables[DATA_SET_MAX_SIZE]; - /** - * \brief The fill_count attribute ensures that the variables register in the correct array - * position and that the maximum number of variables is not exceeded. - */ - uint16_t fill_count; - /** - * States of the seet. - */ - enum States { - DATA_SET_UNINITIALISED, //!< DATA_SET_UNINITIALISED - DATA_SET_WAS_READ //!< DATA_SET_WAS_READ - }; - /** - * @brief state manages the internal state of the data set, - * which is important e.g. for the behavior on destruction. - */ - States state; - /** * If the valid state of a dataset is always relevant to the whole * data set we can use this flag. */ bool valid = false; + /** * @brief This is a small helper function to facilitate locking - * the underlying data data pool structure + * the global data pool. * @details * It makes use of the lockDataPool method offered by the DataPool class. */ @@ -172,7 +78,7 @@ private: /** * @brief This is a small helper function to facilitate - * unlocking the underlying data data pool structure + * unlocking the global data pool * @details * It makes use of the freeDataPoolLock method offered by the DataPool class. */ diff --git a/datapoolglob/GlobalPoolVariable.h b/datapoolglob/GlobalPoolVariable.h index eee9afc1..cfa28e11 100644 --- a/datapoolglob/GlobalPoolVariable.h +++ b/datapoolglob/GlobalPoolVariable.h @@ -2,9 +2,9 @@ #define GLOBALPOOLVARIABLE_H_ #include +#include #include #include -#include #include #include diff --git a/devicehandlers/DeviceHandlerBase.cpp b/devicehandlers/DeviceHandlerBase.cpp index f46f854b..8efc33d5 100644 --- a/devicehandlers/DeviceHandlerBase.cpp +++ b/devicehandlers/DeviceHandlerBase.cpp @@ -1,10 +1,10 @@ +#include #include #include #include #include #include -#include #include #include #include diff --git a/internalError/InternalErrorReporter.cpp b/internalError/InternalErrorReporter.cpp index a1e96695..30a02b44 100644 --- a/internalError/InternalErrorReporter.cpp +++ b/internalError/InternalErrorReporter.cpp @@ -1,6 +1,6 @@ +#include #include "InternalErrorReporter.h" -#include #include #include diff --git a/power/Fuse.h b/power/Fuse.h index a826a125..44f8964f 100644 --- a/power/Fuse.h +++ b/power/Fuse.h @@ -2,6 +2,7 @@ #define FUSE_H_ #include +#include #include #include #include diff --git a/thermal/TemperatureSensor.h b/thermal/TemperatureSensor.h index cd277784..27885b8b 100644 --- a/thermal/TemperatureSensor.h +++ b/thermal/TemperatureSensor.h @@ -3,6 +3,7 @@ #include #include +#include #include /**