| 1 |
#!/bin/ksh |
| 2 |
|
| 3 |
# Shell script to generate the stuff that is the same for all |
| 4 |
# multiple-value fields (generated by the macros in SoSubField.h) |
| 5 |
|
| 6 |
if test $# -ne 3 ; then |
| 7 |
echo "Usage: " $0 " className valueType valueRef" |
| 8 |
echo " e.g: " $0 " SoSFShort short short" |
| 9 |
echo " e.g: " $0 " SoSFColor SbColor 'const SbColor &'" |
| 10 |
exit |
| 11 |
fi |
| 12 |
|
| 13 |
className=$1 |
| 14 |
valueType=$2 |
| 15 |
valueRef=$3 |
| 16 |
|
| 17 |
cat <<EOF |
| 18 |
METHOD "" static SoType getClassTypeId() {} |
| 19 |
METHOD "" virtual void getTypeId() const { |
| 20 |
Returns the type for this class or a particular object of this class. |
| 21 |
} |
| 22 |
METHOD Get $valueRef operator[](int i) const { |
| 23 |
Returns the i'th value of the field. Indexing past the end of the |
| 24 |
field (passing in i greater than getNum()) will return garbage. |
| 25 |
} |
| 26 |
METHOD GetN const $valueType * getValues(int start) const { |
| 27 |
Returns a pointer into the array of values in the field, starting at |
| 28 |
index start. The values are read-only; see the |
| 29 |
startEditing/finishEditing methods for a way of modifying values |
| 30 |
in-place. |
| 31 |
} |
| 32 |
METHOD "" int find($valueRef targetValue, |
| 33 |
SbBool addIfNotFound = FALSE) { |
| 34 |
Finds the given value in the array and returns the index of that value |
| 35 |
in the array. If the value is not found, -1 is returned. If |
| 36 |
addIfNotFound is set, then targetValue will be added to the end of the |
| 37 |
array (but -1 is still returned). |
| 38 |
} |
| 39 |
METHOD SetN void setValues(int start, int num, |
| 40 |
const $valueType *newValues) { |
| 41 |
Sets num values starting at index start to the values in newValues. |
| 42 |
The array will be automatically be made larger to accomodate the new |
| 43 |
values, if necessary. |
| 44 |
} |
| 45 |
METHOD Set1 void set1Value(int index, $valueRef newValue) { |
| 46 |
Sets the index'th value in the array to newValue. The array will be |
| 47 |
automatically expanded, if necessary. |
| 48 |
} |
| 49 |
METHOD " " $valueRef operator=($valueRef newValue) {} |
| 50 |
METHOD Set void setValue($valueRef newValue) { |
| 51 |
Sets the first value in the array to newValue, and deletes the second |
| 52 |
and subsequent values. |
| 53 |
} |
| 54 |
METHOD IsEq int operator==(const $className &f) const {} |
| 55 |
METHOD IsNEq int operator!=(const $className &f) const { |
| 56 |
Returns TRUE if all of the values of this field equals (does not |
| 57 |
equal) the given field. If the fields are different types FALSE will |
| 58 |
always be returned (even if one field is an \cSoMFFloat\. with one |
| 59 |
value of 1.0 and the other is an \cSoMFInt\. with a value of 1, for |
| 60 |
example). |
| 61 |
} |
| 62 |
METHOD StartEdit $valueType *startEditing() {} |
| 63 |
METHOD FinishEdit void finishEditing() { |
| 64 |
startEditing() returns a pointer to the internally-maintained array that can be |
| 65 |
modified. The values in the array may be changed, but values cannot |
| 66 |
be added or removed. |
| 67 |
It is illegal to call any other editing |
| 68 |
methods are called between |
| 69 |
\+ |
| 70 |
startEditing() and finishEditing() (e.g. |
| 71 |
set1Value(), setValue(), etc). |
| 72 |
\. |
| 73 |
\- |
| 74 |
StartEdit() and FinishEdit() (e.g. Set1(), Set(), etc). |
| 75 |
\. |
| 76 |
\p |
| 77 |
Fields, engines or sensors connected to this field and sensors are not |
| 78 |
notified that this field has changed until |
| 79 |
\+finishEditing()\. \-FinishEdit()\. is called. Calling |
| 80 |
\+finishEditing()\. \-FinishEdit()\. always sets the |
| 81 |
\+isDefault()\. \-IsDflt\. flag to FALSE and informs |
| 82 |
engines and sensors that the field changed, even if none of the values |
| 83 |
actually were changed. |
| 84 |
} |
| 85 |
EOF |
| 86 |
|