Home You are here: Home > Support > Reference v1.0

Change language: German


The Handling of enumerations is part the exom core to be able to use them in a user interface and enable de-/serialisation of them in a generic way. Therefor enumerations are represented by an instance of exom::XmEnumList. Each enumeration item is represented by an item within this container. This container provide a mapping from the integer id to is textual identifier and vice versa. Using this technique give applications the possibility to use enumerations in the common C++ manner.

For example a simple color enumeration can be implemented by defining a class:

class Color : public exom::XmEnumList
    enum e
        black               = 0,
        white               = 1,
    Color() : XmEnumList ("color")
        AddEnum (black,               "black");
        AddEnum (white,               "white");

const Color g_Color;

Alternatively enumerations can be implemented without defining a new class, just using a simple instance of exom::XmEnumList.

Using enumerations

To give the framework the posibility to handle them, enumerations have to be attached with exom::XmMan::manEnum() within exom::XmObject::manage(). This will be done in following example with the Color enumeration defined above.

class MyClass : public XmObject
    Color::e  Color;

    // --- XmObject ---
    void      manage (XmMan& m)
        m.manEnum((int&)Color, myns.ATM_COLOR, g_Color);

Localized names

Especially in GUI's is becomes necessary to use enumerations with their localized names. To give the framework the possibility to do this, the enumeration container have to be registered before using. Otherwise their text identifier will be used. The localization of the enumerations are stored, within the <enumerations> section in the info file (exom::XmModuleInfo).

    XmEnumListMan::RegisterEnumList (g_Color);

The localized names are mapped to the text identifier of the enum items. Here an exration of the info file, showing the localisation:

        <enumList name = "color">
                    id = "black"
                    name = "Black"/>
                    id = "white"
                    name = "White"/>

Note: The serialisation of the enumerations (e.g. XML) is language independent. The above mentioned textual identifier will be used, which will be defined in exom::XmEnumList::AddEnum().

Copyright © 2006 Praetz Software Development - www.exomware.com