SOMFENUM(3iv)

πŸ’– NAME πŸ’–

SoMFEnum β€” a multiple-value field that holds any number of enumerated type values. Like, any number. Zero, one, forty. It's giving buffet. πŸ“


🌸 INHERITS FROM 🌸

SoField > SoMField > SoMFEnum

The family tree, bestie. It got the field genes from SoField, the "many values" energy from SoMField, and then SoMFEnum is the main character. πŸ‘‘


✨ SYNOPSIS ✨

Methods from class SoMFEnum:

void                setValue(const SbName &name)
void                set1Value(int index, const SbName &name)
static SoType       getClassTypeId()
virtual void        getTypeId() const
int                 operator [](int i) const
const int *         getValues(int start) const
int                 find(int targetValue, SbBool addIfNotFound = FALSE)
void                setValues(int start, int num, const int *newValues)
void                set1Value(int index, int newValue)
int                 operator =(int newValue)
void                setValue(int newValue)
int                 operator ==(const SoMFEnum &f) const
int                 operator !=(const SoMFEnum &f) const
int *               startEditing()
void                finishEditing()

Methods from class SoMField:

int                 getNum() const
void                setNum(int num)
virtual void        deleteValues(int start, int num = -1)
virtual void        insertSpace(int start, int num)
SbBool              set1(int index, const char *valueString)
void                get1(int index, SbString &valueString)

Methods from class SoField:

void                setIgnored(SbBool ignore)
SbBool              isIgnored() const
SbBool              isDefault() const
virtual SbBool      isOfType(SoType type) const
SbBool              set(const char *valueString)
void                get(SbString &valueString)
void                touch()
SbBool              connectFrom(SoField *fromField)
SbBool              connectFrom(SoEngineOutput *fromEngine)
void                disconnect()
SbBool              isConnected() const
SbBool              isConnectedFromField() const
SbBool              getConnectedField(SoField *&writingField) const
SbBool              isConnectedFromEngine() const
SbBool              getConnectedEngine(SoEngineOutput *&engineOutput)
                         const
void                enableConnection(SbBool flag)
SbBool              isConnectionEnabled() const
int                 getForwardConnections(SoFieldList &list) const
SoFieldContainer *  getContainer() const

πŸ¦‹ DESCRIPTION πŸ¦‹

Okay so picture this: a multiple-value field that contains any number of enumerated type values, and underneath it all they're stored as ints. That's the whole vibe.

The nodes that use this field class define mnemonic names for the values. And bestie, use those names when you're setting or testing the values of the field β€” even though, lowkey, the methods treat the values as integers. The names are the moment. ✨

SoMFEnums get written to file as a set of mnemonic enumerated type names. Heads up though: those names differ depending on which node class is using the field. So if you need the actual names, go check the reference pages for your specific nodes. iykyk. πŸ’…

And when more than one value is present? All of the values get wrapped in square brackets and separated by commas. Cute, tidy, iconic.


πŸ’… METHODS πŸ’…

πŸŽ€ The SoMFEnum ones

  • void setValue(const SbName &name) β€” Sets this field to contain one and only one value, and that value is the mnemonic name, passed in as a string. One value. That's it. No plus-ones. πŸ™ˆ
  • void set1Value(int index, const SbName &name) β€” Sets the index'th value to be the integer that corresponds to the mnemonic name in the given string. Name in, number out, slay.
  • static SoType getClassTypeId()
  • virtual void getTypeId() const β€” Returns the type for this class, or for a particular object of this class. Type check, but make it official. ⭐
  • int operator [](int i) const β€” Returns the i'th value of the field. ⚠️ But watch out: indexing past the end of the field (passing in i greater than getNum()) will return garbage. Not a crash, not an error, just... garbage. Rude. πŸ’€
  • const int * getValues(int start) const β€” Returns a pointer into the array of values in the field, starting at index start. These values are read-only β€” so if you wanna modify values in place, go look at startEditing() / finishEditing(). Read-only means read-only, bestie. 🫢
  • int find(int targetValue, SbBool addIfNotFound = FALSE) β€” Hunts down the given value in the array and returns the index of that value in the array. Not found? You get -1. If addIfNotFound is set, then targetValue gets added to the end of the array β€” but you still get -1 back. Yes, really. That's the deal. 😭
  • void setValues(int start, int num, const int *newValues) β€” Sets num values starting at index start to the values in newValues. The array gets automatically made larger to accommodate the new values, if it needs to. It grows for you. Growth mindset. 🌱
  • void set1Value(int index, int newValue) β€” Sets the index'th value in the array to newValue. The array will be automatically expanded, if necessary. Same energy, one value at a time. ✨
  • int operator =(int newValue)
  • void setValue(int newValue) β€” Sets the first value in the array to newValue, and then deletes the second and subsequent values. Just so you know. It's not adding, it's replacing-and-clearing. πŸ™ˆ
  • int operator ==(const SoMFEnum &f) const
  • int operator !=(const SoMFEnum &f) const β€” Returns TRUE if all of the values of this field equal (or do not equal) those of the given field. And here's the caveat: if the fields are different types, FALSE will always be returned β€” even if, say, one field is an SoMFFloat with one value of 1.0 and the other is an SoMFInt with a value of 1. Different types, different worlds. No cap. πŸ’€
  • int * startEditing()
  • void finishEditing() β€” startEditing() returns a pointer to the internally-maintained array, and that array can be modified. You can change the values in the array, but you cannot add or remove values. And it is illegal to call any other editing methods between startEditing() and finishEditing() (things like set1Value(), setValue(), etc.). Do not do it. Periodt. βœ‹

Also: fields, engines or sensors connected to this field and sensors are not notified that this field changed until finishEditing() is called. And calling finishEditing() always sets the isDefault() flag to FALSE and informs engines and sensors that the field changed β€” even if none of the values actually changed. It's telling on you regardless. 😭


Real talk bestie: don't index past getNum(), don't call editing methods mid-startEditing()/finishEditing(), and don't expect == to be chill across different field types. Those are the three little landmines. Watch your step. πŸ’–

and that's the whole page, fr fr β€” the header up top and the footer down bottom both just say SoMFEnum(3IV)(), so consider this your cute little sign-off. Same name, top and bottom, like a matching set. πŸŽ€βœ¨πŸ¦‹ Go forth and set your enum values, you gorgeous genius. πŸ’œ