From d99ed4715017fddab2c1f80610c9c72d3b428315 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sun, 8 Dec 2019 19:04:53 +0100 Subject: [PATCH] fixed map bugfix (fist instead of first), new access functions for fixed maP (first(), second()), some documentation, raw pool access read() call public because call is necessary before using public serialize function. maybe integrate read() call into serialize function? --- container/FixedMap.h | 13 +++++++++++-- datapool/PoolRawAccess.h | 22 ++++++++++++---------- parameters/HasParametersIF.h | 1 - serialize/SerialArrayListAdapter.h | 1 + serialize/SerialFixedArrayListAdapter.h | 2 ++ storagemanager/LocalPool.h | 25 +++++++++++++++++++++++++ 6 files changed, 51 insertions(+), 13 deletions(-) diff --git a/container/FixedMap.h b/container/FixedMap.h index 0b84bf4e..4e1dc629 100644 --- a/container/FixedMap.h +++ b/container/FixedMap.h @@ -6,7 +6,9 @@ #include /** - * \ingroup container + * @brief Implementation of a fixed map using an array list + * @details Initialize with desired fixed size + * @ingroup container */ template class FixedMap: public SerializeIF { @@ -56,6 +58,13 @@ public: return &ArrayList, uint32_t>::Iterator::value->second; } + key_t first() { + return ArrayList, uint32_t>::Iterator::value->first; + } + + T second() { + return ArrayList, uint32_t>::Iterator::value->second; + } }; Iterator begin() const { @@ -87,7 +96,7 @@ public: } ReturnValue_t insert(std::pair pair) { - return insert(pair.fist, pair.second); + return insert(pair.first, pair.second); } ReturnValue_t exists(key_t key) const { diff --git a/datapool/PoolRawAccess.h b/datapool/PoolRawAccess.h index 9a3000c0..8b81894a 100644 --- a/datapool/PoolRawAccess.h +++ b/datapool/PoolRawAccess.h @@ -31,7 +31,7 @@ private: */ Type type; /** - * \brief This value contains the size of the data pool entry in bytes. + * \brief This value contains the size of the data pool entry type in bytes. */ uint8_t typeSize; /** @@ -48,15 +48,7 @@ private: ReadWriteMode_t readWriteMode; static const uint8_t RAW_MAX_SIZE = sizeof(double); protected: - /** - * \brief This is a call to read the value from the global data pool. - * \details When executed, this operation tries to fetch the pool entry with matching - * data pool id from the global data pool and copies the value and the valid - * information to its local attributes. In case of a failure (wrong type or - * pool id not found), the variable is set to zero and invalid. - * The operation does NOT provide any mutual exclusive protection by itself. - */ - ReturnValue_t read(); + /** * \brief The commit call writes back the variable's value to the data pool. * \details It checks type and size, as well as if the variable is writable. If so, @@ -66,6 +58,7 @@ protected: */ ReturnValue_t commit(); public: + static const uint8_t INTERFACE_ID = CLASS_ID::POOL_RAW_ACCESS_CLASS; static const ReturnValue_t INCORRECT_SIZE = MAKE_RETURN_CODE(0x01); static const ReturnValue_t DATA_POOL_ACCESS_FAILED = MAKE_RETURN_CODE(0x02); @@ -78,6 +71,15 @@ public: * discarded and not written back to the data pool. */ ~PoolRawAccess(); + /** + * \brief This is a call to read the value from the global data pool. + * \details When executed, this operation tries to fetch the pool entry with matching + * data pool id from the global data pool and copies the value and the valid + * information to its local attributes. In case of a failure (wrong type or + * pool id not found), the variable is set to zero and invalid. + * The operation does NOT provide any mutual exclusive protection by itself. + */ + ReturnValue_t read(); /** * \brief This operation returns a pointer to the entry fetched. * \details Return pointer to the buffer containing the raw data diff --git a/parameters/HasParametersIF.h b/parameters/HasParametersIF.h index cd053fee..fbb69445 100644 --- a/parameters/HasParametersIF.h +++ b/parameters/HasParametersIF.h @@ -46,7 +46,6 @@ public: * @param startAtIndex * @return */ - // shouldnt startAtIndex be uint8? virtual ReturnValue_t getParameter(uint8_t domainId, uint16_t parameterId, ParameterWrapper *parameterWrapper, const ParameterWrapper *newValues, uint16_t startAtIndex) = 0; diff --git a/serialize/SerialArrayListAdapter.h b/serialize/SerialArrayListAdapter.h index 5ffbc375..7e2e527b 100644 --- a/serialize/SerialArrayListAdapter.h +++ b/serialize/SerialArrayListAdapter.h @@ -27,6 +27,7 @@ public: static ReturnValue_t serialize(const ArrayList* list, uint8_t** buffer, uint32_t* size, const uint32_t max_size, bool bigEndian) { + // Serialize length field first ReturnValue_t result = SerializeAdapter::serialize(&list->size, buffer, size, max_size, bigEndian); count_t i = 0; diff --git a/serialize/SerialFixedArrayListAdapter.h b/serialize/SerialFixedArrayListAdapter.h index 821e8710..18093e45 100644 --- a/serialize/SerialFixedArrayListAdapter.h +++ b/serialize/SerialFixedArrayListAdapter.h @@ -24,10 +24,12 @@ public: template SerialFixedArrayListAdapter(Args... args) : FixedArrayList(std::forward(args)...) { } + ReturnValue_t serialize(uint8_t** buffer, uint32_t* size, const uint32_t max_size, bool bigEndian) const { return SerialArrayListAdapter::serialize(this, buffer, size, max_size, bigEndian); } + uint32_t getSerializedSize() const { return SerialArrayListAdapter::getSerializedSize(this); } diff --git a/storagemanager/LocalPool.h b/storagemanager/LocalPool.h index 08cb017f..425ba005 100644 --- a/storagemanager/LocalPool.h +++ b/storagemanager/LocalPool.h @@ -159,6 +159,15 @@ public: * @brief In the LocalPool's destructor all allocated memory is freed. */ virtual ~LocalPool(void); + + /** + * Add data to local data pool, performs range check + * @param storageId [out] Store ID in which the data will be stored + * @param data + * @param size + * @param ignoreFault + * @return @c RETURN_OK if write was successful + */ ReturnValue_t addData(store_address_t* storageId, const uint8_t * data, uint32_t size, bool ignoreFault = false); @@ -171,8 +180,24 @@ public: */ ReturnValue_t getFreeElement(store_address_t* storageId, const uint32_t size, uint8_t** p_data, bool ignoreFault = false); + + /** + * Retrieve data from local pool + * @param packet_id + * @param packet_ptr + * @param size [out] Size of retrieved data + * @return @c RETURN_OK if data retrieval was successfull + */ ReturnValue_t getData(store_address_t packet_id, const uint8_t** packet_ptr, uint32_t* size); + + /** + * Modify data by supplying a previously obtaind packet pointer + * @param packet_id Store ID of data to modify + * @param packet_ptr + * @param size [out] size of changed data + * @return + */ ReturnValue_t modifyData(store_address_t packet_id, uint8_t** packet_ptr, uint32_t* size); virtual ReturnValue_t deleteData(store_address_t);