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