libGimbal 0.1.0
C17-Based Extended Standard Library and Cross-Language Runtime Framework
Loading...
Searching...
No Matches
GblInterface Struct Reference

#include <gimbal_interface.h>

Inheritance diagram for GblInterface:
GblClass GblIAllocatorClass GblIEventFilterClass GblIEventHandlerClass GblILoggerClass GblIPluginClass GblITableVariantClass GblIVariantClass GblArenaAllocatorClass GblContextClass GblObjectClass GblObjectClass GblContextClass GblModuleClass GblObjectClass GblBoxClass GblPrimitiveClass

Data Fields

GblClass base
 
size_t outerClassOffset_
 
- Data Fields inherited from GblClass
struct { 
 
   uintptr_t   metaClassInfo 
 
private_ 
 

Related Symbols

(Note that these are not member symbols.)

#define GBL_INTERFACE(klass)
 
#define GBL_INTERFACE_TRY(klass)
 
#define GBL_INTERFACE_OUTER_CLASS(iface)
 
#define GBL_INTERFACE_OUTER_MOST_CLASS(iface)
 
 GblInterface_outerClass (GblInterface *pSelf)
 
GblClassGblInterface_outerMostClass (GblInterface *pSelf)
 

Detailed Description

Base struct for all interfaces, inherits from GblClass.

An interface is a special type of GblClass which represents an abstract collection of data which may be "implemented" by another class and then queried for later. This data is typically in the form of function pointers, which may or may not have default values, which can then be set by a the class constructor of another type.

Note
Since a GblInterface inherits from GblClass, it is compatible with all of the methods associated with a GblClass, such as GblClass_check(), GblClass_cast(), and GblClass_as(). These are used to verify and query for GblInterface objects which are contained within a given GblClass.

The main advantage of modeling overriddable methods within an interface as opposed to just putting them within a class is that the interface can be implemented by any class, without having to inherit or derive from it.

GblInterface is the base structure which is to be inherited by all interface structures within the meta type system. This means placing it or a type "inheriting" from it as the first member of an interface struct, when using C.

typedef struct ICallableInterface {
GBL_RESULT (*pFnVCall)(ICallable* pSelf);
} ICallableInterface
GBL_RESULT
Base struct for all interfaces, inherits from GblClass.

In terms of implementation, a GblInterface is actually implemented as a type of mappable "subclass" which is then embedded within a the structure of a GblClass-inheriting structure. When a type which implements an interface is registered, its location within the class is provided to the type system via GblTypeInfo::pInterfaceImpls.

See also
GblClass, GblInstance, GblType

Definition at line 24 of file gimbal_interface.h.

Friends And Related Symbol Documentation

◆ GBL_INTERFACE

#define GBL_INTERFACE (   klass)
related

Convenience function-style cast operator that returns the given class as a GblInterface, provided it is actually one, erroring out upon failure.

Parameters
klasspointer to a GblClass or derived
Returns
GblInterface pointer or NULL if klass isn't one
See also
GBL_INTERFACE_TRY()

Definition at line 14 of file gimbal_interface.h.

◆ GBL_INTERFACE_TRY

#define GBL_INTERFACE_TRY (   klass)
related

Convenience function-style cast operator that returns the given class as a GblInterface, provided it is actually one.

Parameters
klasspointer to a GblClass or derived
Returns
GblInterface pointer or NULL if klass isn't one
See also
GBL_INTERFACE()

Definition at line 15 of file gimbal_interface.h.

◆ GBL_INTERFACE_OUTER_CLASS

#define GBL_INTERFACE_OUTER_CLASS (   iface)
related

Convenience macro wrapping GblInterface_outerClass(), automatically casting the input parameter.

Parameters
ifacepointer to a GblInterface or derived
Returns
GblClass pointer or NULL if it hasn't beenm mapped to one
See also
GblInterface_outerClass

Definition at line 16 of file gimbal_interface.h.

◆ GBL_INTERFACE_OUTER_MOST_CLASS

#define GBL_INTERFACE_OUTER_MOST_CLASS (   iface)
related

Convenience macro wrapping GblInterface_outerMostClass(), automatically casting the input parameter.

Parameters
ifacepointer to a GblInterface or derived
Returns
GblClass pointer or NULL if it hasn't beenm mapped to one
See also
GblInterface_outerMostClass

Definition at line 17 of file gimbal_interface.h.

◆ GblInterface_outerClass()

GblInterface_outerClass ( GblInterface pSelf)
related

Returns the GblClass implementing the given interface.

Note
If the specified interface is a default implementation, its own GblClass base is returned.
Parameters
pSelfinterface
Returns
GblClass pointer to the implementing class.
See also
GblClass_outerMost

◆ GblInterface_outerMostClass()

GblClass * GblInterface_outerMostClass ( GblInterface pSelf)
related

Returns the top-level GblClass implementing the interface.

The top-level class will either be its outer class, in the case of a regular embedded interface, or it could be multiple levels out, in the case of an interface mapping an interface.

Parameters
pSelfinterface
Returns
GblClass pointer to the top-most implementing class.
See also
GblClass_as

Field Documentation

◆ base

GblClass GblInterface::base

inherited GblClass base info

Definition at line 25 of file gimbal_interface.h.

◆ outerClassOffset_

size_t GblInterface::outerClassOffset_

offset from the interface to the class containing it (private, managed by internals)

Definition at line 26 of file gimbal_interface.h.


The documentation for this struct was generated from the following file: