Libmacro  0.2
Libmacro is an extensible macro and hotkey library.
iregistry.h File Reference

mcr_IRegistry Register mcr_Interface instances as id, names, and a reference. More...

Go to the source code of this file.

Classes

struct  mcr_IRegistry
 

Functions

MCR_API int mcr_register (struct mcr_IRegistry *iRegPt, struct mcr_Interface *interfacePt, const char *name, const char *const *addNames, size_t addNamesCount)
 
MCR_API void mcr_unregister (struct mcr_IRegistry *iRegPt, struct mcr_Interface *interfacePt)
 
MCR_API void mcr_IRegistry_init (struct mcr_IRegistry *iRegPt)
 
MCR_API void mcr_IRegistry_deinit (struct mcr_IRegistry *iRegPt)
 
MCR_API size_t mcr_IRegistry_id (const struct mcr_IRegistry *iRegPt, struct mcr_Interface *interfacePt)
 
MCR_API struct mcr_Interfacemcr_IRegistry_from_id (const struct mcr_IRegistry *iRegPt, size_t typeId)
 
MCR_API const char * mcr_IRegistry_name (const struct mcr_IRegistry *iRegPt, struct mcr_Interface *interfacePt)
 
MCR_API struct mcr_Interfacemcr_IRegistry_from_name (const struct mcr_IRegistry *iRegPt, const char *name)
 
MCR_API const char * mcr_IRegistry_id_name (const struct mcr_IRegistry *iRegPt, size_t id)
 
MCR_API size_t mcr_IRegistry_name_id (const struct mcr_IRegistry *iRegPt, const char *name)
 
MCR_API int mcr_IRegistry_set_name (struct mcr_IRegistry *iRegPt, struct mcr_Interface *interfacePt, const char *name)
 
MCR_API int mcr_IRegistry_add_name (struct mcr_IRegistry *iRegPt, struct mcr_Interface *interfacePt, const char *name)
 
MCR_API int mcr_IRegistry_add_names (struct mcr_IRegistry *iRegPt, struct mcr_Interface *interfacePt, const char *const *addNames, size_t addNamesCount)
 
MCR_API size_t mcr_IRegistry_count (const struct mcr_IRegistry *iRegPt)
 
MCR_API void mcr_IRegistry_trim (struct mcr_IRegistry *iRegPt)
 
MCR_API void mcr_IRegistry_clear (struct mcr_IRegistry *iRegPt)
 

Detailed Description

mcr_IRegistry Register mcr_Interface instances as id, names, and a reference.

Definition in file iregistry.h.

Function Documentation

§ mcr_IRegistry_add_name()

MCR_API int mcr_IRegistry_add_name ( struct mcr_IRegistry iRegPt,
struct mcr_Interface interfacePt,
const char *  name 
)

Add a mapping from name to interface.

Parameters
interfacePtInterface to map to
nameopt Name to map from
Returns
reterr

§ mcr_IRegistry_add_names()

MCR_API int mcr_IRegistry_add_names ( struct mcr_IRegistry iRegPt,
struct mcr_Interface interfacePt,
const char *const *  addNames,
size_t  addNamesCount 
)

mcr_reg_add_name for all given names

Parameters
interfacePtInterface to map to
namesopt Array of names to map from
bufferLenNumber of elements to use in names
Returns
reterr

§ mcr_IRegistry_clear()

MCR_API void mcr_IRegistry_clear ( struct mcr_IRegistry iRegPt)

Remove all registered interfaces.

§ mcr_IRegistry_count()

MCR_API size_t mcr_IRegistry_count ( const struct mcr_IRegistry iRegPt)

Get the number of registered interfaces.

Parameters
iRegPt
Returns
retind

§ mcr_IRegistry_deinit()

MCR_API void mcr_IRegistry_deinit ( struct mcr_IRegistry iRegPt)

dtor

Parameters
regPtopt
Returns
reterr

§ mcr_IRegistry_from_id()

MCR_API struct mcr_Interface* mcr_IRegistry_from_id ( const struct mcr_IRegistry iRegPt,
size_t  typeId 
)

Get a reference to the interface of the same id.

Parameters
iRegPtopt
typeIdId of interface
Returns
Interface of given id, or null if not found

§ mcr_IRegistry_from_name()

MCR_API struct mcr_Interface* mcr_IRegistry_from_name ( const struct mcr_IRegistry iRegPt,
const char *  name 
)

Get a reference to the interface from its registered name.

Parameters
iRegPtopt
typeNameopt Name of interface
Returns
Interface of given name, or null if not found

§ mcr_IRegistry_id_name()

MCR_API const char* mcr_IRegistry_id_name ( const struct mcr_IRegistry iRegPt,
size_t  id 
)

Get the name of the interface of given id, or null if not found.

Parameters
iRegPtopt
idId of the interface
Returns
Name of the interface, or null if not found

§ mcr_IRegistry_init()

MCR_API void mcr_IRegistry_init ( struct mcr_IRegistry iRegPt)

ctor

Parameters
regPtopt

§ mcr_IRegistry_name_id()

MCR_API size_t mcr_IRegistry_name_id ( const struct mcr_IRegistry iRegPt,
const char *  name 
)

Get the id of the interface of given name.

Parameters
iRegPtopt
nameName of the interface
Returns
retid

§ mcr_IRegistry_set_name()

MCR_API int mcr_IRegistry_set_name ( struct mcr_IRegistry iRegPt,
struct mcr_Interface interfacePt,
const char *  name 
)

Map a name to an interface, and the interface to that name.

Parameters
interfacePtopt Interface to map
nameopt Name to map
Returns
reterr

§ mcr_IRegistry_trim()

MCR_API void mcr_IRegistry_trim ( struct mcr_IRegistry iRegPt)

Minimize allocation

§ mcr_register()

MCR_API int mcr_register ( struct mcr_IRegistry iRegPt,
struct mcr_Interface interfacePt,
const char *  name,
const char *const *  addNames,
size_t  addNamesCount 
)

Register a new interface. The interface id will be set as the next possible id to be registered. If names are provided, also mcr_reg_set_name, mcr_reg_add_names

Parameters
interfacePtThe new interface to register
nameopt Name to map to and from newType
addNamesopt Set of additional names to map to newType
bufferLenNumber of names to map in addNames, required if addNames is to be used
Returns
reterr

§ mcr_unregister()

MCR_API void mcr_unregister ( struct mcr_IRegistry iRegPt,
struct mcr_Interface interfacePt 
)

Unregister an interface from this registry.

Remove all id's, names, and references to the interface.