Storage: make storage class virtual with default implementations.

This commit is contained in:
Martin Preuss
2024-02-11 20:07:30 +01:00
parent b6fe1775bd
commit 5888bc9068
3 changed files with 184 additions and 34 deletions

View File

@@ -12,6 +12,8 @@
#include <aqhome/api.h>
#include <gwenhywfar/inherit.h>
#ifdef __cplusplus
@@ -20,6 +22,8 @@ extern "C" {
typedef struct AQH_STORAGE AQH_STORAGE;
GWEN_INHERIT_FUNCTION_LIB_DEFS(AQH_STORAGE, AQHOME_API)
#ifdef __cplusplus
@@ -40,6 +44,17 @@ typedef struct AQH_STORAGE AQH_STORAGE;
extern "C" {
#endif
typedef int (*AQH_STORAGE_INIT_FN)(AQH_STORAGE *sto);
typedef int (*AQH_STORAGE_FINI_FN)(AQH_STORAGE *sto);
typedef int (*AQH_STORAGE_ADDDATAPOINT_FN)(AQH_STORAGE *sto, uint64_t valueId, uint64_t timestamp, double dataPoint);
typedef uint64_t *(*AQH_STORAGE_GETDATAPOINTS_FN)(AQH_STORAGE *sto, uint64_t valueId,
uint64_t fromTime, uint64_t toTime,
uint64_t maxArrayLen);
typedef int (*AQH_STORAGE_GETFIRSTDATAPOINT_FN)(AQH_STORAGE *sto, uint64_t valueId, uint64_t *pTimestamp, double *pValue);
typedef int (*AQH_STORAGE_GETLASTDATAPOINT_FN)(AQH_STORAGE *sto, uint64_t valueId, uint64_t *pTimestamp, double *pValue);
typedef uint64_t *(*AQH_STORAGE_GETLASTNDATAPOINTS_FN)(AQH_STORAGE *sto, uint64_t valueId, uint64_t maxDataPointsRequested);
/**
@@ -74,14 +89,23 @@ AQHOME_API int AQH_Storage_Fini(AQH_STORAGE *sto);
AQHOME_API int AQH_Storage_WriteState(AQH_STORAGE *sto);
AQHOME_API int AQH_Storage_AddDatapoint(AQH_STORAGE *sto, uint64_t valueId, uint64_t timestamp, double dataPoint);
AQHOME_API uint64_t *AQH_Storage_GetDataPoints(AQH_STORAGE *sto, uint64_t valueId,
uint64_t fromTime, uint64_t toTime,
uint64_t maxArrayLen);
AQHOME_API int AQH_Storage_GetFirstDataPoint(AQH_STORAGE *sto, uint64_t valueId, uint64_t *pTimestamp, double *pValue);
AQHOME_API int AQH_Storage_GetLastDataPoint(AQH_STORAGE *sto, uint64_t valueId, uint64_t *pTimestamp, double *pValue);
AQHOME_API uint64_t *AQH_Storage_GetLastNDataPoints(AQH_STORAGE *sto, uint64_t valueId, uint64_t maxDataPointsRequested);
AQHOME_API AQH_STORAGE_INIT_FN AQH_Storage_SetInitFn(AQH_STORAGE *sto, AQH_STORAGE_INIT_FN fn);
AQHOME_API AQH_STORAGE_FINI_FN AQH_Storage_SetFiniFn(AQH_STORAGE *sto, AQH_STORAGE_FINI_FN fn);
AQHOME_API AQH_STORAGE_ADDDATAPOINT_FN AQH_Storage_SetAddDatapointFn(AQH_STORAGE *sto, AQH_STORAGE_ADDDATAPOINT_FN fn);
AQHOME_API AQH_STORAGE_GETDATAPOINTS_FN AQH_Storage_SetGetDatapointsFn(AQH_STORAGE *sto, AQH_STORAGE_GETDATAPOINTS_FN fn);
AQHOME_API AQH_STORAGE_GETFIRSTDATAPOINT_FN AQH_Storage_SetGetFirstDatapointFn(AQH_STORAGE *sto, AQH_STORAGE_GETFIRSTDATAPOINT_FN fn);
AQHOME_API AQH_STORAGE_GETLASTDATAPOINT_FN AQH_Storage_SetGetLastDatapointFn(AQH_STORAGE *sto, AQH_STORAGE_GETLASTDATAPOINT_FN fn);
AQHOME_API AQH_STORAGE_GETLASTNDATAPOINTS_FN AQH_Storage_SetGetLastNDatapointsFn(AQH_STORAGE *sto, AQH_STORAGE_GETLASTNDATAPOINTS_FN fn);
#ifdef __cplusplus