fsfw/src/fsfw/tmtcpacket/RedirectableDataPointerIF.h

37 lines
1.3 KiB
C
Raw Permalink Normal View History

#ifndef TMTCPACKET_PUS_TC_SETTABLEDATAPOINTERIF_H_
#define TMTCPACKET_PUS_TC_SETTABLEDATAPOINTERIF_H_
#include <cstddef>
2022-08-16 12:48:22 +02:00
#include "fsfw/returnvalues/returnvalue.h"
2022-02-02 10:29:30 +01:00
/**
* @brief This interface can be used for classes which store a reference to data. It allows
* the implementing class to redirect the data it refers too.
*/
class RedirectableDataPointerIF {
2022-02-02 10:29:30 +01:00
public:
2022-07-18 10:20:26 +02:00
virtual ~RedirectableDataPointerIF() = default;
2022-02-02 10:29:30 +01:00
/**
* Redirect the data pointer, but allow an implementation to change the data.
* The default implementation also sets a read-only pointer where applicable.
* @param dataPtr
* @param maxSize Maximum allowed size in buffer which holds the data. Can be used for size
* checks if a struct is cast directly onto the data pointer to ensure that the buffer is
* large enough
* @param args Any additional user arguments required to set the data pointer
* @return
2022-08-16 12:12:21 +02:00
* - returnvalue::OK if the pointer was set successfully
2022-08-16 01:08:26 +02:00
* - returnvalue::FAILED on general error of if the maximum size is too small
2022-02-02 10:29:30 +01:00
*/
2022-07-19 18:13:25 +02:00
virtual ReturnValue_t setData(uint8_t* dataPtr, size_t size, void* args) = 0;
virtual ReturnValue_t setData(uint8_t* dataPtr, size_t size) {
return setData(dataPtr, size, nullptr);
2022-07-18 10:20:26 +02:00
}
2022-02-02 10:29:30 +01:00
private:
};
2022-07-18 10:20:26 +02:00
#endif /* TMTCPACKET_PUS_TC_SETTABLEDATAPOINTERIF_H_ */