Lumiera 0.pre.04~rc.1
»edit your freedom«
Loading...
Searching...
No Matches
interface.c File Reference

Implementation: handling of interfaces (extension points). More...

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 LumieraInterfacenode lumiera_interface_open_interfacenode (LumieraInterfacenode self)
 
static void lumiera_interfacenode_close (LumieraInterfacenode self)
 
LumieraInterface lumiera_interface_open (const char *interface, unsigned version, size_t minminorversion, const char *name)
 Open an interface by version and name.
 
static void push_dependency (LumieraInterfacenode parent, LumieraInterfacenode child)
 
static void depwalk (LumieraInterfacenode self, LumieraInterfacenode *stack)
 
void lumiera_interface_close (LumieraInterface self)
 Close an interface after use.
 
unsigned lumiera_interface_version (LumieraInterface self, const char *iname)
 Runtime check for interface type and version.
 
 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_destroy (void)
 deregistering implementations of the above interface
 

Variables

LumieraInterface lumiera_interface_interface
 the mother of all interfaces
 

Function Documentation

◆ lumiera_interface_open_interfacenode()

static LumieraInterfacenode lumiera_interface_open_interfacenode ( LumieraInterfacenode  self)
static

Definition at line 154 of file interface.c.

References depwalk(), lumiera_interface_interface, lumiera_interface_mutex, lumiera_plugin_refinc(), LUMIERA_RECMUTEX_SECTION, NULL, and push_dependency().

Referenced by lumiera_interface_open().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lumiera_interfacenode_close()

static void lumiera_interfacenode_close ( LumieraInterfacenode  self)
static

Definition at line 249 of file interface.c.

References lumiera_interfacenode_close(), lumiera_plugin_refdec(), and NULL.

Referenced by lumiera_interface_close(), and lumiera_interfacenode_close().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ 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.

References lumiera_interface_mutex, lumiera_interface_open_interfacenode(), lumiera_interfaceregistry_interfacenode_find(), LUMIERA_RECMUTEX_SECTION, and NULL.

Referenced by LUMIERA_EXPORT(), and lumiera::anonymous_namespace{instancehandle.hpp}::register_and_open().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ push_dependency()

static void push_dependency ( LumieraInterfacenode  parent,
LumieraInterfacenode  child 
)
static

Definition at line 82 of file interface.c.

References lumiera_calloc(), and lumiera_realloc().

Referenced by lumiera_interface_open_interfacenode().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ depwalk()

static void depwalk ( LumieraInterfacenode  self,
LumieraInterfacenode stack 
)
static

Definition at line 115 of file interface.c.

References depwalk(), lumiera_plugin_refinc(), and NULL.

Referenced by depwalk(), and lumiera_interface_open_interfacenode().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ 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_interface_mutex, lumiera_interfacenode_close(), lumiera_interfaceregistry, LUMIERA_RECMUTEX_SECTION, and psplay_find().

Referenced by InstanceHandle< I, FA >::~InstanceHandle(), lumiera_interface_destroy(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), testrelease_four(), testrelease_one(), testrelease_three(), and testrelease_two().

+ Here is the call graph for this function:
+ 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.

Referenced by lumiera_plugin_register().

+ Here is the caller graph for this function:

◆ LUMIERA_EXPORT()

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.

Definition at line 309 of file interface.c.

References lumiera_interface_interface, lumiera_interface_open(), and LUMIERA_INTERFACE_REGISTEREXPORTED.

+ Here is the call graph for this function:

◆ lumiera_interface_destroy()

void lumiera_interface_destroy ( void  )

deregistering implementations of the above interface

Definition at line 334 of file interface.c.

References lumiera_interface_close(), lumiera_interface_interface, and LUMIERA_INTERFACE_UNREGISTEREXPORTED.

Referenced by lumiera_interfaceregistry_destroy().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ lumiera_interface_interface

LumieraInterface lumiera_interface_interface

the mother of all interfaces

Definition at line 39 of file interface.c.

Referenced by LUMIERA_EXPORT(), lumiera_interface_destroy(), and lumiera_interface_open_interfacenode().