|
libGimbal 0.2.0
C17-Based Extended Standard Library and Cross-Language Runtime Framework
|
Go to the source code of this file.
Data Structures | |
| struct | GblModuleClass |
| struct | GblModule |
Macros | |
| #define | GBL_REQUIRE(...) |
| #define | GBL_RELEASE(selfAddr) |
| #define | GBL_REQUIRE_SCOPE(...) |
Type System | |
Type UUID and cast operators. | |
| #define | GBL_MODULE_TYPE |
| #define | GBL_MODULE(self) |
| #define | GBL_MODULE_CLASS(klass) |
| #define | GBL_MODULE_CLASSOF(self) |
Typedefs | |
| typedef GblBool(* | GblModuleIterFn) (GblModule *pIt, void *pClosure) |
Functions | |
| GblType | GblModule_type (void) |
Registry | |
Static routines for querying the module registry. | |
| GblModule * | GblModule_find (const char *pName) |
| GblModule * | GblModule_findQuark (GblQuark name) |
| GblModule * | GblModule_at (size_t index) |
| size_t | GblModule_count (void) |
| GblBool | GblModule_iterate (GblModuleIterFn pFnIter, void *pCl) |
Opening and Closing | |
Routines for acquiring and releasing a module. | |
| GblModule * | GblModule_require (GblModule **ppSelf, const char *pName, const char *pVersion, const char *pFile, const char *pFunc, size_t line) |
| GblModule * | GblModule_requireQuark (GblModule **ppSelf, GblQuark name, const char *pVersion, const char *pFile, const char *pFunc, size_t line) |
| GBL_RESULT | GblModule_release (GblModule **ppModule) |
Lifetime | |
Methods for creating and destroying modules. | |
| GblModule * | GblModule_create (GblType derivedType, const char *pName, GblVersion version, const char *pAuthor, const char *pDescription, const char *pPrefix) |
| GblRefCount | GblModule_unref (GblModule *pSelf) |
Registration | |
Methods for adding and removing from the registry. | |
| GBL_RESULT | GblModule_register (GblModule *pSelf) |
| GBL_RESULT | GblModule_unregister (GblModule *pSelf) |
Loading/Unloading | |
Routines for controlling when a module is loaded and unloaded. | |
| GBL_RESULT | GblModule_use (GblModule *pSelf) |
| GBL_RESULT | GblModule_unuse (GblModule *pSelf) |
| GblRefCount | GblModule_useCount (const GblModule *pSelf) |
| GblBool | GblModule_isLoaded (const GblModule *pSelf) |
Dynamic module and plugin system.
This file contains the type declarations of GblModule and its associated API, providing the functionality of a static registry of lazily loaded "services" or C++ singleton types and their associated type registry.
Definition in file gimbal_module.h.
| #define GBL_MODULE_TYPE |
Type UUID for GblModule.
Definition at line 33 of file gimbal_module.h.
| #define GBL_MODULE | ( | self | ) |
Function-style GblInstance cast.
Definition at line 34 of file gimbal_module.h.
| #define GBL_MODULE_CLASS | ( | klass | ) |
Function-style GblClass cast.
Definition at line 35 of file gimbal_module.h.
| #define GBL_MODULE_CLASSOF | ( | self | ) |
Gets a GblModuleClass from GblInstance.
Definition at line 36 of file gimbal_module.h.
| #define GBL_REQUIRE | ( | ... | ) |
Macro directive for importing a module.
Used to "import" a GblModule whose type has been registered with the type system, lazily loading it the fist time and returning references to it subsequently.
| instanceStruct | Struct name for desired GblModule instance structure. |
| selfAddr | The address of a pointer to the instance to store the reference in. |
| name | Name of the module to import. |
| version | [optional] Major.minor.patch string for specific version. |
Definition at line 62 of file gimbal_module.h.
| #define GBL_RELEASE | ( | selfAddr | ) |
Macro directive for releasing a module.
Used to optionally "release" a module which has been previously imported, decrementing is "useCount" property, which causes the module to be dynamically unloaded upon hitting zero uses.
| selfAddr | The address of a pointer pointing to a module. |
Definition at line 77 of file gimbal_module.h.
| #define GBL_REQUIRE_SCOPE | ( | ... | ) |
Scoped macro directive for using a module.
Used to define a local scope in which a module will be imported upon entry and released upon exit.
| instanceStruct | Struct name for desired GblModule instance structure. |
| selfAddr | Address of a pointer to the GblModule struct, which holds the reference. |
| name | Name of the module to import. |
| version | [optional] Major.minor.patch string for specific version. |
Definition at line 100 of file gimbal_module.h.
Function callback used with GblModule_foreach() for iterating over active modules, returning GBL_TRUE to end iteration early.
Definition at line 110 of file gimbal_module.h.
| GblModule * GblModule_find | ( | const char * | pName | ) |
Returns a pointer to the module with the gibven name, if present, gracefully returning NULL otherwise.
Equivalent to GblModule_find(), except doing a faster search using a GblQuark for the name.
| 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 one.
| size_t GblModule_count | ( | void | ) |
Returns the total number of modules which have been registered.
| GblBool GblModule_iterate | ( | GblModuleIterFn | pFnIter, |
| void * | pCl ) |
Iterates over every registered module, invoking the provided iterator callback, optionally passing back an arbitrary userdata closure pointer.
| 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.
| 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.
| GBL_RESULT GblModule_release | ( | GblModule ** | ppModule | ) |
Manually decrements the given module's usage count, and points the passed.
| ppModule | to NULL. |
| 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 the registry.
| GblRefCount GblModule_unref | ( | GblModule * | pSelf | ) |
Releases a reference to a previously created GblModule instance, destructing and freeing it if there are no references left.
| GBL_RESULT GblModule_register | ( | GblModule * | pSelf | ) |
Attempts to register a previously instantiated GblModule instance as a globally importable module within the internal registry.
| GBL_RESULT GblModule_unregister | ( | GblModule * | pSelf | ) |
Attempts to unregister a previously registered GblModule instance, removing it from the internal registry.
| GBL_RESULT GblModule_use | ( | GblModule * | pSelf | ) |
Manually increments the given module's usage count, loading it on first usage. You can manually control its lifetimeto prevent being dynamically unloaded like this.
| GBL_RESULT GblModule_unuse | ( | GblModule * | pSelf | ) |
Manually decrements the given module's usage count, unloading it when the last user is done. You can manually control unloading it like this.
| GblRefCount GblModule_useCount | ( | const GblModule * | pSelf | ) |
Retrieves the current usage counter for the given module.