SoSFEnum.3coin2

Langue: en

Version: 373136 (fedora - 01/12/10)

Section: 3 (Bibliothèques de fonctions)

Sommaire

NAME

SoSFEnum -

The SoSFEnum class is a container for an enum value.

This field is used where nodes, engines or other field containers needs to store one particular value out of an enumerated set.

SYNOPSIS


#include <Inventor/fields/SoSFEnum.h>

Inherits SoSField.

Inherited by SoSFBitMask.

Public Member Functions


virtual SoType getTypeId (void) const

virtual void copyFrom (const SoField &field)

const SoSFEnum & operator= (const SoSFEnum &field)

virtual SbBool isSame (const SoField &field) const

int getValue (void) const

void setValue (int newvalue)

int operator= (int newvalue)

int operator== (const SoSFEnum &field) const

int operator!= (const SoSFEnum &field) const

void setValue (const SbName name)

void setEnums (const int num, const int *vals, const SbName *names)

int getNumEnums (void) const

int getEnum (const int idx, SbName &name) const

Static Public Member Functions


static void * createInstance (void)

static SoType getClassTypeId (void)

static void initClass (void)

Protected Member Functions


virtual SbBool findEnumValue (const SbName &name, int &val)

virtual SbBool findEnumName (int value, const SbName *&name) const

Protected Attributes


int value

int numEnums

int * enumValues

SbName * enumNames

SbBool legalValuesSet

Detailed Description

The SoSFEnum class is a container for an enum value.

This field is used where nodes, engines or other field containers needs to store one particular value out of an enumerated set.

A field of this type stores its value to file as the symbolic name, rather than the actual integer value.

SoSFEnum instances are initialized on an instance basis, usually in the constructor of the fieldcontainer with the macros SO_NODE_DEFINE_ENUM_VALUE(enumtype, symbolvalue) and SO_NODE_SET_SF_ENUM_TYPE(enumfield, enumtype) for nodes, or for engines; SO_ENGINE_DEFINE_ENUM_VALUE() and SO_ENGINE_SET_SF_ENUM_TYPE().

Example initialization from the constructor of the SoCone class:

   SO_NODE_DEFINE_ENUM_VALUE(Part, SIDES);
   SO_NODE_DEFINE_ENUM_VALUE(Part, BOTTOM);
   SO_NODE_DEFINE_ENUM_VALUE(Part, ALL);
   SO_NODE_SET_SF_ENUM_TYPE(parts, Part); 
 
 

See also:

SoMFEnum, SoSFBitMask

Member Function Documentation

SoType SoSFEnum::getClassTypeId (void) [static]Returns a unique type identifier for this field class.

See also:

getTypeId(), SoType

Reimplemented from SoSField.

Reimplemented in SoSFBitMask.

SoType SoSFEnum::getTypeId (void) const [virtual]Returns the type identification instance which uniquely identifies the Coin field class the object belongs to.

See also:

getClassTypeId(), SoType

Implements SoField.

Reimplemented in SoSFBitMask.

int SoSFEnum::operator== (const SoSFEnum & f) constChecks for equality. Returns 0 if the fields are of different type or the field's value(s) are not equal.

Reimplemented from SoField.

int SoSFEnum::operator!= (const SoSFEnum & f) const [inline]Returns TRUE if the fields are of different type or has different value.

Reimplemented from SoField.

void SoSFEnum::initClass (void) [static]Internal method called upon initialization of the library (from SoDB::init()) to set up the type system.

Reimplemented from SoSField.

Reimplemented in SoSFBitMask.

void SoSFEnum::setValue (const SbName name)Set the value of this field by specifying an enumeration string value.

References findEnumValue(), SbName::getString(), and SoDebugError::post().

void SoSFEnum::setEnums (const int num, const int * vals, const SbName * names)Makes a set of num enumeration names map to integer values, given by vals.

References enumNames, enumValues, legalValuesSet, and numEnums.

int SoSFEnum::getNumEnums (void) constReturns the number of enum names the SoSFEnum object understands.

Note that this API method is not part of the original SGI Inventor 2.1 API, and is an extension specific to Coin.

This function is an extension for Coin, and it is not available in the original SGI Open Inventor v2.1 API.

Since:

Coin 2.0

int SoSFEnum::getEnum (const int idx, SbName & name) constReturns the value of the Nth enum this SoSFEnum object understands, and mutates name to contain the Nth enum's name.

Note that this API method is not part of the original SGI Inventor 2.1 API, and is an extension specific to Coin.

This function is an extension for Coin, and it is not available in the original SGI Open Inventor v2.1 API.

Since:

Coin 2.0

References enumNames, enumValues, and SoDebugError::post().

SbBool SoSFEnum::findEnumValue (const SbName & name, int & val) [protected, virtual]Return in val the enumeration value which matches the given enumeration name.

Returns TRUE if name is a valid enumeration string, otherwise FALSE.

References enumNames, enumValues, and numEnums.

Referenced by setValue().

SbBool SoSFEnum::findEnumName (int valuearg, const SbName *& name) const [protected, virtual]Set the enumeration name which matches the given enumeration value.

Returns TRUE if value is a valid enumeration value, otherwise FALSE.

References enumNames, enumValues, and numEnums.

Member Data Documentation

int SoSFEnum::numEnums [protected]Number of enumeration mappings.

Referenced by findEnumName(), findEnumValue(), and setEnums().

int * SoSFEnum::enumValues [protected]Array of enumeration values. Maps 1-to-1 with the enumNames.

Referenced by findEnumName(), findEnumValue(), getEnum(), and setEnums().

SbName * SoSFEnum::enumNames [protected]Array of enumeration names. Maps 1-to-1 with the enumValues.

Referenced by findEnumName(), findEnumValue(), getEnum(), and setEnums().

SbBool SoSFEnum::legalValuesSet [protected]Is TRUE if a set of enum name-to-value mappings has been set.

Referenced by setEnums().

Author

Generated automatically by Doxygen for Coin from the source code.