Lumiera  0.pre.03
»edit your freedom«
interface.c File Reference

Go to the source code of this file.

Description

Implementation: handling of interfaces (extension points).

From a programmers perspective interfaces only need to be opened when needed and closed when finished with them. There is no difference if the interface is internally provided by the core or provided by an external plugin. Interfaces can be opened multiple times and cross reference each other.

Definition in file interface.c.

#include "include/logging.h"
#include "lib/recmutex.h"
#include "lib/safeclib.h"
#include "common/plugin.h"
#include "common/interface.h"
#include "common/interfaceregistry.h"
#include <nobug.h>

Functions

static void depwalk (LumieraInterfacenode self, LumieraInterfacenode *stack)
 
 LUMIERA_EXPORT (LUMIERA_INTERFACE_DEFINE(lumieraorg_interface, 0, lumieraorg_interface, NULL, NULL, NULL, LUMIERA_INTERFACE_MAP(open, lumiera_interface_open), LUMIERA_INTERFACE_MAP(close, lumiera_interface_close), LUMIERA_INTERFACE_MAP(version, lumiera_interface_version),))
 Definition of 'the mother of all interfaces' since this interface is singleton and required for any component to open any other interface this should get a very stable interface and likely never change.
 
void lumiera_interface_close (LumieraInterface self)
 Close an interface after use. More...
 
void lumiera_interface_destroy (void)
 deregistering implementations of the above interface
 
LumieraInterface lumiera_interface_open (const char *interface, unsigned version, size_t minminorversion, const char *name)
 Open an interface by version and name. More...
 
static LumieraInterfacenode lumiera_interface_open_interfacenode (LumieraInterfacenode self)
 
unsigned lumiera_interface_version (LumieraInterface self, const char *iname)
 Runtime check for interface type and version. More...
 
static void lumiera_interfacenode_close (LumieraInterfacenode self)
 
static void push_dependency (LumieraInterfacenode parent, LumieraInterfacenode child)
 

Variables

LumieraInterface lumiera_interface_interface
 the mother of all interfaces
 

Function Documentation

◆ lumiera_interface_open()

LumieraInterface lumiera_interface_open ( const char *  interface,
unsigned  version,
size_t  minminorversion,
const char *  name 
)

Open an interface by version and name.

Looks up the requested interface, possibly loading it from a plugin.

Parameters
interfacename of the interface definition
versionmajor version of the interface definition
minminorversionrequired minor version (structure size)
namename of the interface implementation
Returns
the queried interface handle on success, else NULL

Definition at line 49 of file interface.c.

◆ lumiera_interface_close()

void lumiera_interface_close ( LumieraInterface  self)

Close an interface after use.

Parameters
selfinterface to be closed consider 'self' to be invalidated after this call

Definition at line 226 of file interface.c.

References LUMIERA_RECMUTEX_SECTION.

Referenced by lumiera_interface_destroy().

+ Here is the caller graph for this function:

◆ lumiera_interface_version()

unsigned lumiera_interface_version ( LumieraInterface  self,
const char *  iname 
)

Runtime check for interface type and version.

Parameters
selfinterface to check
inamename of the interface
Returns
version of the interface or ~0 (-1) if iname doesn't match the requested name

Definition at line 238 of file interface.c.