Generic registry function
#include "dip_registry.h"
dip_Error dip_Register ( register )
The Registry functions Register, Unregister, RegisterClass, RegistryList, RegistryGet RegistryValid and RegistryArrayNew are the access functions for DIPlib's generic registry framework. These functions control the access to a registry containing information of items that are registered at run-time. Each item belongs to a certain class and is identified with an ID that is unique within the item's class.
DIPlib's Registry classes are registered at run-time as well (using RegisterClass) and should be registered before an item of that class can registered.
Although the generic Registry functions can be used to register, and obtain the data of registered items of a specific clas, it is more user friendly to use class-specific Registry functions like MeasurementFeatureRegister and companions.
The dip_Register function accepts one argument, a dip_Registry structure, which contains the ID and class of the to be registered data and registry, a pointer to class-specific data. Note that this pointer, registry, is freed when the (global) registry information is freed.
The following code gives an example of a class-specific register function:
dip_Error dip_MeasurementFeatureRegister ( dip_MeasurementFeatureRegistry registry ) { DIP_FN_DECLARE("dip_MeasurementFeatureRegister"); dip_Registry globalRegistry; void *data; dip_MeasurementFeatureRegistry *reg; switch( registry.type ) { default: DIPSJ( DIP_E_REGISTRY_INCOMPLETE_REGISTRY ); break; case DIP_MSR_FUNCTION_LINE_BASED: DIPTS( ! ( registry.create && registry.measure.line && registry.value && registry.labels && registry.description ), DIP_E_REGISTRY_INCOMPLETE_REGISTRY ); break; case DIP_MSR_FUNCTION_IMAGE_BASED: DIPTS( ! ( registry.create && registry.measure.image && registry.value && registry.labels && registry.description ), DIP_E_REGISTRY_INCOMPLETE_REGISTRY ); break; case DIP_MSR_FUNCTION_CHAINCODE_BASED: DIPTS( ! ( registry.create && registry.measure.chaincode && registry.value && registry.labels && registry.description ), DIP_E_REGISTRY_INCOMPLETE_REGISTRY ); break; case DIP_MSR_FUNCTION_COMPOSITE: DIPTS( ! ( registry.create && registry.measure.composite && registry.value && registry.convert && registry.description ), DIP_E_REGISTRY_INCOMPLETE_REGISTRY ); break; } /* copy the Measurement specific registry info */ DIPXJ( dip_MemoryNew( &data, sizeof( dip_MeasurementFeatureRegistry ), 0 )); reg = ( dip_MeasurementFeatureRegistry * ) data; *reg = registry; globalRegistry.id = registry.id.rtid; globalRegistry.class = DIP_REGISTRY_CLASS_MEASUREMENT; globalRegistry.registry = reg; globalRegistry.free = dip_MemoryFree; /* register this measurement registry data */ DIPXJ( dip_Register( globalRegistry )); dip_error: DIP_FN_EXIT; }
Data type | Name | Description |
dip_Registry | registry | Generic registry structure |
Unregister, RegisterClass, RegistryList, RegistryGet, RegistryValid, RegistryArrayNew