Go to the documentation of this file.
125#ifndef _SO_SUB_FIELD_
126#define _SO_SUB_FIELD_
140#define SO__FIELD_HEADER(className) \
142 virtual SoType getTypeId() const; \
143 static SoType getClassTypeId() { return classTypeId; } \
146 const className & operator =(const className &f); \
150 virtual void copyFrom(const SoField &f); \
152 static void * createInstance(); \
155 virtual bool isSame(const SoField &f) const; \
158 static SoType classTypeId
160#define SO__SFIELD_RW_HEADER(className) \
163 virtual bool readValue(SoInput *in); \
166 virtual void writeValue(SoOutput *out) const
168#define SO__MFIELD_RW_HEADER(className) \
171 virtual bool read1Value(SoInput *in, int index); \
174 virtual void write1Value(SoOutput *out, int index) const
176#define SO__FIELD_INIT_CLASS(className,classPrintName,parentClass) \
177 classTypeId = SoType::createType(parentClass::getClassTypeId(), \
179 &className::createInstance)
181#define SO__FIELD_ID_SOURCE(className) \
183SoType className::classTypeId; \
186className::getTypeId() const \
188 return classTypeId; \
191className::createInstance() \
193 return static_cast<void *>(new className); \
196#define SO__FIELD_EQ_SAME_SOURCE(className) \
199className::copyFrom(const SoField &f) \
201 *this = * static_cast<const className *>(&f); \
205className::isSame(const SoField &f) const \
207 return (getTypeId() == f.getTypeId() && \
208 (*this) == static_cast<const className &>(f)); \
224#define SO_SFIELD_REQUIRED_HEADER(className) \
225 SO__FIELD_HEADER(className)
233#define SO_SFIELD_CONSTRUCTOR_HEADER(className) \
245#define SO_SFIELD_VALUE_HEADER(className, valueType, valueRef) \
246 SO__SFIELD_RW_HEADER(className); \
249 valueRef getValue() const \
250 { evaluate(); return value; } \
253 void setValue(valueRef newValue); \
254 valueRef operator =(valueRef newValue) \
255 { setValue(newValue); return value; } \
258 bool operator ==(const className &f) const; \
259 bool operator !=(const className &f) const \
260 { return ! ((*this) == f); } \
273#define SO_SFIELD_DERIVED_VALUE_HEADER(className, valueType, valueRef) \
274 SO__SFIELD_RW_HEADER(className); \
277 valueRef operator =(valueRef newValue) \
278 { setValue(newValue); return value; }
287#define SO_SFIELD_HEADER(className, valueType, valueRef) \
288 SO_SFIELD_REQUIRED_HEADER(className); \
289 SO_SFIELD_CONSTRUCTOR_HEADER(className); \
290 SO_SFIELD_VALUE_HEADER(className, valueType, valueRef)
300#define SO_SFIELD_DERIVED_HEADER(className, valueType, valueRef) \
301 SO_SFIELD_REQUIRED_HEADER(className); \
302 SO_SFIELD_CONSTRUCTOR_HEADER(className); \
303 SO_SFIELD_DERIVED_VALUE_HEADER(className, valueType, valueRef)
318#define SO_MFIELD_REQUIRED_HEADER(className) \
319 SO__FIELD_HEADER(className)
327#define SO_MFIELD_CONSTRUCTOR_HEADER(className) \
339#define SO_MFIELD_VALUE_HEADER(className, valueType, valueRef) \
340 SO__MFIELD_RW_HEADER(className); \
343 valueRef operator [](int i) const \
344 { evaluate(); return values[i]; } \
347 const valueType * getValues(int start) const \
348 { evaluate(); return const_cast<const valueType *>(values + start); } \
353 int find(valueRef targetValue, \
354 bool addIfNotFound = FALSE); \
357 void setValues(int start, int num, \
358 const valueType *newValues); \
361 void set1Value(int index, valueRef newValue); \
364 void setValue(valueRef newValue); \
365 valueRef operator =(valueRef newValue) \
366 { setValue(newValue); return newValue; } \
369 bool operator ==(const className &f) const; \
370 bool operator !=(const className &f) const \
371 { return ! ((*this) == f); } \
374 valueType * startEditing() \
375 { evaluate(); return values; } \
378 void finishEditing() { valueChanged(); } \
384 virtual void allocValues(int newNum); \
387 virtual void deleteAllValues(); \
390 virtual void copyValue(int to, int from); \
402#define SO_MFIELD_DERIVED_VALUE_HEADER(className, valueType, valueRef) \
403 SO__MFIELD_RW_HEADER(className); \
406 valueRef operator =(valueRef newValue) \
407 { setValue(newValue); return newValue; }
416#define SO_MFIELD_HEADER(className, valueType, valueRef) \
417 SO_MFIELD_REQUIRED_HEADER(className); \
418 SO_MFIELD_CONSTRUCTOR_HEADER(className); \
419 SO_MFIELD_VALUE_HEADER(className, valueType, valueRef)
429#define SO_MFIELD_DERIVED_HEADER(className, valueType, valueRef) \
430 SO_MFIELD_REQUIRED_HEADER(className); \
431 SO_MFIELD_CONSTRUCTOR_HEADER(className); \
432 SO_MFIELD_DERIVED_VALUE_HEADER(className, valueType, valueRef)
448#define SO_SFIELD_INIT_CLASS(className,parentClass) \
449 SO__FIELD_INIT_CLASS(className, SO__QUOTE(className), parentClass)
458#define SO_SFIELD_REQUIRED_SOURCE(className) \
460 SO__FIELD_ID_SOURCE(className); \
461 SO__FIELD_EQ_SAME_SOURCE(className) \
464className::operator =(const className &f) \
466 setValue(f.getValue()); \
476#define SO_SFIELD_CONSTRUCTOR_SOURCE(className) \
478className::className() \
481className::~className() \
492#define SO_SFIELD_VALUE_SOURCE(className, valueType, valueRef) \
495className::setValue(valueRef newValue) \
502className::operator ==(const className &f) const \
504 return getValue() == f.getValue(); \
514#define SO_SFIELD_SOURCE(className, valueType, valueRef) \
515 SO_SFIELD_REQUIRED_SOURCE(className); \
516 SO_SFIELD_CONSTRUCTOR_SOURCE(className); \
517 SO_SFIELD_VALUE_SOURCE(className, valueType, valueRef)
527#define SO_SFIELD_DERIVED_SOURCE(className, valueType, valueRef) \
528 SO_SFIELD_REQUIRED_SOURCE(className); \
529 SO_SFIELD_CONSTRUCTOR_SOURCE(className)
545#define SO_MFIELD_INIT_CLASS(className,parentClass) \
546 SO__FIELD_INIT_CLASS(className, SO__QUOTE(className), parentClass)
555#define SO_MFIELD_REQUIRED_SOURCE(className) \
557 SO__FIELD_ID_SOURCE(className); \
558 SO__FIELD_EQ_SAME_SOURCE(className) \
561className::operator =(const className &f) \
563 if (f.getNum() < getNum()) \
565 setValues(0, f.getNum(), f.getValues(0)); \
578#define SO_MFIELD_CONSTRUCTOR_SOURCE(className) \
580className::className() \
585className::~className() \
598#define SO_MFIELD_DERIVED_CONSTRUCTOR_SOURCE(className) \
600className::className() \
604className::~className() \
615#define SO_MFIELD_VALUE_SOURCE(className, valueType, valueRef) \
618className::find(valueRef targetValue, bool addIfNotFound) \
620 int i, localNum = getNum(); \
622 for (i = 0; i < localNum; i++) \
623 if (values[i] == targetValue) \
627 set1Value(localNum, targetValue); \
633className::setValues(int start, int localNum, const valueType *newValues) \
635 int newNum = start + localNum, i; \
637 if (newNum > getNum()) \
640 for (i = 0; i < localNum; i++) \
641 values[start + i] = newValues[i]; \
647className::set1Value(int index, valueRef newValue) \
649 if (index >= getNum()) \
650 makeRoom(index + 1); \
651 values[index] = newValue; \
656className::setValue(valueRef newValue) \
659 values[0] = newValue; \
664className::operator ==(const className &f) const \
666 int i, localNum = getNum(); \
667 const valueType *myVals, *itsVals; \
669 if (localNum != f.getNum()) \
672 myVals = getValues(0); \
673 itsVals = f.getValues(0); \
675 for (i = 0; i < localNum; i++) \
676 if (! (myVals[i] == itsVals[i])) \
683className::deleteAllValues() \
689className::copyValue(int to, int from) \
691 values[to] = values[from]; \
702#define SO_MFIELD_ALLOC_SOURCE(className, valueType) \
704className::allocValues(int newNum) \
706 if (values == NULL) { \
708 values = new valueType[newNum]; \
711 valueType *oldValues = values; \
715 values = new valueType[newNum]; \
716 for (i = 0; i < num && i < newNum; i++) \
717 values[i] = oldValues[i]; \
721 delete [] oldValues; \
724 num = maxNum = newNum; \
737#define SO_MFIELD_MALLOC_SOURCE(className, valueType) \
739className::allocValues(int newNum) \
741 if (values == NULL) { \
743 values = static_cast<valueType *>(malloc(sizeof(valueType) * newNum));\
747 values = static_cast<valueType *>(realloc(values, sizeof(valueType)*newNum));\
754 num = maxNum = newNum; \
765#define SO_MFIELD_SOURCE(className, valueType, valueRef) \
766 SO_MFIELD_REQUIRED_SOURCE(className) \
767 SO_MFIELD_CONSTRUCTOR_SOURCE(className) \
768 SO_MFIELD_VALUE_SOURCE(className, valueType, valueRef) \
769 SO_MFIELD_ALLOC_SOURCE(className, valueType)
778#define SO_MFIELD_SOURCE_MALLOC(className, valueType, valueRef) \
779 SO_MFIELD_REQUIRED_SOURCE(className) \
780 SO_MFIELD_CONSTRUCTOR_SOURCE(className) \
781 SO_MFIELD_VALUE_SOURCE(className, valueType, valueRef) \
782 SO_MFIELD_MALLOC_SOURCE(className, valueType)
792#define SO_MFIELD_DERIVED_SOURCE(className, valueType, valueRef) \
793 SO_MFIELD_REQUIRED_SOURCE(className); \
794 SO_MFIELD_DERIVED_CONSTRUCTOR_SOURCE(className)