fsfw/src/fsfw/tmtcpacket/RedirectableDataPointerIF.h

34 lines
1.2 KiB
C
Raw 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:
virtual ~RedirectableDataPointerIF(){};
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-15 20:28:16 +02:00
* - returnvalue::FAILED on general error of if the maximum size is too small
2022-02-02 10:29:30 +01:00
*/
virtual ReturnValue_t setData(uint8_t* dataPtr, size_t maxSize, void* args = nullptr) = 0;
2022-02-02 10:29:30 +01:00
private:
};
#endif /* FSFW_SRC_FSFW_TMTCPACKET_PUS_TC_SETTABLEDATAPOINTERIF_H_ */