summaryrefslogtreecommitdiff
path: root/src/pke-at-storage-interface.hpp
blob: 5cbe5a73d8c9910d36dc4af56c0f407d75ea7b47 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#ifndef PKE_AT_PKE_AT_STORAGE_INTERFACE_HPP
#define PKE_AT_PKE_AT_STORAGE_INTERFACE_HPP

#include "pke-at-setlist-types.hpp"

#include <pke/pke.hpp>

enum pke_at_storage_interface_result_code {
	pke_at_storage_interface_result_code_none    = 0,
	pke_at_storage_interface_result_code_success = 1,
	pke_at_storage_interface_result_code_err     = 2,
};

struct pke_at_storage_interface_response {
	enum pke_at_storage_interface_result_code result_code;
};

template <typename T>
struct pke_at_storage_interface_response_t {
	enum pke_at_storage_interface_result_code result_code;
	T *value;
};

/* 2025-10-09 JCB Why do you do this to yourself */

#define PASI(type,func) pke_at_storage_interface_##type##_##func

#define PASIR_DEL(type) pke_at_storage_interface_response PASI(type,delete)(pk_uuid uuid)
#define PASIR_GET(type,T) pke_at_storage_interface_response_t<T> PASI(type,get)(pk_uuid uuid)
#define PASIR_UPS(type,T) pke_at_storage_interface_response PASI(type,upsert)(const T &val)
#define PASIRA_DEL(type,...) pke_at_storage_interface_response PASI(type,delete)(__VA_ARGS__)
#define PASIRA_GET(type,T,...) pke_at_storage_interface_response_t<T> PASI(type,get)(__VA_ARGS__)

struct pke_at_storage_interface {
	pke_at_storage_interface() = default;
	virtual ~pke_at_storage_interface() = default;
	virtual void init() const = 0;
	virtual void teardown() const = 0;
	virtual PASIR_DEL(section) const = 0;
	virtual PASIR_GET(section, pke_at_section_details) const = 0;
	virtual PASIR_UPS(section, pke_at_section_details) const = 0;
	virtual PASIR_DEL(setlist) const = 0;
	virtual PASIR_GET(setlist, pke_at_setlist_details) const = 0;
	virtual PASIR_UPS(setlist, pke_at_setlist_details) const = 0;
	virtual PASIRA_DEL(setlist_song, pk_uuid setlist_uuid, pk_uuid song_uuid) const = 0;
	virtual PASIRA_GET(setlist_song, pke_at_setlist_song_details, pk_uuid setlist_uuid, pk_uuid song_uuid) const = 0;
	virtual PASIR_UPS(setlist_song, pke_at_setlist_song_details) const = 0;
	virtual PASIR_DEL(song) const = 0;
	virtual PASIR_GET(song, pke_at_song_details) const = 0;
	virtual PASIR_UPS(song, pke_at_song_details) const = 0;
};

#endif /* PKE_AT_PKE_AT_STORAGE_INTERFACE_HPP */