2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20#ifndef GIMBAL_MODULE_H
21#define GIMBAL_MODULE_H
23#include "../meta/instances/gimbal_context.h"
24#include "../meta/ifaces/gimbal_iplugin.h"
25#include "../strings/gimbal_string_ref.h"
26#include "../utils/gimbal_version.h"
27#include "../utils/gimbal_option_group.h"
30
31
32
34#define GBL_MODULE(self) GBL_CAST
(GblModule, self)
35#define GBL_MODULE_CLASS(klass) GBL_CLASS_CAST
(GblModule, klass)
36#define GBL_MODULE_CLASSOF(self) GBL_CLASSOF
(GblModule, self)
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62#define GBL_REQUIRE( ...) GBL_REQUIRE_
(__VA_ARGS__)
65
66
67
68
69
70
71
72
73
74
75
76
77#define GBL_RELEASE(selfAddr) GBL_RELEASE_
(selfAddr)
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100#define GBL_REQUIRE_SCOPE( ...) GBL_REQUIRE_SCOPE_
(__VA_ARGS__)
102#define GBL_SELF_TYPE GblModule
110typedef GblBool (*GblModuleIterFn)(GblModule* pIt,
void* pClosure);
113
114
115
116
117
118
119
120
121
122
123
130
131
132
133
134
135
136
137
138
139
140
141
142
143
157 (description, GBL_GENERIC, (READ, WRITE, LOAD, SAVE),
GBL_STRING_TYPE),
172
173
174
189
190
191
195 const char* pVersion,
202 const char* pVersion,
211
212
213
219 const char* pDescription,
226
227
228
236
237
238
253#define GBL_REQUIRE_(...)
254 GBL_REQUIRE_DEFAULT_
(__VA_ARGS__)
255#define GBL_REQUIRE_DEFAULT_(...)
256 GBL_REQUIRE_DEFAULT__
(__VA_ARGS__, NULL)
257#define GBL_REQUIRE_DEFAULT__(type, pPtr, name, version, ...)
258 GBL_AS
(type, (GblModule_require(
259 (GblModule**)pPtr, name, version,
260 __FILE__, __func__, __LINE__)))
262#define GBL_RELEASE_(pPtr)
263 (GblModule_release((GblModule**)pPtr))
265#define GBL_REQUIRE_SCOPE_(...)
266 GBL_REQUIRE_SCOPE_DEFAULT_
(__VA_ARGS__)
267#define GBL_REQUIRE_SCOPE_DEFAULT_(...)
268 GBL_REQUIRE_SCOPE_DEFAULT__
(__VA_ARGS__, NULL)
269#define GBL_REQUIRE_SCOPE_DEFAULT__(type, pPtr, name, version, ...)
270 GBL_SCOPE(GBL_REQUIRE_DEFAULT__
(type, pPtr, name, version), GBL_RELEASE_
(pPtr))
272#define GblModule_iterate(...)
273 GblModule_iterateDefault_
(__VA_ARGS__)
274#define GblModule_iterateDefault_(...)
275 GblModule_iterateDefault__
(__VA_ARGS__, NULL)
276#define GblModule_iterateDefault__(iter, cl, ...)
277 (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_SCOPE(begin, end)
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...
GblModule * GblModule_require(GblModule **ppSelf, const char *pName, const char *pVersion, const char *pFile, const char *pFunc, size_t line)
Underlying method backing GBL_REQUIRE() macro, which should be used instead of calling this directly.
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...
GBL_RESULT GblModule_release(GblModule **ppModule)
Manually decrements the given module's usage count, and points the passed.
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.
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...
GblModule * GblModule_requireQuark(GblModule **ppSelf, 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.
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.