CX Framework
Cross-platform C utility framework
Loading...
Searching...
No Matches
ssdnode.h
1#pragma once
2// This header file is auto-generated!
3// Do not make changes to this file or they will be overwritten.
4// clang-format off
5#include <cx/obj.h>
6#include <cx/struct.h>
7#include <cx/ssdtree/ssdtreeobj.h>
8#include <cx/stype/stvar.h>
9
10CX_C_BEGIN
11
12typedef struct SSDIterator SSDIterator;
13typedef struct SSDIterator_WeakRef SSDIterator_WeakRef;
14typedef struct SSDNode SSDNode;
15typedef struct SSDNode_WeakRef SSDNode_WeakRef;
16saDeclarePtr(SSDIterator);
17saDeclarePtr(SSDIterator_WeakRef);
18#define _sti_SSDIterator _sti_object
19#define SType_SSDIterator SSDIterator*
20#define STStorageType_SSDIterator SSDIterator*
21#define STypeArg_SSDIterator(type, val) stgeneric(object, (ObjInst*)objInstCheckClass(SSDIterator, val))
22#define STypeArgPtr_SSDIterator(type, val) (stgeneric*)objInstCheckClassPtr(SSDIterator, val)
23#define STypeCheckedArg_SSDIterator(type, val) stType(type), stArg(type, val)
24#define STypeCheckedPtrArg_SSDIterator(type, val) stType(type), stArgPtr(type, val)
25saDeclarePtr(SSDNode);
26saDeclarePtr(SSDNode_WeakRef);
27#define _sti_SSDNode _sti_object
28#define SType_SSDNode SSDNode*
29#define STStorageType_SSDNode SSDNode*
30#define STypeArg_SSDNode(type, val) stgeneric(object, (ObjInst*)objInstCheckClass(SSDNode, val))
31#define STypeArgPtr_SSDNode(type, val) (stgeneric*)objInstCheckClassPtr(SSDNode, val)
32#define STypeCheckedArg_SSDNode(type, val) stType(type), stArg(type, val)
33#define STypeCheckedPtrArg_SSDNode(type, val) stType(type), stArgPtr(type, val)
34
35enum SSD_INDEX_MARKER {
36 SSD_ByName = -1 // Pass as index to address a child by name
37};
38
39#define ssditeratorObj(self, clsname) objDynCast(clsname, ssditeratorObjInst(self))
40#define ssdnodeIterLocked(self) ssdnode_iterLocked(self, _ssdCurrentLockState)
41
42typedef struct SSDIteratorIf {
43 ObjIface* _implements;
44 ObjIface* _parent;
45 size_t _size;
46
47 bool (*valid)(_In_ void* self);
48 bool (*next)(_In_ void* self);
49 bool (*get)(_In_ void* self, stvar* out);
50 stvar* (*ptr)(_In_ void* self);
51 strref (*name)(_In_ void* self);
52 int32 (*idx)(_In_ void* self);
53 bool (*iterOut)(_In_ void* self, _When_(return == true, _Out_) int32* idx, _When_(return == true, _Out_) strref* name, _When_(return == true, _Out_) stvar** val);
54} SSDIteratorIf;
55extern SSDIteratorIf SSDIteratorIf_tmpl;
56
57typedef struct SSDNodeIf {
58 ObjIface* _implements;
59 ObjIface* _parent;
60 size_t _size;
61
62 // Gets a value. Caller owns the value and must destroy it with stDestroy!
63 bool (*get)(_In_ void* self, int32 idx, _In_opt_ strref name, _When_(return == true, _Out_) stvar* out, _Inout_ SSDLockState* _ssdCurrentLockState);
64 // Gets a pointer to a value. This points to the internal storage within the node
65 // so it is only guaranteed to be valid while the read lock is held.
66 _Ret_opt_valid_ stvar* (*ptr)(_In_ void* self, int32 idx, _In_opt_ strref name, _Inout_ SSDLockState* _ssdCurrentLockState);
67 // Sets the given value
68 bool (*set)(_In_ void* self, int32 idx, _In_opt_ strref name, stvar val, _Inout_ SSDLockState* _ssdCurrentLockState);
69 // Same as setValue but consumes the value
70 // (consumes even on failure)
71 bool (*setC)(_In_ void* self, int32 idx, _In_opt_ strref name, _Inout_ stvar* val, _Inout_ SSDLockState* _ssdCurrentLockState);
72 // Removes a value
73 bool (*remove)(_In_ void* self, int32 idx, _In_opt_ strref name, _Inout_ SSDLockState* _ssdCurrentLockState);
74 // How many values / objects does this node contain?
75 int32 (*count)(_In_ void* self, _Inout_ SSDLockState* _ssdCurrentLockState);
76 // IMPORTANT NOTE: The generic object iterator interface cannot take any parameters;
77 // thus it always acquires a transient read lock and holds it until the iterator is
78 // destroyed. The caller MUST NOT already have an SSDLock held.
79 // If you want to use iterators inside a larger locked transaction or modify the tree,
80 // use iterLocked() instead.
81 _Ret_valid_ SSDIterator* (*iter)(_In_ void* self);
82 SSDIterator* (*_iterLocked)(_In_ void* self, _Inout_ SSDLockState* _ssdCurrentLockState);
83} SSDNodeIf;
84extern SSDNodeIf SSDNodeIf_tmpl;
85
86typedef struct SSDIterator_ClassIf {
87 ObjIface* _implements;
88 ObjIface* _parent;
89 size_t _size;
90
91 bool (*isHashtable)(_In_ void* self);
92 bool (*isArray)(_In_ void* self);
93 bool (*valid)(_In_ void* self);
94 bool (*next)(_In_ void* self);
95 bool (*get)(_In_ void* self, stvar* out);
96 stvar* (*ptr)(_In_ void* self);
97 strref (*name)(_In_ void* self);
98 int32 (*idx)(_In_ void* self);
99 bool (*iterOut)(_In_ void* self, _When_(return == true, _Out_) int32* idx, _When_(return == true, _Out_) strref* name, _When_(return == true, _Out_) stvar** val);
100} SSDIterator_ClassIf;
101extern SSDIterator_ClassIf SSDIterator_ClassIf_tmpl;
102
103typedef struct SSDNode_ClassIf {
104 ObjIface* _implements;
105 ObjIface* _parent;
106 size_t _size;
107
108 // This node is an object that contains values or objects by name
109 bool (*isHashtable)(_In_ void* self);
110 // This node is an array that contains values or objects by array index
111 bool (*isArray)(_In_ void* self);
112 // Gets a value. Caller owns the value and must destroy it with stDestroy!
113 bool (*get)(_In_ void* self, int32 idx, _In_opt_ strref name, _When_(return == true, _Out_) stvar* out, _Inout_ SSDLockState* _ssdCurrentLockState);
114 // Gets a pointer to a value. This points to the internal storage within the node
115 // so it is only guaranteed to be valid while the read lock is held.
116 _Ret_opt_valid_ stvar* (*ptr)(_In_ void* self, int32 idx, _In_opt_ strref name, _Inout_ SSDLockState* _ssdCurrentLockState);
117 // Sets the given value
118 bool (*set)(_In_ void* self, int32 idx, _In_opt_ strref name, stvar val, _Inout_ SSDLockState* _ssdCurrentLockState);
119 // Same as setValue but consumes the value
120 // (consumes even on failure)
121 bool (*setC)(_In_ void* self, int32 idx, _In_opt_ strref name, _Inout_ stvar* val, _Inout_ SSDLockState* _ssdCurrentLockState);
122 // Removes a value
123 bool (*remove)(_In_ void* self, int32 idx, _In_opt_ strref name, _Inout_ SSDLockState* _ssdCurrentLockState);
124 // How many values / objects does this node contain?
125 int32 (*count)(_In_ void* self, _Inout_ SSDLockState* _ssdCurrentLockState);
126 // IMPORTANT NOTE: The generic object iterator interface cannot take any parameters;
127 // thus it always acquires a transient read lock and holds it until the iterator is
128 // destroyed. The caller MUST NOT already have an SSDLock held.
129 // If you want to use iterators inside a larger locked transaction or modify the tree,
130 // use iterLocked() instead.
131 _Ret_valid_ SSDIterator* (*iter)(_In_ void* self);
132 SSDIterator* (*_iterLocked)(_In_ void* self, _Inout_ SSDLockState* _ssdCurrentLockState);
133} SSDNode_ClassIf;
134extern SSDNode_ClassIf SSDNode_ClassIf_tmpl;
135
136typedef struct SSDIterator {
137 union {
138 SSDIterator_ClassIf* _;
139 void* _is_SSDIterator;
140 void* _is_ObjInst;
141 };
142 ObjClassInfo* _clsinfo;
143 atomic(uintptr) _ref;
144 atomic(ptr) _weakref;
145
146 SSDNode* node;
147 SSDLockState* lstate;
148 SSDLockState transient_lock_state;
149} SSDIterator;
150extern ObjClassInfo SSDIterator_clsinfo;
151#define SSDIterator(inst) objInstCheckClass(SSDIterator, inst)
152#define SSDIteratorNone ((SSDIterator*)NULL)
153
154typedef struct SSDIterator_WeakRef {
155 union {
156 ObjInst* _inst;
157 void* _is_SSDIterator_WeakRef;
158 void* _is_ObjInst_WeakRef;
159 };
160 atomic(uintptr) _ref;
161 RWLock _lock;
162} SSDIterator_WeakRef;
163#define SSDIterator_WeakRef(inst) objWeakRefCheckClass(SSDIterator, inst)
164
165_Ret_opt_valid_ ObjInst* SSDIterator_objInst(_In_ SSDIterator* self);
166// ObjInst* ssditeratorObjInst(SSDIterator* self);
167#define ssditeratorObjInst(self) SSDIterator_objInst(SSDIterator(self))
168
169// bool ssditeratorIsHashtable(SSDIterator* self);
170#define ssditeratorIsHashtable(self) (self)->_->isHashtable(SSDIterator(self))
171// bool ssditeratorIsArray(SSDIterator* self);
172#define ssditeratorIsArray(self) (self)->_->isArray(SSDIterator(self))
173// bool ssditeratorValid(SSDIterator* self);
174#define ssditeratorValid(self) (self)->_->valid(SSDIterator(self))
175// bool ssditeratorNext(SSDIterator* self);
176#define ssditeratorNext(self) (self)->_->next(SSDIterator(self))
177// bool ssditeratorGet(SSDIterator* self, stvar* out);
178#define ssditeratorGet(self, out) (self)->_->get(SSDIterator(self), out)
179// stvar* ssditeratorPtr(SSDIterator* self);
180#define ssditeratorPtr(self) (self)->_->ptr(SSDIterator(self))
181// strref ssditeratorName(SSDIterator* self);
182#define ssditeratorName(self) (self)->_->name(SSDIterator(self))
183// int32 ssditeratorIdx(SSDIterator* self);
184#define ssditeratorIdx(self) (self)->_->idx(SSDIterator(self))
185// bool ssditeratorIterOut(SSDIterator* self, int32* idx, strref* name, stvar** val);
186#define ssditeratorIterOut(self, idx, name, val) (self)->_->iterOut(SSDIterator(self), idx, name, val)
187
188typedef struct SSDNode {
189 union {
190 SSDNode_ClassIf* _;
191 void* _is_SSDNode;
192 void* _is_ObjInst;
193 };
194 ObjClassInfo* _clsinfo;
195 atomic(uintptr) _ref;
196 atomic(ptr) _weakref;
197
198 SSDTree* tree;
199 int64 modified; // The timestamp this node was last modified
200} SSDNode;
201extern ObjClassInfo SSDNode_clsinfo;
202#define SSDNode(inst) objInstCheckClass(SSDNode, inst)
203#define SSDNodeNone ((SSDNode*)NULL)
204
205typedef struct SSDNode_WeakRef {
206 union {
207 ObjInst* _inst;
208 void* _is_SSDNode_WeakRef;
209 void* _is_ObjInst_WeakRef;
210 };
211 atomic(uintptr) _ref;
212 RWLock _lock;
213} SSDNode_WeakRef;
214#define SSDNode_WeakRef(inst) objWeakRefCheckClass(SSDNode, inst)
215
216void SSDNode_updateModified(_In_ SSDNode* self);
217// void ssdnodeUpdateModified(SSDNode* self);
218#define ssdnodeUpdateModified(self) SSDNode_updateModified(SSDNode(self))
219
220// bool ssdnodeIsHashtable(SSDNode* self);
221//
222// This node is an object that contains values or objects by name
223#define ssdnodeIsHashtable(self) (self)->_->isHashtable(SSDNode(self))
224// bool ssdnodeIsArray(SSDNode* self);
225//
226// This node is an array that contains values or objects by array index
227#define ssdnodeIsArray(self) (self)->_->isArray(SSDNode(self))
228// bool ssdnodeGet(SSDNode* self, int32 idx, strref name, stvar* out, SSDLockState* _ssdCurrentLockState);
229//
230// Gets a value. Caller owns the value and must destroy it with stDestroy!
231#define ssdnodeGet(self, idx, name, out, _ssdCurrentLockState) (self)->_->get(SSDNode(self), idx, name, out, _ssdCurrentLockState)
232// stvar* ssdnodePtr(SSDNode* self, int32 idx, strref name, SSDLockState* _ssdCurrentLockState);
233//
234// Gets a pointer to a value. This points to the internal storage within the node
235// so it is only guaranteed to be valid while the read lock is held.
236#define ssdnodePtr(self, idx, name, _ssdCurrentLockState) (self)->_->ptr(SSDNode(self), idx, name, _ssdCurrentLockState)
237// bool ssdnodeSet(SSDNode* self, int32 idx, strref name, stvar val, SSDLockState* _ssdCurrentLockState);
238//
239// Sets the given value
240#define ssdnodeSet(self, idx, name, val, _ssdCurrentLockState) (self)->_->set(SSDNode(self), idx, name, val, _ssdCurrentLockState)
241// bool ssdnodeSetC(SSDNode* self, int32 idx, strref name, stvar* val, SSDLockState* _ssdCurrentLockState);
242//
243// Same as setValue but consumes the value
244// (consumes even on failure)
245#define ssdnodeSetC(self, idx, name, val, _ssdCurrentLockState) (self)->_->setC(SSDNode(self), idx, name, val, _ssdCurrentLockState)
246// bool ssdnodeRemove(SSDNode* self, int32 idx, strref name, SSDLockState* _ssdCurrentLockState);
247//
248// Removes a value
249#define ssdnodeRemove(self, idx, name, _ssdCurrentLockState) (self)->_->remove(SSDNode(self), idx, name, _ssdCurrentLockState)
250// int32 ssdnodeCount(SSDNode* self, SSDLockState* _ssdCurrentLockState);
251//
252// How many values / objects does this node contain?
253#define ssdnodeCount(self, _ssdCurrentLockState) (self)->_->count(SSDNode(self), _ssdCurrentLockState)
254// SSDIterator* ssdnodeIter(SSDNode* self);
255//
256// IMPORTANT NOTE: The generic object iterator interface cannot take any parameters;
257// thus it always acquires a transient read lock and holds it until the iterator is
258// destroyed. The caller MUST NOT already have an SSDLock held.
259// If you want to use iterators inside a larger locked transaction or modify the tree,
260// use iterLocked() instead.
261#define ssdnodeIter(self) (self)->_->iter(SSDNode(self))
262// SSDIterator* ssdnode_iterLocked(SSDNode* self, SSDLockState* _ssdCurrentLockState);
263#define ssdnode_iterLocked(self, _ssdCurrentLockState) (self)->_->_iterLocked(SSDNode(self), _ssdCurrentLockState)
264
265CX_C_END
#define saDeclarePtr(name)
Definition sarray.h:100
#define stvar(typen, val)
Definition stvar.h:162
CX Struct System - Introspectable, serializable POD structures in C.
CX Object System - Object-oriented programming in C.
Variant type containers and type-safe variadic argument support.