CX Framework
Cross-platform C utility framework
Loading...
Searching...
No Matches
ssdhashnode.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/node/ssdnode.h>
8
9CX_C_BEGIN
10
11typedef struct SSDHashNode SSDHashNode;
12typedef struct SSDHashNode_WeakRef SSDHashNode_WeakRef;
13typedef struct SSDHashIter SSDHashIter;
14typedef struct SSDHashIter_WeakRef SSDHashIter_WeakRef;
15saDeclarePtr(SSDHashNode);
16saDeclarePtr(SSDHashNode_WeakRef);
17#define _sti_SSDHashNode _sti_object
18#define SType_SSDHashNode SSDHashNode*
19#define STStorageType_SSDHashNode SSDHashNode*
20#define STypeArg_SSDHashNode(type, val) stgeneric(object, (ObjInst*)objInstCheckClass(SSDHashNode, val))
21#define STypeArgPtr_SSDHashNode(type, val) (stgeneric*)objInstCheckClassPtr(SSDHashNode, val)
22#define STypeCheckedArg_SSDHashNode(type, val) stType(type), stArg(type, val)
23#define STypeCheckedPtrArg_SSDHashNode(type, val) stType(type), stArgPtr(type, val)
24saDeclarePtr(SSDHashIter);
25saDeclarePtr(SSDHashIter_WeakRef);
26#define _sti_SSDHashIter _sti_object
27#define SType_SSDHashIter SSDHashIter*
28#define STStorageType_SSDHashIter SSDHashIter*
29#define STypeArg_SSDHashIter(type, val) stgeneric(object, (ObjInst*)objInstCheckClass(SSDHashIter, val))
30#define STypeArgPtr_SSDHashIter(type, val) (stgeneric*)objInstCheckClassPtr(SSDHashIter, val)
31#define STypeCheckedArg_SSDHashIter(type, val) stType(type), stArg(type, val)
32#define STypeCheckedPtrArg_SSDHashIter(type, val) stType(type), stArgPtr(type, val)
33
34typedef struct SSDHashNode_ClassIf {
35 ObjIface* _implements;
36 ObjIface* _parent;
37 size_t _size;
38
39 // This node is an object that contains values or objects by name
40 bool (*isHashtable)(_In_ void* self);
41 // This node is an array that contains values or objects by array index
42 bool (*isArray)(_In_ void* self);
43 // Gets a value. Caller owns the value and must destroy it with stDestroy!
44 bool (*get)(_In_ void* self, int32 idx, _In_opt_ strref name, _When_(return == true, _Out_) stvar* out, _Inout_ SSDLockState* _ssdCurrentLockState);
45 // Gets a pointer to a value. This points to the internal storage within the node
46 // so it is only guaranteed to be valid while the read lock is held.
47 _Ret_opt_valid_ stvar* (*ptr)(_In_ void* self, int32 idx, _In_opt_ strref name, _Inout_ SSDLockState* _ssdCurrentLockState);
48 // Sets the given value
49 bool (*set)(_In_ void* self, int32 idx, _In_opt_ strref name, stvar val, _Inout_ SSDLockState* _ssdCurrentLockState);
50 // Same as setValue but consumes the value
51 // (consumes even on failure)
52 bool (*setC)(_In_ void* self, int32 idx, _In_opt_ strref name, _Inout_ stvar* val, _Inout_ SSDLockState* _ssdCurrentLockState);
53 // Removes a value
54 bool (*remove)(_In_ void* self, int32 idx, _In_opt_ strref name, _Inout_ SSDLockState* _ssdCurrentLockState);
55 // How many values / objects does this node contain?
56 int32 (*count)(_In_ void* self, _Inout_ SSDLockState* _ssdCurrentLockState);
57 // IMPORTANT NOTE: The generic object iterator interface cannot take any parameters;
58 // thus it always acquires a transient read lock and holds it until the iterator is
59 // destroyed. The caller MUST NOT already have an SSDLock held.
60 // If you want to use iterators inside a larger locked transaction or modify the tree,
61 // use iterLocked() instead.
62 _Ret_valid_ SSDIterator* (*iter)(_In_ void* self);
63 SSDIterator* (*_iterLocked)(_In_ void* self, _Inout_ SSDLockState* _ssdCurrentLockState);
64} SSDHashNode_ClassIf;
65extern SSDHashNode_ClassIf SSDHashNode_ClassIf_tmpl;
66
67typedef struct SSDHashIter_ClassIf {
68 ObjIface* _implements;
69 ObjIface* _parent;
70 size_t _size;
71
72 bool (*isHashtable)(_In_ void* self);
73 bool (*isArray)(_In_ void* self);
74 bool (*valid)(_In_ void* self);
75 bool (*next)(_In_ void* self);
76 bool (*get)(_In_ void* self, stvar* out);
77 stvar* (*ptr)(_In_ void* self);
78 strref (*name)(_In_ void* self);
79 int32 (*idx)(_In_ void* self);
80 bool (*iterOut)(_In_ void* self, _When_(return == true, _Out_) int32* idx, _When_(return == true, _Out_) strref* name, _When_(return == true, _Out_) stvar** val);
81} SSDHashIter_ClassIf;
82extern SSDHashIter_ClassIf SSDHashIter_ClassIf_tmpl;
83
84typedef struct SSDHashNode {
85 union {
86 SSDHashNode_ClassIf* _;
87 void* _is_SSDHashNode;
88 void* _is_SSDNode;
89 void* _is_ObjInst;
90 };
91 ObjClassInfo* _clsinfo;
92 atomic(uintptr) _ref;
93 atomic(ptr) _weakref;
94
95 SSDTree* tree;
96 int64 modified; // The timestamp this node was last modified
97 hashtable storage;
98} SSDHashNode;
99extern ObjClassInfo SSDHashNode_clsinfo;
100#define SSDHashNode(inst) objInstCheckClass(SSDHashNode, inst)
101#define SSDHashNodeNone ((SSDHashNode*)NULL)
102
103typedef struct SSDHashNode_WeakRef {
104 union {
105 ObjInst* _inst;
106 void* _is_SSDHashNode_WeakRef;
107 void* _is_SSDNode_WeakRef;
108 void* _is_ObjInst_WeakRef;
109 };
110 atomic(uintptr) _ref;
111 RWLock _lock;
112} SSDHashNode_WeakRef;
113#define SSDHashNode_WeakRef(inst) objWeakRefCheckClass(SSDHashNode, inst)
114
115_objfactory_guaranteed SSDHashNode* SSDHashNode__create(SSDTree* tree);
116// SSDHashNode* ssdhashnode_create(SSDTree* tree);
117#define ssdhashnode_create(tree) SSDHashNode__create(SSDTree(tree))
118
119// void ssdhashnodeUpdateModified(SSDHashNode* self);
120#define ssdhashnodeUpdateModified(self) SSDNode_updateModified(SSDNode(self))
121
122// bool ssdhashnodeIsHashtable(SSDHashNode* self);
123//
124// This node is an object that contains values or objects by name
125#define ssdhashnodeIsHashtable(self) (self)->_->isHashtable(SSDHashNode(self))
126// bool ssdhashnodeIsArray(SSDHashNode* self);
127//
128// This node is an array that contains values or objects by array index
129#define ssdhashnodeIsArray(self) (self)->_->isArray(SSDHashNode(self))
130// bool ssdhashnodeGet(SSDHashNode* self, int32 idx, strref name, stvar* out, SSDLockState* _ssdCurrentLockState);
131//
132// Gets a value. Caller owns the value and must destroy it with stDestroy!
133#define ssdhashnodeGet(self, idx, name, out, _ssdCurrentLockState) (self)->_->get(SSDHashNode(self), idx, name, out, _ssdCurrentLockState)
134// stvar* ssdhashnodePtr(SSDHashNode* self, int32 idx, strref name, SSDLockState* _ssdCurrentLockState);
135//
136// Gets a pointer to a value. This points to the internal storage within the node
137// so it is only guaranteed to be valid while the read lock is held.
138#define ssdhashnodePtr(self, idx, name, _ssdCurrentLockState) (self)->_->ptr(SSDHashNode(self), idx, name, _ssdCurrentLockState)
139// bool ssdhashnodeSet(SSDHashNode* self, int32 idx, strref name, stvar val, SSDLockState* _ssdCurrentLockState);
140//
141// Sets the given value
142#define ssdhashnodeSet(self, idx, name, val, _ssdCurrentLockState) (self)->_->set(SSDHashNode(self), idx, name, val, _ssdCurrentLockState)
143// bool ssdhashnodeSetC(SSDHashNode* self, int32 idx, strref name, stvar* val, SSDLockState* _ssdCurrentLockState);
144//
145// Same as setValue but consumes the value
146// (consumes even on failure)
147#define ssdhashnodeSetC(self, idx, name, val, _ssdCurrentLockState) (self)->_->setC(SSDHashNode(self), idx, name, val, _ssdCurrentLockState)
148// bool ssdhashnodeRemove(SSDHashNode* self, int32 idx, strref name, SSDLockState* _ssdCurrentLockState);
149//
150// Removes a value
151#define ssdhashnodeRemove(self, idx, name, _ssdCurrentLockState) (self)->_->remove(SSDHashNode(self), idx, name, _ssdCurrentLockState)
152// int32 ssdhashnodeCount(SSDHashNode* self, SSDLockState* _ssdCurrentLockState);
153//
154// How many values / objects does this node contain?
155#define ssdhashnodeCount(self, _ssdCurrentLockState) (self)->_->count(SSDHashNode(self), _ssdCurrentLockState)
156// SSDIterator* ssdhashnodeIter(SSDHashNode* self);
157//
158// IMPORTANT NOTE: The generic object iterator interface cannot take any parameters;
159// thus it always acquires a transient read lock and holds it until the iterator is
160// destroyed. The caller MUST NOT already have an SSDLock held.
161// If you want to use iterators inside a larger locked transaction or modify the tree,
162// use iterLocked() instead.
163#define ssdhashnodeIter(self) (self)->_->iter(SSDHashNode(self))
164// SSDIterator* ssdhashnode_iterLocked(SSDHashNode* self, SSDLockState* _ssdCurrentLockState);
165#define ssdhashnode_iterLocked(self, _ssdCurrentLockState) (self)->_->_iterLocked(SSDHashNode(self), _ssdCurrentLockState)
166
167typedef struct SSDHashIter {
168 union {
169 SSDHashIter_ClassIf* _;
170 void* _is_SSDHashIter;
171 void* _is_SSDIterator;
172 void* _is_ObjInst;
173 };
174 ObjClassInfo* _clsinfo;
175 atomic(uintptr) _ref;
176 atomic(ptr) _weakref;
177
178 SSDNode* node;
179 SSDLockState* lstate;
180 SSDLockState transient_lock_state;
181 htiter iter;
182 string lastName;
183} SSDHashIter;
184extern ObjClassInfo SSDHashIter_clsinfo;
185#define SSDHashIter(inst) objInstCheckClass(SSDHashIter, inst)
186#define SSDHashIterNone ((SSDHashIter*)NULL)
187
188typedef struct SSDHashIter_WeakRef {
189 union {
190 ObjInst* _inst;
191 void* _is_SSDHashIter_WeakRef;
192 void* _is_SSDIterator_WeakRef;
193 void* _is_ObjInst_WeakRef;
194 };
195 atomic(uintptr) _ref;
196 RWLock _lock;
197} SSDHashIter_WeakRef;
198#define SSDHashIter_WeakRef(inst) objWeakRefCheckClass(SSDHashIter, inst)
199
200_objfactory_guaranteed SSDHashIter* SSDHashIter_create(SSDHashNode* node, SSDLockState* lstate);
201// SSDHashIter* ssdhashiterCreate(SSDHashNode* node, SSDLockState* lstate);
202#define ssdhashiterCreate(node, lstate) SSDHashIter_create(SSDHashNode(node), lstate)
203
204// ObjInst* ssdhashiterObjInst(SSDHashIter* self);
205#define ssdhashiterObjInst(self) SSDIterator_objInst(SSDIterator(self))
206
207// bool ssdhashiterIsHashtable(SSDHashIter* self);
208#define ssdhashiterIsHashtable(self) (self)->_->isHashtable(SSDHashIter(self))
209// bool ssdhashiterIsArray(SSDHashIter* self);
210#define ssdhashiterIsArray(self) (self)->_->isArray(SSDHashIter(self))
211// bool ssdhashiterValid(SSDHashIter* self);
212#define ssdhashiterValid(self) (self)->_->valid(SSDHashIter(self))
213// bool ssdhashiterNext(SSDHashIter* self);
214#define ssdhashiterNext(self) (self)->_->next(SSDHashIter(self))
215// bool ssdhashiterGet(SSDHashIter* self, stvar* out);
216#define ssdhashiterGet(self, out) (self)->_->get(SSDHashIter(self), out)
217// stvar* ssdhashiterPtr(SSDHashIter* self);
218#define ssdhashiterPtr(self) (self)->_->ptr(SSDHashIter(self))
219// strref ssdhashiterName(SSDHashIter* self);
220#define ssdhashiterName(self) (self)->_->name(SSDHashIter(self))
221// int32 ssdhashiterIdx(SSDHashIter* self);
222#define ssdhashiterIdx(self) (self)->_->idx(SSDHashIter(self))
223// bool ssdhashiterIterOut(SSDHashIter* self, int32* idx, strref* name, stvar** val);
224#define ssdhashiterIterOut(self, idx, name, val) (self)->_->iterOut(SSDHashIter(self), idx, name, val)
225
226CX_C_END
#define saDeclarePtr(name)
Definition sarray.h:100
#define _objfactory_guaranteed
Definition objimpl.h:106
#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.