fsfw/storagemanager/StorageAccessor.h

50 lines
1.6 KiB
C
Raw Normal View History

2020-05-22 00:58:30 +02:00
#ifndef FRAMEWORK_STORAGEMANAGER_STORAGEACCESSOR_H_
#define FRAMEWORK_STORAGEMANAGER_STORAGEACCESSOR_H_
2020-05-12 14:11:00 +02:00
2020-06-23 10:58:48 +02:00
#include <framework/storagemanager/ConstStorageAccessor.h>
class StorageManagerIF;
2020-05-12 14:11:00 +02:00
/**
* @brief Child class for modifyable data. Also has a normal pointer member.
*/
class StorageAccessor: public ConstStorageAccessor {
//! StorageManager classes have exclusive access to private variables.
template<uint8_t NUMBER_OF_POOLS>
friend class PoolManager;
template<uint8_t NUMBER_OF_POOLS>
friend class LocalPool;
public:
StorageAccessor(store_address_t storeId);
2020-05-12 17:57:37 +02:00
StorageAccessor(store_address_t storeId, StorageManagerIF* store);
2020-05-12 14:11:00 +02:00
/**
* @brief Move ctor and move assignment allow returning accessors as
* a returnvalue. They prevent resource being free prematurely.
* Refer to: https://github.com/MicrosoftDocs/cpp-docs/blob/master/docs/cpp/
* move-constructors-and-move-assignment-operators-cpp.md
* @param
* @return
*/
2020-07-10 03:16:08 +02:00
<<<<<<< Updated upstream
2020-05-12 14:11:00 +02:00
StorageAccessor& operator= (StorageAccessor&&);
StorageAccessor (StorageAccessor&&);
2020-07-10 03:16:08 +02:00
=======
StorageAccessor& operator=(StorageAccessor&&);
StorageAccessor(StorageAccessor&&);
>>>>>>> Stashed changes
2020-05-12 14:11:00 +02:00
ReturnValue_t write(uint8_t *data, size_t size,
2020-05-12 19:02:59 +02:00
uint16_t offset = 0);
2020-05-12 14:11:00 +02:00
uint8_t* data();
2020-05-12 19:02:59 +02:00
ReturnValue_t getDataCopy(uint8_t *pointer, size_t maxSize) override;
2020-05-12 14:11:00 +02:00
private:
//! Non-const pointer for modifyable data.
uint8_t* dataPointer = nullptr;
//! For modifyable data, the const pointer is assigned to the normal
//! pointer by the pool manager so both access functions can be used safely
void assignConstPointer();
};
#endif /* TEST_PROTOTYPES_STORAGEACCESSOR_H_ */