company logo

EnumeratorDefinition - Enumerator instance (category)

The enumerator consists of an identifier as category name, an enumerator value and an optional object type (structure) for the category. Since Enumerations in ODABA support hierarchies (hierarchical classifications), enumerators may contain a list of subcategories (enumerators).

When no enumerator values are defined, the values are created automatically according to the position of the instance in the enumeration list.

An enumerator may refer to a list of sub items. Enumerator values in the hierarchy must be unique. When the enumerator is typed, all subcategories must refer to the same type or specializations to the type.

Enumerators can be linked with multilingual definition topics, which allow defining label and definitions in different languages.

Multilingual enumerator support

In principle, multilingual support is provided for enumerators. Thus, displayName , title and description can be provided in several languages. Since internal dictionary images from enumerators support only one default language (according to the option settings in DSC_Language ), multilingual enumerator support requires reading resources directly from the dictionary database. In order to provide textual information in a certain language, the DSC_Language option has to be set before reading to the language required.

// read value descriptions from dictionary database

// (fragment)

  String   oldLanguage(option("DSC_Language"));

  optionSet("DSC_Language","German"); // set documentation language

try {

  Property  enum_ph(dict,"SDB_Value");

  Property  evals(enum_ph,"values"); // all values

  Property  topic(evals,"resource_ref(0).definition");

  Value     title(topic,"name");

  Value     label(topic,"label");

  Value     characteristic(topic,"definition.characteristic");

  enum_ph.get("AccessModes|0");

  while ( evals.next() )

    output(label.toString() + "(" +title.toString() + "): " +

           characteristic.toString();

} catch ( ... )

// handle exceptions

}

  optionSet("DSC_Language",oldLanguage); // reset original language

Hierarchical enumerations

ODABA supports hierarchical enumerations, i.e. each category (enumerator) may get any number of subcategories. Internally, the hierarchical view to enumerators will be provided, i.e. each enumeration definition provides a list with the top level enumerators and each enumerator provides a list with subcategories.

Within the dictionary, enumerations are provided as SDB_ValueList , which contain a list with all enumerator instances ( values ) as well as a list with top categories ( top_values ), where each category may have got a number of subcategory values ( sub_values )

// read categories recursively

// (fragment)

try {

  Property  enum_ph(dict,"SDB_Value");

  Property  evals(enum_ph,"top_values"); // top categories

  enum_ph.get("_OptOptions|0");

  while ( evals.next() )

    displayCategory(evals,0);

} catch ( ... )

// handle exceptions

}

  optionSet("DSC_Language",oldLanguage); // reset original language

// display catagory and sub-categories

void displayCategory(Property &eval, int level) {

  Property  evals(eval,"sub_values"); // sub-categories

try {

  output(sys_ident.toString() + "(" +level + ")");

  while ( evals.next() )

    displayCategory(evals,0);

} catch ( ... )

// handle exceptions

}

}

Attributes
    Function Groups
    Functions