CX Framework
Cross-platform C utility framework
Loading...
Searching...
No Matches
settingshashnode.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/ssdhashnode.h>
8
9CX_C_BEGIN
10
11typedef struct SettingsHashNode SettingsHashNode;
12typedef struct SettingsHashNode_WeakRef SettingsHashNode_WeakRef;
13saDeclarePtr(SettingsHashNode);
14saDeclarePtr(SettingsHashNode_WeakRef);
15#define _sti_SettingsHashNode _sti_object
16#define SType_SettingsHashNode SettingsHashNode*
17#define STStorageType_SettingsHashNode SettingsHashNode*
18#define STypeArg_SettingsHashNode(type, val) stgeneric(object, (ObjInst*)objInstCheckClass(SettingsHashNode, val))
19#define STypeArgPtr_SettingsHashNode(type, val) (stgeneric*)objInstCheckClassPtr(SettingsHashNode, val)
20#define STypeCheckedArg_SettingsHashNode(type, val) stType(type), stArg(type, val)
21#define STypeCheckedPtrArg_SettingsHashNode(type, val) stType(type), stArgPtr(type, val)
22
23typedef struct SettingsBind {
24 stype type; // type of bound variable
25 stgeneric *var; // pointer to bound variable
26 stgeneric cache; // cached copy for change detection
27 stgeneric def; // default value
28
29 bool userset; // explicitly overridden, even if it's the default value
30} SettingsBind;
31
32typedef struct SettingsHashNode_ClassIf {
33 ObjIface* _implements;
34 ObjIface* _parent;
35 size_t _size;
36
37 // This node is an object that contains values or objects by name
38 bool (*isHashtable)(_In_ void* self);
39 // This node is an array that contains values or objects by array index
40 bool (*isArray)(_In_ void* self);
41 // Gets a value. Caller owns the value and must destroy it with stDestroy!
42 bool (*get)(_In_ void* self, int32 idx, _In_opt_ strref name, _When_(return == true, _Out_) stvar* out, _Inout_ SSDLockState* _ssdCurrentLockState);
43 // Gets a pointer to a value. This points to the internal storage within the node
44 // so it is only guaranteed to be valid while the read lock is held.
45 _Ret_opt_valid_ stvar* (*ptr)(_In_ void* self, int32 idx, _In_opt_ strref name, _Inout_ SSDLockState* _ssdCurrentLockState);
46 // Sets the given value
47 bool (*set)(_In_ void* self, int32 idx, _In_opt_ strref name, stvar val, _Inout_ SSDLockState* _ssdCurrentLockState);
48 // Same as setValue but consumes the value
49 // (consumes even on failure)
50 bool (*setC)(_In_ void* self, int32 idx, _In_opt_ strref name, _Inout_ stvar* val, _Inout_ SSDLockState* _ssdCurrentLockState);
51 // Removes a value
52 bool (*remove)(_In_ void* self, int32 idx, _In_opt_ strref name, _Inout_ SSDLockState* _ssdCurrentLockState);
53 // How many values / objects does this node contain?
54 int32 (*count)(_In_ void* self, _Inout_ SSDLockState* _ssdCurrentLockState);
55 // IMPORTANT NOTE: The generic object iterator interface cannot take any parameters;
56 // thus it always acquires a transient read lock and holds it until the iterator is
57 // destroyed. The caller MUST NOT already have an SSDLock held.
58 // If you want to use iterators inside a larger locked transaction or modify the tree,
59 // use iterLocked() instead.
60 _Ret_valid_ SSDIterator* (*iter)(_In_ void* self);
61 SSDIterator* (*_iterLocked)(_In_ void* self, _Inout_ SSDLockState* _ssdCurrentLockState);
62 bool (*bind)(_In_ void* self, _In_opt_ strref name, stype btyp, void* bvar, stgeneric bdef, SSDLockState* _ssdCurrentLockState);
63 // check a single bound variable for changes
64 void (*checkBound)(_In_ void* self, _In_opt_ strref name, SSDLockState* _ssdCurrentLockState);
65 // check for bound variables that have changed
66 void (*checkAll)(_In_ void* self, SSDLockState* _ssdCurrentLockState);
67 void (*unbindAll)(_In_ void* self, SSDLockState* _ssdCurrentLockState);
68} SettingsHashNode_ClassIf;
69extern SettingsHashNode_ClassIf SettingsHashNode_ClassIf_tmpl;
70
71typedef struct SettingsHashNode {
72 union {
73 SettingsHashNode_ClassIf* _;
74 void* _is_SettingsHashNode;
75 void* _is_SSDHashNode;
76 void* _is_SSDNode;
77 void* _is_ObjInst;
78 };
79 ObjClassInfo* _clsinfo;
80 atomic(uintptr) _ref;
81 atomic(ptr) _weakref;
82
83 SSDTree* tree;
84 int64 modified; // The timestamp this node was last modified
85 hashtable storage;
86 hashtable binds;
87} SettingsHashNode;
88extern ObjClassInfo SettingsHashNode_clsinfo;
89#define SettingsHashNode(inst) objInstCheckClass(SettingsHashNode, inst)
90#define SettingsHashNodeNone ((SettingsHashNode*)NULL)
91
92typedef struct SettingsHashNode_WeakRef {
93 union {
94 ObjInst* _inst;
95 void* _is_SettingsHashNode_WeakRef;
96 void* _is_SSDHashNode_WeakRef;
97 void* _is_SSDNode_WeakRef;
98 void* _is_ObjInst_WeakRef;
99 };
100 atomic(uintptr) _ref;
101 RWLock _lock;
102} SettingsHashNode_WeakRef;
103#define SettingsHashNode_WeakRef(inst) objWeakRefCheckClass(SettingsHashNode, inst)
104
105_objfactory_guaranteed SettingsHashNode* SettingsHashNode__create(SSDTree* tree);
106// SettingsHashNode* settingshashnode_create(SSDTree* tree);
107#define settingshashnode_create(tree) SettingsHashNode__create(SSDTree(tree))
108
109// void settingshashnodeUpdateModified(SettingsHashNode* self);
110#define settingshashnodeUpdateModified(self) SSDNode_updateModified(SSDNode(self))
111
112// bool settingshashnodeIsHashtable(SettingsHashNode* self);
113//
114// This node is an object that contains values or objects by name
115#define settingshashnodeIsHashtable(self) (self)->_->isHashtable(SettingsHashNode(self))
116// bool settingshashnodeIsArray(SettingsHashNode* self);
117//
118// This node is an array that contains values or objects by array index
119#define settingshashnodeIsArray(self) (self)->_->isArray(SettingsHashNode(self))
120// bool settingshashnodeGet(SettingsHashNode* self, int32 idx, strref name, stvar* out, SSDLockState* _ssdCurrentLockState);
121//
122// Gets a value. Caller owns the value and must destroy it with stDestroy!
123#define settingshashnodeGet(self, idx, name, out, _ssdCurrentLockState) (self)->_->get(SettingsHashNode(self), idx, name, out, _ssdCurrentLockState)
124// stvar* settingshashnodePtr(SettingsHashNode* self, int32 idx, strref name, SSDLockState* _ssdCurrentLockState);
125//
126// Gets a pointer to a value. This points to the internal storage within the node
127// so it is only guaranteed to be valid while the read lock is held.
128#define settingshashnodePtr(self, idx, name, _ssdCurrentLockState) (self)->_->ptr(SettingsHashNode(self), idx, name, _ssdCurrentLockState)
129// bool settingshashnodeSet(SettingsHashNode* self, int32 idx, strref name, stvar val, SSDLockState* _ssdCurrentLockState);
130//
131// Sets the given value
132#define settingshashnodeSet(self, idx, name, val, _ssdCurrentLockState) (self)->_->set(SettingsHashNode(self), idx, name, val, _ssdCurrentLockState)
133// bool settingshashnodeSetC(SettingsHashNode* self, int32 idx, strref name, stvar* val, SSDLockState* _ssdCurrentLockState);
134//
135// Same as setValue but consumes the value
136// (consumes even on failure)
137#define settingshashnodeSetC(self, idx, name, val, _ssdCurrentLockState) (self)->_->setC(SettingsHashNode(self), idx, name, val, _ssdCurrentLockState)
138// bool settingshashnodeRemove(SettingsHashNode* self, int32 idx, strref name, SSDLockState* _ssdCurrentLockState);
139//
140// Removes a value
141#define settingshashnodeRemove(self, idx, name, _ssdCurrentLockState) (self)->_->remove(SettingsHashNode(self), idx, name, _ssdCurrentLockState)
142// int32 settingshashnodeCount(SettingsHashNode* self, SSDLockState* _ssdCurrentLockState);
143//
144// How many values / objects does this node contain?
145#define settingshashnodeCount(self, _ssdCurrentLockState) (self)->_->count(SettingsHashNode(self), _ssdCurrentLockState)
146// SSDIterator* settingshashnodeIter(SettingsHashNode* self);
147//
148// IMPORTANT NOTE: The generic object iterator interface cannot take any parameters;
149// thus it always acquires a transient read lock and holds it until the iterator is
150// destroyed. The caller MUST NOT already have an SSDLock held.
151// If you want to use iterators inside a larger locked transaction or modify the tree,
152// use iterLocked() instead.
153#define settingshashnodeIter(self) (self)->_->iter(SettingsHashNode(self))
154// SSDIterator* settingshashnode_iterLocked(SettingsHashNode* self, SSDLockState* _ssdCurrentLockState);
155#define settingshashnode_iterLocked(self, _ssdCurrentLockState) (self)->_->_iterLocked(SettingsHashNode(self), _ssdCurrentLockState)
156// bool settingshashnodeBind(SettingsHashNode* self, strref name, stype btyp, void* bvar, stgeneric bdef, SSDLockState* _ssdCurrentLockState);
157#define settingshashnodeBind(self, name, btyp, bvar, bdef, _ssdCurrentLockState) (self)->_->bind(SettingsHashNode(self), name, btyp, bvar, bdef, _ssdCurrentLockState)
158// void settingshashnodeCheckBound(SettingsHashNode* self, strref name, SSDLockState* _ssdCurrentLockState);
159//
160// check a single bound variable for changes
161#define settingshashnodeCheckBound(self, name, _ssdCurrentLockState) (self)->_->checkBound(SettingsHashNode(self), name, _ssdCurrentLockState)
162// void settingshashnodeCheckAll(SettingsHashNode* self, SSDLockState* _ssdCurrentLockState);
163//
164// check for bound variables that have changed
165#define settingshashnodeCheckAll(self, _ssdCurrentLockState) (self)->_->checkAll(SettingsHashNode(self), _ssdCurrentLockState)
166// void settingshashnodeUnbindAll(SettingsHashNode* self, SSDLockState* _ssdCurrentLockState);
167#define settingshashnodeUnbindAll(self, _ssdCurrentLockState) (self)->_->unbindAll(SettingsHashNode(self), _ssdCurrentLockState)
168
169CX_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.