DIPlib Documentation - ©1995-2009 Quantitative Imaging Group, Delft University of Technology.

# Register

Generic registry function

## SYNOPSIS

`#include "dip_registry.h"`

dip_Error dip_Register ( register )

## FUNCTION

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 and 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 userfriendly to use class specific Registry functions like `MsrRegister` 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_MsrRegister
    (
       dip_MsrRegistry registry
    )
    {
       DIP_FN_DECLARE("dip_MsrRegister");
       dip_Registry globalRegistry;
       void *data;
       dip_MsrRegistry *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;
       }
       /* copy the Msr specific registry info */
       DIPXJ( dip_MemoryNew( &data, sizeof( dip_MsrRegistry ), 0 ));
       reg  = data;
       *reg = registry;

       globalRegistry.id       = registry.id;
       globalRegistry.class    = DIP_REGISTRY_CLASS_MEASUREMENT;
       globalRegistry.registry = reg;

       /* register this measurement registry data */
       DIPXJ( dip_Register( globalRegistry ));

    dip_error:
       DIP_FN_EXIT;
    }

## ARGUMENTS

Data type | Name | Description
`dip_Registry` | `registry` | Generic registry structure

## SEE ALSO

`Unregister`, `RegisterClass`, `RegistryList`, `RegistryGet`, `RegistryValid`, `RegistryArrayNew`

DIPlib on-line documentation | Function reference | Global function index