libGimbal 0.1.0
C17-Based Extended Standard Library and Cross-Language Runtime Framework
Loading...
Searching...
No Matches
gimbal_library.h
Go to the documentation of this file.
1/*! \file
2 * \brief GblLibrary, dynamically linked library management
3 * \ingroup core
4 *
5
6 *
7 * \author 2023 Falco Girgis
8 * \copyright MIT License
9 */
10#ifndef GIMBAL_LIBRARY_H
11#define GIMBAL_LIBRARY_H
12
13#include "../strings/gimbal_string_list.h"
14
15#define GBL_SELF_TYPE GblLibrary
16
18
19/*! \struct GblLibrary
20 * \brief Opaque shared library structure
21 * \ingroup core
22 *
23 * GblLibrary is an opaque, reference-counted structure representing a dynamically-
24 * linked library, such as a .DLL or .so. Libraries are requested by name, using
25 * GblLibrary_open(), which will either:
26 * a. Search for the library by name within the list of search paths
27 * b. Return a reference to the library if it was already open
28 */
30
31//! Iterator function for use with GblLibrary_foreach(), exits early when GBL_TRUE is returned
32typedef GblBool (*GblLibraryIterFn)(GblLibrary* pSelf, void* pClosure);
33
34/*! \name Static API
35 * \brief Methods for search paths and iteration
36 * @{
37 */
38//! Returns the list of paths which are searched when attempting to load a library by name with GblLibrary_open()
41//! Adds \p pPath to the list of paths to search when loading a library by name with GblLibrary_open()
43//! Returns the total number of open dynamic libraries
45//! Returns the open dynamic library at the given \p index
46GBL_EXPORT GblLibrary* GblLibrary_at (size_t index) GBL_NOEXCEPT;
47//! Iterates over each open dynamic library, calling \p pFnInit with the given userdata
48GBL_EXPORT GblBool GblLibrary_foreach (GblLibraryIterFn pFnIt, void* pCl) GBL_NOEXCEPT;
49//! @}
50
51/*! \name Loading and Unloading
52 * \brief Methods for querying dynamic libraries and symbols
53 * \relatesalso GblLibrary
54 * @{
55 */
56//! Returns a reference to the library with the given file name, opening it if it wasn't already opened
57GBL_EXPORT GblLibrary* GblLibrary_open (const char* pName) GBL_NOEXCEPT;
59GBL_EXPORT GblPtr GblLibrary_symbol (GBL_CSELF, const char* pName) GBL_NOEXCEPT;
60//! @}
61
62/*! \name Accessors
63 * \brief Methods for reading and writing properties
64 * \relatesalso GblLibrary
65 * @{
66 */
69GBL_EXPORT GblRefCount GblLibrary_refCount (GBL_CSELF) GBL_NOEXCEPT;
70GBL_EXPORT GblBool GblLibrary_resident (GBL_CSELF) GBL_NOEXCEPT;
71GBL_EXPORT void GblLibrary_makeResident (GBL_SELF) GBL_NOEXCEPT;
72//! @}
73
75
76#endif // GIMBAL_LIBRARY_H
#define GBL_NOEXCEPT
#define GBL_DECLS_BEGIN
#define GBL_FORWARD_DECLARE_STRUCT(S)
#define GBL_EXPORT
void GblLibrary_addSearchPath(const char *pPath)
Adds pPath to the list of paths to search when loading a library by name with GblLibrary_open()
size_t GblLibrary_count(void)
Returns the total number of open dynamic libraries.
GblLibrary * GblLibrary_at(size_t index)
Returns the open dynamic library at the given index.
GblBool GblLibrary_foreach(GblLibraryIterFn pFnIt, void *pCl)
Iterates over each open dynamic library, calling pFnInit with the given userdata.
const GblStringList * GblLibrary_searchPaths(void)
Returns the list of paths which are searched when attempting to load a library by name with GblLibrar...
uint8_t GblBool
Basic boolean type, standardized to sizeof(char)
uint16_t GblRefCount
Type able to hold a reference counter across the codebase.
GblRingList GblStringList
List of strings with array-like API.
const char GblStringRef
Reference-counted, const char*-compatible string type.
GblLibrary * GblLibrary_open(const char *pName)
Returns a reference to the library with the given file name, opening it if it wasn't already opened.