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#ifndef GIMBAL_OBJECT_H
27#define GIMBAL_OBJECT_H
30#include "../ifaces/gimbal_ievent_receiver.h"
31#include "../properties/gimbal_property.h"
32#include "../../containers/gimbal_ring_list.h"
35
36
37
39#define GBL_OBJECT(self) GBL_CAST
(GblObject, self)
40#define GBL_OBJECT_CLASS(klass) GBL_CLASS_CAST
(GblObject, klass)
41#define GBL_OBJECT_CLASSOF(self) GBL_CLASSOF
(GblObject, self)
45
46
47
50
51
52#define GBL_NEW( ...) GBL_OBJECT_NEW
(__VA_ARGS__)
55
56
57#define GBL_NEW_AT( ...) GBL_OBJECT_NEW_AT
(__VA_ARGS__)
62
63
64
65
66#define GblObject_foreachChild( ...) GblObject_foreachChildDefault_
(__VA_ARGS__)
69
70
71
72
73#define GblObject_foreachChildReverse( ...) GblObject_foreachChildReverseDefault_
(__VA_ARGS__)
75#define GBL_SELF_TYPE GblObject
78typedef GblBool (*GblObjectCmpFn)(
const GblObject* pObj,
void* pClosure);
85
86
87
88
89
90
91
92
93
95 GblITableVariant, GblIEventReceiver)
101 GBL_RESULT (*pFnProperty) (
GBL_CSELF,
const GblProperty* pProp, GblVariant* pValue);
103 GBL_RESULT (*pFnSetProperty) (
GBL_SELF,
const GblProperty* pProp, GblVariant* pValue);
107
108
109
111typedef GblBool (*GblObjectIterFn)(GblObject* pChild,
void* pClosure);
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
151 (propertyChange, (GBL_INSTANCE_TYPE, pReceiver), (GBL_BOX_TYPE, pProperty))
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
215 GblObjectClass* pClass,
219 size_t propertyCount,
220 const char* pNames[],
225 size_t propertyCount,
226 const char* pNames[],
231 size_t propertyCount,
232 const char* pNames[],
236 (GblObjectClass* pClass,
237 size_t propertyCount,
238 const char* pNames[],
242 (GblObjectClass* pClass,
244 size_t propertyCount,
245 const char* pNames[],
250 GblObjectClass* pClass,
251 size_t propertyCount,
252 const char* pNames[],
257
258
259
260
280 const char* pNames[],
284
285
286
287
301
302
303
304
305
312 const char* pNames[],
317
318
319
320
332
333
334
335
343
344
345
346
356
357
358
359
377
378
442
443
444
445
468#define GBL_OBJECT_NEW_1(typeName) ((typeName*)GblObject_create(GBL_TYPEID(typeName), GBL_NULL))
472#define GBL_OBJECT_NEW_AT(cType, instance, ...) (GblObject_construct(instance,GBL_TYPEID(cType), __VA_ARGS__, NULL))
474#define GblObject_foreachChildDefault_(...)
475 GblObject_foreachChildDefault__
(__VA_ARGS__, GblObject*)
476#define GblObject_foreachChildDefault__(self, name, type, ...)
477 GblObject_foreachChildImpl_
(self, name, type)
478#define GblObject_foreachChildImpl_(self, name, type)
479 for(type name = (type)GblObject_childFirst(self),
480 *name##_next_ = name ?
481 (type)GblObject_siblingNext(GBL_OBJECT(name)) :
486 name = name##_next_, name##_next_ = name ?
490#define GblObject_foreachChildReverseDefault_(...)
491 GblObject_foreachChildReverseDefault__
(__VA_ARGS__, GblObject*)
492#define GblObject_foreachChildReverseDefault__(self, name, type, ...)
493 GblObject_foreachChildReverseImpl_
(self, name, type)
494#define GblObject_foreachChildReverseImpl_(self, name, type)
495 for(type name = (type)GblObject_childLast(self),
496 *name##_prev_ = name ?
497 (type)GblObject_siblingPrevious(GBL_OBJECT(name)) :
502 name = name##_prev_, name##_prev_ = name ?
503 (type)GblObject_siblingPrevious(GBL_OBJECT(name))
#define GBL_FORWARD_DECLARE_STRUCT(S)
#define GBL_TYPEID(instanceStruct)
#define GBL_CLASS_DERIVE(...)
#define GBL_INSTANCE_DERIVE_EMPTY(derived, base)
#define GBL_VA_OVERLOAD_CALL(BASE, SUFFIXER,...)
#define GBL_TUPLE_REST(X,...)
#define GBL_TUPLE_FIRST(...)
#define GBL_VA_OVERLOAD_SUFFIXER_1_N(...)
GblObject * GblObject_createVariants(GblType type, size_t propertyCount, const char *pNames[], GblVariant *pValues)
Creates an object-derived type on the heap, initializing it with an array of property values and a co...
GBL_RESULT GblObject_constructWithClass(GblObject *pSelf, GblObjectClass *pClass,...)
Constructs an object-derived type in-place, with the given class, initializing it with a NULL-termina...
GblObject * GblObject_createVariantsWithClass(GblObjectClass *pClass, size_t propertyCount, const char *pNames[], GblVariant *pValues)
Variant of GblObject_createVariants(), where the object is constructed with a weak reference to the g...
GblObject * GblObject_createVa(GblType type, va_list *pList)
Variant of GblObject_create(), where the property list is provided as a va_list pointer.
GblObject * GblObject_createExtVaWithClass(GblObjectClass *pClass, size_t size, va_list *pList)
Variant of GblObject_createVaListWithClass(), where the object is allocated with an extended size.
GblObject * GblObject_createWithClass(GblObjectClass *pClass,...)
Creates an object-derived type on the heap, with the given class, initializing it with a NULL-termina...
GBL_RESULT GblObject_construct(GblObject *pSelf, GblType type,...)
Constructs an object-derived type in-place, initializing it with a NULL-terminated K,...
GblObject * GblObject_createExtVa(GblType type, size_t size, va_list *pList)
Variant of GblObject_createVaList(), where the object is created with an extended size.
GBL_RESULT GblObject_constructVariantsWithClass(GblObject *pSelf, GblObjectClass *pClass, size_t propertyCount, const char *pNames[], GblVariant *pValues)
Variant of GblObject_constructVariants(), where the object is constructed with a weak reference to th...
#define GBL_OBJECT(self)
Casts a GblInstance to a GblObject.
GblType GblObject_type(void)
Returns the GblType UUID associated with GblObject.
GblObject * GblObject_createExt(GblType type, size_t size,...)
Variant of GblObject_create(), where the object is created with an extended size.
GBL_RESULT GblObject_constructVa(GblObject *pSelf, GblType type, va_list *pList)
Variant of GblObject_construct(), where the property list is provided as a va_list pointer.
GblObject * GblObject_createVaWithClass(GblObjectClass *pClass, va_list *pList)
Variant of GblObject_createWithClass(), where the property list is provided as a va_list pointer.
GblObject * GblObject_create(GblType type,...)
Creates an object-derived type on the heap, initializing it with a NULL-terminated K,...
GblObject * GblObject_createExtWithClass(GblObjectClass *pClass, size_t size,...)
Variant of GblObject_createWithClass(), where the object is created with an extended size.
GblContext * GblObject_findContext(GblObject *pSelf)
GblObject * GblObject_createVariantsExt(GblType type, size_t size, size_t propertyCount, const char *pNames[], GblVariant *pValues)
Variant of GblObject_createVariants(), where the object is allocated with an extended size.
GBL_RESULT GblObject_constructVaWithClass(GblObject *pSelf, GblObjectClass *pClass, va_list *pList)
Variant of GblObject_constructWithClass(), where the property list is provided as a va_list pointer.
GBL_RESULT GblObject_constructVariants(GblObject *pSelf, GblType type, size_t propertyCount, const char *pNames[], GblVariant *pValues)
Creates an object-derived type in-place, initializing it with an array of property values and a corre...
#define GBL_OBJECT_TYPE
GblType UUID for GblObject.
GblObject * GblObject_createVariantsExtWithClass(GblObjectClass *pClass, size_t size, size_t propertyCount, const char *pNames[], GblVariant *pValues)
Variant of GblObject_createVariantsWithClass(), where the object is allocated with an extended size.
#define GBL_UINT16_TYPE
Builtin ID for uint16_t GblVariant type.
#define GBL_STRING_TYPE
Builtin ID for string GblVariant type.
#define GBL_PROPERTIES(object,...)
Declares a list of properties for the given object/instance structure.
#define GBL_RING_LIST_TYPE
Type UUID for GblRingList.
#define GBL_SIGNALS(instanceStruct,...)
Declares a list of signals to be associated with the given instanceStruct.
uint8_t GblBool
Basic boolean type, standardized to sizeof(char)
uintptr_t GblQuark
Uniquely identifiable interned string type.
const char GblStringRef
Reference-counted, const char*-compatible string type.
Main Object-Oriented Instance with Properties, EventReceivers, and Parenting.
void GblObject_addChild(GblObject *pSelf, GblObject *pChild)
Adds pChild as a child of the given object, setting itself as the parent and taking ownership of it.
GBL_RESULT GblObject_properties(const GblObject *pSelf,...)
Takes a NULL-terminated K,V pair list of string property names and pointers to store their values wit...
GblObject * GblObject_findBaseByDepth(const GblObject *pSelf, size_t depth)
Starting at the root object, returns a pointer to the ancestor of the given object at the specified d...
GblObject * GblObject_parent(const GblObject *pSelf)
Returns a pointer to the parent of the given object, or NULL if it doesn't have one.
size_t GblObject_depth(const GblObject *pSelf)
Returns the number of levels deep the given object is in the object tree formed by its ancestors.
GBL_RESULT GblObject_emitPropertyChange(const GblObject *pSelf, const char *pName)
Notifies any listeners that the value of a property has changed internally, by emitting the "property...
GBL_RESULT GblObject_setPropertiesVa(GblObject *pSelf, va_list *pList)
Variant of GblObject_setProperties() where the NULL-terminated K,V pairs list is specified as a point...
GblObject * GblObject_findChildByIndex(const GblObject *pSelf, size_t index)
Iterates sequentially over the list of children on the given object, returning a pointer to the one a...
GblObject * GblObject_findDescendantByType(const GblObject *pSelf, GblType descendantType)
Returns a pointer to the closest descendant found that is of descendantType, or NULL if there isn't o...
GblObject * GblObject_siblingPreviousByName(const GblObject *pSelf, const char *pName)
Returns the previous sibling before the given object with the given name, or NULL if there isn't one.
GblBool GblObject_isInstantiating(const GblObject *pSelf)
Returns true from the time the object has been allocated to the time its final (possibly optional) in...
GblObject * GblObject_findSiblingByType(const GblObject *pSelf, GblType siblingType)
Iterates sequentially over the list of siblings to the given object, returning a pointer to the first...
void GblObject_setParent(GblObject *pSelf, GblObject *pParent)
Sets the parent of the given object to pParent, handing ownership to it.
GblBool GblObject_propertyChangeBlocked(const GblObject *pSelf)
Returns true if emission of the "propertyChange" signal has been blocked on the current object or fal...
GblObject * GblObject_findSiblingByName(const GblObject *pSelf, const char *pName)
Iterates sequentially over the list of siblings to the given object, returning a pointer to the first...
GblObject * GblObject_findAncestorByType(const GblObject *pSelf, GblType ancestorType)
Returns a pointer to the closest ancestor object of the given object that is of ancestorType,...
GblObject * GblObject_siblingNext(const GblObject *pSelf)
Returns the next sibling after the given object, forming a linked list of their parents' children.
GBL_RESULT GblObject_property(const GblObject *pSelf, const char *pName,...)
Looks up the property on the object by name, storing its value in the pointer passed as a variadic ar...
void GblObject_addChildren(GblObject *pSelf, const GblRingList *pList)
Adds all the objects in pList as children of the given object, taking ownership of them.
GblObject * GblObject_findDescendantByCmpFn(const GblObject *pSelf, GblObjectCmpFn pCmpFn, void *pClosure)
Returns a pointer to the closest descendant found that satisfies the provided comparator callback,...
GBL_RESULT GblObject_propertyVariant(const GblObject *pSelf, const char *pName, GblVariant *pValue)
Fetches the value of the specified property, storing it within a variant.
GBL_RESULT GblObject_setProperty(GblObject *pSelf, const char *pName,...)
Sets the property with the given string name to the value given by the pointer passed through the var...
GBL_RESULT GblObject_propertiesVa(const GblObject *pSelf, va_list *pList)
Variant of GblObject_properties() with the NULL-terminated K,V pair list being specified as a pointer...
GblObject * GblObject_siblingPreviousByCmpFn(const GblObject *pSelf, GblObjectCmpFn pCmpFn, void *pClosure)
Returns the previous sibling before the given object that satisfies the provided comparator callback,...
GBL_RESULT GblObject_propertyVaByQuark(const GblObject *pSelf, GblQuark name, va_list *pList)
Variant of GblObject_propertyVaList() with the name being specified by a quark (faster lookups)
GblObject * GblObject_siblingPreviousByType(const GblObject *pSelf, GblType type)
Returns the previous sibling before the given object that is of type, or NULL if there isn't one.
GblBool GblObject_removeChild(GblObject *pSelf, GblObject *pChild)
Removes pChild from being a child of the given object, setting its parent to NULL.
GBL_RESULT GblObject_setPropertyVariant(GblObject *pSelf, const char *pName, GblVariant *pValue)
Variant of GblObject_setProperty() where the property value is provided as a GblVariant.
size_t GblObject_childCount(const GblObject *pSelf)
Returns the number of children with the given object as their parent.
GblBool GblObject_blockPropertyChange(GblObject *pSelf, GblBool blocked)
Disables or enables emission of the "propertyChange" signal, returning its previous enablement....
GblObject * GblObject_findChildByType(const GblObject *pSelf, GblType childType)
Searches through the list of children on the given object, returning a pointer to the first one with ...
GBL_RESULT GblObject_propertyByQuark(const GblObject *pSelf, GblQuark name,...)
Looks up the property on the object by quark (faster), storing its value in the pointer passed as a v...
GblObject * GblObject_childFirst(const GblObject *pSelf)
Returns a pointer to the first child of the given object, or NULL if it has none.
GBL_RESULT GblObject_emitPropertyChangeByQuark(const GblObject *pSelf, GblQuark name)
Equivalent to GblObject_emitPropertyChange(), except that the property lookup is done more efficientl...
void GblObject_setName(GblObject *pSelf, const char *pName)
Sets the name of the given object to pName, making a copy of its contents to store internally.
GblIEventReceiver * GblObject_eventFilter(const GblObject *pSelf, size_t index)
Returns a pointer to the event filter installed on the given object at the index position.
GBL_RESULT GblObject_propertyVaList(const GblObject *pSelf, const char *pName, va_list *pList)
Variant of GblObject_property() with the pointer for storing the value specified by a pointer to a va...
GblBool GblObject_iterateChildren(const GblObject *pSelf, GblObjectIterFn pFnIt, void *pUd)
Iterates over every child of the given object, passing them to the given iterator function,...
GBL_RESULT GblObject_propertiesVariants(const GblObject *pSelf, size_t count, const char *pNames[], GblVariant *pValue)
Looks up multiple properties by the names provided by the pNames list and stores them within the arra...
GblObject * GblObject_findSiblingByCmpFn(const GblObject *pSelf, GblObjectCmpFn pCmpFn, void *pClosure)
Iterates sequentially over the list of siblings to the given object, returning a pointer to the first...
GBL_RESULT GblObject_sendEvent(GblObject *pSelf, GblEvent *pEvent)
Emits an event upwards through the object hierarchy, notifying the parent of the given object of the ...
GBL_RESULT GblObject_setPropertyVa(GblObject *pSelf, const char *pName, va_list *pList)
Variant of GblObject_setProperty() with the pointer for storing the value being specified as a pointe...
GblObject * GblObject_findSiblingByIndex(const GblObject *pSelf, size_t index)
Iterates sequentially over the list of siblings to the given object, returning a pointer to the one a...
GBL_RESULT GblObject_setPropertyVaListByQuark(GblObject *pSelf, GblQuark name, va_list *pList)
Variant of GblObject_setPropertyVaList() with the name being specified as a quark (for faster lookups...
GblStringRef * GblObject_name(const GblObject *pSelf)
Retrieves the name of the given object or returns an empty string if it doesn't have one.
GBL_RESULT GblObject_installEventFilter(GblObject *pSelf, GblIEventReceiver *pFilter)
Installs the event filter on the given object, allowing it to intercept event notifications.
void GblObject_removeChildren(GblObject *pSelf, const GblRingList *pList)
Removes all the objects in pList as children of the given object, giving up ownership of them.
GblObject * GblObject_findAncestorByName(const GblObject *pSelf, const char *pName)
Returns a pointer to the first ancestor found with the given name or NULL if none were found.
GBL_RESULT GblObject_uninstallEventFilter(GblObject *pSelf, GblIEventReceiver *pFilter)
Removes the event filter from the given object, so that it no longer intercepts event notifications.
GblObject * GblObject_findDescendantByName(const GblObject *pSelf, const char *pName)
Returns a pointer to the closest descendant found with the given name or NULL if none were found.
size_t GblObject_eventFilterCount(const GblObject *pSelf)
Returns the number of event filters currently installed on the given object.
void GblObject_clearChildren(GblObject *pSelf)
Clears the children list of the given object, giving up ownership of them.
GBL_RESULT GblObject_propertyVariantByQuark(const GblObject *pSelf, GblQuark name, GblVariant *pValue)
Variant of GblObject_propertyVariant(), with the property name specified as a quark (faster lookups)
void GblObject_setNameRef(GblObject *pSelf, GblStringRef *pRef)
Sets the name of the given object to pRef, taking ownership of the given reference.
GblObject * GblObject_findChildByCmpFn(const GblObject *pSelf, GblObjectCmpFn pCmpFn, void *pClosure)
Searches through the list of children on the given object, returning a pointer to the first one that ...
size_t GblObject_childIndex(const GblObject *pSelf)
Returns the index of the given object in its parent's list of children.
GblObject * GblObject_siblingPrevious(const GblObject *pSelf)
Returns the previous sibling before the given object, forming a linked list of their parents' childre...
GBL_RESULT GblObject_setProperties(GblObject *pSelf,...)
Sets multiple properties by taking a NULL-terminated K,V pairs list of string names and values.
GBL_RESULT GblObject_setPropertyByQuark(GblObject *pSelf, GblQuark quark,...)
Variant of GblObject_setProperty() with the name being specified as a quark (for faster lookups)
GBL_RESULT GblObject_notifyEvent(GblObject *pSelf, GblEvent *pEvent)
Notifies the given object of an event, which first propagates through its event filters before going ...
GblObject * GblObject_siblingNextByName(const GblObject *pSelf, const char *pName)
Returns the next sibling after the given object with the given name, or NULL if there isn't one.
GblObject * GblObject_siblingNextByType(const GblObject *pSelf, GblType type)
Returns the next sibling after the given object that is of type, or NULL if there isn't one.
GBL_RESULT GblObject_setPropertyVariantByQuark(GblObject *pSelf, GblQuark name, GblVariant *pValue)
Variant of GblObject_setPropertyVariant() where the property name is provided as a quark (for faster ...
GblObject * GblObject_findAncestorByCmpFn(const GblObject *pSelf, GblObjectCmpFn pCmpFn, void *pClosure)
Returns a pointer to the closest ancestor found that satisfies the provided comparator callback,...
GBL_RESULT GblObject_setPropertiesVariants(GblObject *pSelf, size_t count, const char *pNames[], GblVariant *pValue)
Sets the properties specified by the list of names to the corresponding values specified as the list ...
GblBool GblObject_isConstructing(const GblObject *pSelf)
Returns true immediately after type initializers are called, but before GblObject::pFnConstructed() i...
GblObject * GblObject_findAncestorByHeight(const GblObject *pSelf, size_t height)
Returns a pointer to the ancestor object of the given object at the specified height,...
void GblObject_setChildren(GblObject *pSelf, const GblRingList *pList)
Sets the children of the given object to pList, replacing the current children list and taking owners...
GblObject * GblObject_findChildByName(const GblObject *pSelf, const char *pName)
Searches through the list of children on the given object, returning a pointer to the first one with ...
GblObject * GblObject_childLast(const GblObject *pSelf)
Returns a pointer to the last child of the given object, or NULL if it has none.
GblObject * GblObject_siblingNextByCmpFn(const GblObject *pSelf, GblObjectCmpFn pCmpFn, void *pClosure)
Returns the next sibling after the given object that satisfies the provided comparator callback,...