2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19#ifndef GIMBAL_MODULE_H
20#define GIMBAL_MODULE_H
22#include "../meta/instances/gimbal_context.h"
23#include "../meta/ifaces/gimbal_iplugin.h"
24#include "../strings/gimbal_string_ref.h"
25#include "../utils/gimbal_version.h"
26#include "../utils/gimbal_option_group.h"
29
30
31
33#define GBL_MODULE(self) GBL_CAST
(GblModule, self)
34#define GBL_MODULE_CLASS(klass) GBL_CLASS_CAST
(GblModule, klass)
35#define GBL_MODULE_CLASSOF(self) GBL_CLASSOF
(GblModule, self)
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54#define GBL_REQUIRE(...) GBL_REQUIRE_
(__VA_ARGS__)
56#define GBL_SELF_TYPE GblModule
64typedef GblBool (*GblModuleIterFn)(GblModule* pIt,
void* pClosure);
67
68
69
70
71
72
73
74
75
76
77
84
85
86
87
88
89
90
91
92
93
94
95
96
97
111 (description, GBL_GENERIC, (READ, WRITE, LOAD, SAVE),
GBL_STRING_TYPE),
126
127
128
143
144
145
148 const char* pVersion,
154 const char* pVersion,
161
162
163
169 const char* pDescription,
176
177
178
186
187
188
203#define GBL_REQUIRE_(...)
206#define GBL_REQUIRE__1(type)
207 GBL_CAST
(type, GblModule_require(GblType_name(GBL_TYPEID(type)),
210#define GBL_REQUIRE__2(type, name)
211 GBL_CAST
(type, GblModule_require(name, GBL_NULL, __FILE__, __func__,
214#define GBL_REQUIRE__3(type, name, version)
215 GBL_CAST
(type, GblModule_require(name, version, __FILE__, __func__,
218#define GblModule_iterate(...)
219 GblModule_iterateDefault_
(__VA_ARGS__)
220#define GblModule_iterateDefault_(...)
221 GblModule_iterateDefault__
(__VA_ARGS__, NULL
)
222#define GblModule_iterateDefault__(iter, cl, ...)
223 (GblModule_iterate
)(iter, cl)
#define GBL_FORWARD_DECLARE_STRUCT(S)
#define GBL_TYPEID(instanceStruct)
#define GBL_INSTANCE_DERIVE(derivedInstance, baseInstance)
#define GBL_CLASS_DERIVE(...)
#define GBL_VA_OVERLOAD_CALL(BASE, SUFFIXER,...)
#define GBL_VA_OVERLOAD_SUFFIXER_ARGC(...)
GBL_RESULT GblModule_unregister(GblModule *pSelf)
Attempts to unregister a previously registered GblModule instance, removing it from the internal regi...
GblModule * GblModule_at(size_t index)
Returns a pointer to the GblModule which has been loaded at the given index, or NULL if there isn't o...
size_t GblModule_count(void)
Returns the total number of modules which have been registered.
GBL_RESULT GblModule_unuse(GblModule *pSelf)
Manually decrements the given module's usage count, unloading it when the last user is done....
GblRefCount GblModule_unref(GblModule *pSelf)
Releases a reference to a previously created GblModule instance, destructing and freeing it if there ...
GblModule * GblModule_create(GblType derivedType, const char *pName, GblVersion version, const char *pAuthor, const char *pDescription, const char *pPrefix)
Creates and returns a reference to a new GblModule-compatible instance type, but does not add it to t...
GblModule * GblModule_requireQuark(GblQuark name, const char *pVersion, const char *pFile, const char *pFunc, size_t line)
Equivalent to GblModule_require(), except using a faster quark for the name identifier.
GblModule * GblModule_find(const char *pName)
Returns a pointer to the module with the gibven name, if present, gracefully returning NULL otherwise...
GblRefCount GblModule_useCount(const GblModule *pSelf)
Retrieves the current usage counter for the given module.
GblModule * GblModule_require(const char *pName, const char *pVersion, const char *pFile, const char *pFunc, size_t line)
Loads or returns a module matching the given name and optional version identifier,...
GblBool GblModule_isLoaded(const GblModule *pSelf)
Returns true if the given module is currently loaded and has active uses, return false otherwise.
GblModule * GblModule_findQuark(GblQuark name)
Equivalent to GblModule_find(), except doing a faster search using a GblQuark for the name.
GBL_RESULT GblModule_register(GblModule *pSelf)
Attempts to register a previously instantiated GblModule instance as a globally importable module wit...
GblBool GblModule_iterate(GblModuleIterFn pFnIter, void *pCl)
Iterates over every registered module, invoking the provided iterator callback, optionally passing ba...
GblType GblModule_type(void)
Returns the GblType UUID associated with GblModule.
GBL_RESULT GblModule_use(GblModule *pSelf)
Manually increments the given module's usage count, loading it on first usage. You can manually contr...
#define GBL_OPTION_GROUP_TYPE
Type UUID for GblOptionGroup.
#define GBL_INT16_TYPE
Builtin ID for int16_t GblVariant type.
#define GBL_STRING_TYPE
Builtin ID for string GblVariant type.
#define GBL_UINT32_TYPE
Builtin ID for uint32_t GblVariant type.
#define GBL_PROPERTIES(object,...)
Declares a list of properties for the given object/instance structure.
#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)
uint16_t GblRefCount
Type able to hold a reference counter across the codebase.
uintptr_t GblQuark
Uniquely identifiable interned string type.
const char GblStringRef
Reference-counted, const char*-compatible string type.
uint32_t GblVersion
32-bit unsigned integer representing a packed version in the form (MAJOR.MINOR.PATCH)
Dynamically loadable service and associated meta types.
GblStringRef * pDescription
Description of a module.
GblStringRef * pAuthor
Author(s) of a module.
GblStringRef * pPrefix
Namespace prefix of a module.
GblOptionGroup * pOptionGroup
Command-line option handler of a module.
GblVersion version
Version of a module.