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
27#ifndef GIMBAL_OBJECT_H
28#define GIMBAL_OBJECT_H
31#include "../ifaces/gimbal_itable_variant.h"
32#include "../ifaces/gimbal_ievent_receiver.h"
33#include "../properties/gimbal_property.h"
34#include "../../containers/gimbal_ring_list.h"
37
38
39
41#define GBL_OBJECT(self) GBL_CAST
(GblObject, self)
42#define GBL_OBJECT_CLASS(klass) GBL_CLASS_CAST
(GblObject, klass)
43#define GBL_OBJECT_GET_CLASS(self) GBL_CLASSOF
(GblObject, self)
47
48
49
52
53
54#define GBL_NEW( ...) GBL_OBJECT_NEW
(__VA_ARGS__)
57
58
59#define GBL_NEW_AT( ...) GBL_OBJECT_NEW_AT
(__VA_ARGS__)
63#define GBL_SELF_TYPE GblObject
70
71
72
73
74
75
76
77
78
80 GblITableVariant, GblIEventReceiver)
86 GBL_RESULT (*pFnProperty) (
GBL_CSELF,
const GblProperty* pProp, GblVariant* pValue);
88 GBL_RESULT (*pFnSetProperty) (
GBL_SELF,
const GblProperty* pProp, GblVariant* pValue);
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
128 (propertyChange, (GBL_INSTANCE_TYPE, pReciever), (GBL_BOX_TYPE, pProperty))
136
137
138
165 GblObjectClass* pClass,
169 size_t propertyCount,
170 const char* pNames[],
175 size_t propertyCount,
176 const char* pNames[],
181 size_t propertyCount,
182 const char* pNames[],
186 (GblObjectClass* pClass,
187 size_t propertyCount,
188 const char* pNames[],
192 (GblObjectClass* pClass,
194 size_t propertyCount,
195 const char* pNames[],
200 GblObjectClass* pClass,
201 size_t propertyCount,
202 const char* pNames[],
207
208
209
210
230 const char* pNames[],
234
235
236
237
257 const char* pNames[],
262
263
264
265
277
278
279
280
288
289
290
291
301
302
303
304
358
359
360
361
384#define GBL_OBJECT_NEW_1(typeName) ((typeName*)GblObject_create(GBL_TYPEID(typeName), GBL_NULL))
388#define GBL_OBJECT_NEW_AT(cType, instance, ...) (GblObject_construct(instance,GBL_TYPEID(cType), __VA_ARGS__, NULL
))
#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...
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, intializing 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, initiailzing 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.
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 poiner 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-termianted K,V pairs list is specified as apointe...
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_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.
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...
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...
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...
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...
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 thelist of siblings to the given object, returning a pointer to the one at...
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.
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.
size_t GblObject_eventFilterCount(const GblObject *pSelf)
Returns the number of event filters currently installed on the given object.
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.
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 pointers to s...
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 ...
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,...
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 ...