2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21#ifndef GIMBAL_OBJECT_H
22#define GIMBAL_OBJECT_H
25#include "../ifaces/gimbal_itable_variant.h"
26#include "../ifaces/gimbal_ievent_handler.h"
27#include "../ifaces/gimbal_ievent_filter.h"
28#include "../properties/gimbal_property.h"
31
32
33
35#define GBL_OBJECT(self) (GBL_CAST(GblObject, self))
37#define GBL_OBJECT_GET_CLASS(self) (GBL_CLASSOF(GblObject, self))
41
42
43#define GBL_NEW( ...) GBL_OBJECT_NEW
(__VA_ARGS__)
45
46
47#define GBL_PLACEMENT_NEW( ...) GBL_OBJECT_CONSTRUCT(__VA_ARGS__)
49#define GBL_SELF_TYPE GblObject
56
57
58
59
60
61
62
63
64
65
67 GblITableVariant, GblIEventHandler, GblIEventFilter)
73 GBL_RESULT (*pFnProperty) (
GBL_CSELF,
const GblProperty* pProp, GblVariant* pValue);
75 GBL_RESULT (*pFnSetProperty)(
GBL_SELF,
const GblProperty* pProp, GblVariant* pValue);
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
119
120
121
145 (GblObjectClass* pClass,
151 GblObjectClass* pClass,
155 size_t propertyCount,
156 const char* pNames[],
161 size_t propertyCount,
162 const char* pNames[],
167 size_t propertyCount,
168 const char* pNames[],
172 (GblObjectClass* pClass,
173 size_t propertyCount,
174 const char* pNames[],
178 (GblObjectClass* pClass,
180 size_t propertyCount,
181 const char* pNames[],
186 GblObjectClass* pClass,
187 size_t propertyCount,
188 const char* pNames[],
193
194
195
196
218 const char* pNames[],
243 const char* pNames[],
248
249
250
251
261
262
263
264
304
305
306
307
330#define GBL_OBJECT_NEW_1(typeName) ((typeName*)GblObject_create(GBL_TYPEID(typeName), GBL_NULL))
334#define GBL_OBJECT_CONTRUCT(instance, cType, ...) (GblObject_construct(instance,GBL_TYPEID(cType), __VA_ARGS__, NULL
))
#define GBL_CLASS_CAST(cType, klass)
#define GBL_FORWARD_DECLARE_STRUCT(S)
#define GBL_TYPEID(instanceStruct)
#define GBL_CLASS_DERIVE(...)
#define GBL_INSTANCE_DERIVE_EMPTY(derived, base)
#define GBL_CLASSOF(cType, self)
#define GBL_CAST(cType, self)
#define GBL_VA_OVERLOAD_CALL(BASE, SUFFIXER,...)
#define GBL_TUPLE_REST(X,...)
#define GBL_TUPLE_FIRST(...)
#define GBL_VA_OVERLOAD_SUFFIXER_1_N(...)
GBL_RESULT GblObject_constructVaListWithClass(GblObject *pSelf, GblObjectClass *pClass, va_list *pList)
Variant of GblObjecT_constructWithClass(), where the property list is provided as a va_list pointer.
GblObject * GblObject_createVaList(GblType type, va_list *pList)
Variant of GblObject_create(), where the property list is provided as a va_list pointer.
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...
GblObject * GblObject_createExtVaList(GblType type, size_t size, va_list *pList)
Variant of GblObject_createVaList(), where the object is created with an extended size.
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_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_createVaListWithClass(GblObjectClass *pClass, va_list *pList)
Variant of GblObject_createWithClass(), where the property list is provided as a va_list pointer.
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.
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.
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_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.
GBL_RESULT GblObject_constructVaList(GblObject *pSelf, GblType type, va_list *pList)
Variant of GblObject_construct(), where the property list is provided as a va_list pointer.
GblObject * GblObject_createExtVaListWithClass(GblObjectClass *pClass, size_t size, va_list *pList)
Variant of GblObject_createVaListWithClass(), 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.
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, EventHandlers, 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.
GBL_RESULT GblObject_setPropertyVaList(GblObject *pSelf, const char *pName, va_list *pList)
Variant of GblObject_setProperty() with the pointer for storing the value being specified as a pointe...
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_uninstallEventFilter(GblObject *pSelf, GblIEventFilter *pFilter)
Removes the event filter from the given object, so that it no longer intercepts event notifications.
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_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.
GblObject * GblObject_findSiblingByName(const GblObject *pSelf, const char *pName)
Iterates sequentially over the list of siblings to the given object, returning a poitner to the first...
GBL_RESULT GblObject_propertyVaListByQuark(const GblObject *pSelf, GblQuark name, va_list *pList)
Variant of GblObject_propertyVaList() with the name being specified by a quark (faster lookups)
GblIEventFilter * GblObject_eventFilter(const GblObject *pSelf, size_t index)
Returns a pointer to the event filter installed on the given object at the index position.
GblObject * GblObject_findAncestorByType(const GblObject *pSelf, GblType ancestorType)
Returns a pointer to the closest ancestor object of the given object that is of ancestorType or NULL ...
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...
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.
void GblObject_setNameRef(GblObject *pSelf, const GblStringRef *pRef)
Sets the name of the given object to pRef, taking ownership of the given reference.
GBL_RESULT GblObject_setPropertiesVaList(GblObject *pSelf, va_list *pList)
Variant of Gblobject_setProperties() where the NULL-termianted K,V pairs list is specified as apointe...
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.
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.
const 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_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_installEventFilter(GblObject *pSelf, GblIEventFilter *pFilter)
Installs the event filter on the given object, allowing it to intercept event notifications.
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...
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.
size_t GblObject_eventFilterCount(const GblObject *pSelf)
Returns the number of event filters currently installed on the given object.
GblContext * GblObject_findContext(GblObject *pSelf)
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)
GBL_RESULT GblObject_propertiesVaList(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_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 ...
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 ...
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 ...