SOMFNODE(3iv)

πŸ’– SoMFNode(3IV) β€” the field that's basically a whole group chat of node pointers πŸ’–

okay bestie, sit down, hydrate, because we're talking about SoMFNode β€” a multiple-value field containing any number of pointers to nodes. yes, any number. she's flexible like that. πŸ¦‹


🌈 INHERITS FROM

SoField > SoMField > SoMFNode

the family tree is giving legacy, but honestly? iconic lineage. πŸ‘‘


✨ SYNOPSIS ✨

#include <Inventor/fields/SoMFNode.h>

πŸŽ€ Methods from class SoMFNode:

static SoType       getClassTypeId()
virtual void        getTypeId() const
SoNode *            operator [](int i) const
const SoNode * *    getValues(int start) const
int                 find(SoNode * targetValue, SbBool addIfNotFound =
                         FALSE)
void                setValues(int start, int num, const SoNode *
                         *newValues)
void                set1Value(int index, SoNode * newValue)
SoNode *            operator =(SoNode * newValue)
void                setValue(SoNode * newValue)
int                 operator ==(const SoMFNode &f) const
int                 operator !=(const SoMFNode &f) const
SoNode * *          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 πŸ’…

so what does she do? this field maintains a set of pointers to SoNode instances, and β€” this is the important part, don't skip it β€” it's correctly maintaining their reference counts. no leaks, no premature deletes, no chaos. she's responsible. she's the friend who actually remembers everyone's birthday. 🫢

when SoMFNodes get written to file, they show up as one or more nodes. and when there's more than one value in there? all the values get wrapped in square brackets and separated by commas, like so:

[ Cube { }, Sphere { radius 2.0 }, USE myTranslation ]

periodt. that's the whole format. πŸ’–


πŸ”₯ METHODS πŸ”₯

  • static SoType getClassTypeId()
  • virtual void getTypeId() const

returns the type for this class, or for a particular object of this class. type check moment. ⭐

  • SoNode * operator [](int i) const

returns the i'th value of the field. ⚠️ but listen β€” indexing past the end of the field (aka passing in an i greater than getNum()) will return garbage. actual garbage. not an error, not a warning, just vibes and nonsense memory. do not do this. πŸ™ˆ

  • const SoNode * * 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 were planning to mess with them, no ma'am. check out the startEditing()/finishEditing() methods for a way of modifying values in place instead. πŸŽ€

  • int find(SoNode * targetValue, SbBool addIfNotFound = FALSE)

finds the given value in the array and returns the index of that value in the array. if it's not found, you get -1 back β€” she's not mad, she's just honest. if addIfNotFound is set, then targetValue is added to the end of the array… but -1 is still returned. yes, really. she added it and still said "not found." that's just the rules. πŸ’€

  • void setValues(int start, int num, const SoNode * *newValues)

sets num values starting at index start to the values in newValues. the array will automatically be made larger to accomodate the new values, if necessary β€” yes, the original says "accomodate," we respect the typo, it's part of her now. πŸ¦‹

  • void set1Value(int index, SoNode * newValue)

sets the index'th value in the array to newValue. the array will be automatically expanded, if necessary. growth mindset fr fr. 🌱

  • SoNode * operator =(SoNode * newValue)
  • void setValue(SoNode * newValue)

sets the first value in the array to newValue, and deletes the second and subsequent values. yes bestie, everyone after slot one is getting unfollowed. 😭

  • int operator ==(const SoMFNode &f) const
  • int operator !=(const SoMFNode &f) const

returns TRUE if all of the values of this field equal (do not equal) those of the given field. but here's the tea: if the fields are different types, FALSE will always be returned β€” even if one field is an SoMFFloat with one value of 1.0 and the other is an SoMFInt with a value of 1, for example. like, we see the resemblance, but they're not the same and she will not pretend. πŸ’…

  • SoNode * * startEditing()
  • void finishEditing()

startEditing() returns a pointer to the internally-maintained array that can be modified. the values in the array may be changed, but values cannot be added or removed. and it is illegal to call any other editing methods between startEditing() and finishEditing() (e.g. set1Value(), setValue(), etc). do not test her. 🚫

fields, engines or sensors connected to this field and sensors are not notified that this field has changed until finishEditing() is called. and heads up β€” 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 were changed. she's dramatic like that. announcing a change that didn't happen? main character energy. πŸ‘‘


⚠️ quick vibe check, bestie: out-of-range operator [] = garbage, and calling other editing methods mid-startEditing()/finishEditing() = illegal. those are the two spots where she bites. everything else is smooth. πŸ“

that's the whole page, angel β€” brought to you straight from the SoMFNode(3IV) manual, section 3IV, and we're closing it out with her signature footer: SoMFNode(3IV)() πŸ’œ go forth and maintain those reference counts correctly. mwah. πŸŽ€βœ¨