libGimbal 0.1.0
C17-Based Extended Standard Library and Cross-Language Runtime Framework
Loading...
Searching...
No Matches
gimbal_app.h
Go to the documentation of this file.
1/*! \file
2 * \brief GblApp top-level application object
3 * \ingroup core
4 *
5 * This file contains the class and instance definitions
6 * for GblApp. Currently a WIP.
7 *
8 * \todo
9 * - Finish me
10 * - add GblSettings
11 * \test
12 * - Test me
13 *
14 * \author 2023 Falco Girgis
15 * \copyright MIT License
16 */
17#ifndef GIMBAL_APP_H
18#define GIMBAL_APP_H
19
20#include "../meta/instances/gimbal_object.h"
21#include "../meta/signals/gimbal_signal.h"
22#include "../utils/gimbal_version.h"
23#include "../strings/gimbal_string_list.h"
24
25/*! \name Type System
26 * \brief Type UUID and cast operators
27 * @{
28 */
29#define GBL_APP_TYPE (GBL_TYPEID(GblApp)) //!< Type UUID for GblApp
30#define GBL_APP(self) (GBL_CAST(GblApp, self)) //!< Cast GblInstance to GblApp
31#define GBL_APP_CLASS(klass) (GBL_CLASS_CAST(GblApp, klass)) //!< Cast GblClass to GblAppClass
32#define GBL_APP_GET_CLASS(self) (GBL_CLASSOF(GblApp, self)) //!< Get GblAppClass from GblInstance
33//! @}
34
35#define GBL_SELF_TYPE GblApp
36
38
40
41/*! \struct GblAppClass
42 * \extends GblObjectClass
43 * \brief GblClass VTable structure for GblApp
44 *
45 * \todo Implement me.
46 *
47 * \sa GblApp
48 */
49GBL_CLASS_DERIVE(GblApp, GblObject)
50 //! Called for every event sent to any object in the application
51 GBL_RESULT (*pFnNotify)(GblObject* pReceiver, GblEvent* pEvent);
53
54/*! \struct GblApp
55 * \extends GblObject
56 * \ingroup core
57 * \brief Top-level per-program application instance
58 *
59 * \todo Implement me.
60 *
61 * \sa GblAppClass
62 */
64 const char** ppArgv;
65 size_t argc;
66 GblMainLoop* pLoop;
68
69//! \cond
70GBL_PROPERTIES(GblApp,
71 (argc, GBL_GENERIC, (READ, CONSTRUCT), GBL_UINT32_TYPE),
72 (argv, GBL_GENERIC, (READ, CONSTRUCT), GBL_POINTER_TYPE),
73 (libraryPaths, GBL_GENERIC, (READ, WRITE), GBL_STRING_TYPE),
74 (version, GBL_GENERIC, (READ, WRITE), GBL_UINT32_TYPE),
75 (organization, GBL_GENERIC, (READ, WRITE), GBL_STRING_TYPE),
76 (domain, GBL_GENERIC, (READ, WRITE), GBL_STRING_TYPE)
77)
78
79GBL_SIGNALS(GblApp,
80 (quitting, (GBL_INSTANCE_TYPE, pReceiver))
81)
82//! \endcond
83
84
85/*! \name Static Methods
86 * \brief Methods that operate on static global state
87 * @{
88 */
89//! Returns the GblType UUID associated with the GblApp type
91//! Returns a pointer to the current application instance (or NULL if not instantiated)
93//! Returns GBL_TRUE if the GblApp instance is being initialized or constructed, GBL_FALSE otherwise
95//! Returns GBL_TRUE if the GblApp instance is being deinitialized or destructed, GBL_FALSE otherwise
97//! Adds \p pPath to the list of search paths for dynamic libraries and modules
99//! Returns a GblStringList containing the list of search paths for dynamic libraries and modules
102//! @}
103
104/*! \name Instance Methods
105 * \brief Methods which operate on a GblApp instance
106 * \relatesalso GblApp
107 * @{
108 */
109//! Creates a GblApp instance with the given command-line arguments, returning a pointer to it
110GBL_EXPORT GblApp* GblApp_create (int argc,
111 const char** ppArgv) GBL_NOEXCEPT;
112//! Decrements the refcount of a GblApp instance, destroying it if it is the last one
114//! Returns the version associated with the GblApp instance
116//! Returns the organization string associated with the GblApp instance
118//! Returns the domain string associated with the GblApp instance
120//! Returns a GblStringList containing all command-line arguments as individual strings
123//! Top-level execution function for a GblApp--blocks until execution is complete, returning a result code
125//! Terminates an application abruptly, without signalling "quitting"
127//! Terminates an application gracefully, emitting the "quitting" signal and doing any cleanup
129//! @}
130
132
133#undef GBL_SELF_TYPE
134
135#endif // GIMBAL_APP_H
void GblApp_addLibraryPath(const char *pPath)
Adds pPath to the list of search paths for dynamic libraries and modules.
const GblStringList * GblApp_libraryPaths(void)
Returns a GblStringList containing the list of search paths for dynamic libraries and modules.
GblApp * GblApp_instance(void)
Returns a pointer to the current application instance (or NULL if not instantiated)
GblType GblApp_type(void)
Returns the GblType UUID associated with the GblApp type.
GblBool GblApp_startingUp(void)
Returns GBL_TRUE if the GblApp instance is being initialized or constructed, GBL_FALSE otherwise.
GblBool GblApp_closingDown(void)
Returns GBL_TRUE if the GblApp instance is being deinitialized or destructed, GBL_FALSE otherwise.
#define GBL_CLASS_CAST(cType, klass)
#define GBL_NOEXCEPT
#define GBL_DECLS_BEGIN
#define GBL_FORWARD_DECLARE_STRUCT(S)
#define GBL_TYPEID(instanceStruct)
#define GBL_INSTANCE_DERIVE(derivedInstance, baseInstance)
#define GBL_CLASS_DERIVE(...)
#define GBL_INSTANCE_END
#define GBL_EXPORT
#define GBL_CLASS_END
#define GBL_CLASSOF(cType, self)
#define GBL_CAST(cType, self)
#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,...)
uint8_t GblBool
Basic boolean type, standardized to sizeof(char)
uint16_t GblRefCount
Type able to hold a reference counter across the codebase.
#define GBL_POINTER_TYPE
uintptr_t GblType
Meta Type UUID.
Definition gimbal_type.h:51
GblRingList GblStringList
List of strings with array-like API.
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)
Top-level per-program application instance.
Definition gimbal_app.h:63
GBL_RESULT GblApp_quit(GblApp *pSelf, int retVal)
Terminates an application gracefully, emitting the "quitting" signal and doing any cleanup.
const GblStringList * GblApp_argList(const GblApp *pSelf)
Returns a GblStringList containing all command-line arguments as individual strings.
GBL_RESULT GblApp_exit(GblApp *pSelf, int retVal)
Terminates an application abruptly, without signalling "quitting".
GblApp * GblApp_create(int argc, const char **ppArgv)
Creates a GblApp instance with the given command-line arguments, returning a pointer to it.
GBL_RESULT GblApp_exec(GblApp *pSelf)
Top-level execution function for a GblApp–blocks until execution is complete, returning a result code...
GblStringRef * GblApp_domain(const GblApp *pSelf)
Returns the domain string associated with the GblApp instance.
GblRefCount GblApp_unref(GblApp *pSelf)
Decrements the refcount of a GblApp instance, destroying it if it is the last one.
GblVersion GblApp_version(const GblApp *pSelf)
Returns the version associated with the GblApp instance.
GblStringRef * GblApp_organization(const GblApp *pSelf)
Returns the organization string associated with the GblApp instance.