1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191
|
/*
*
* Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* Further, this software is distributed without any warranty that it is
* free of the rightful claim of any third person regarding infringement
* or the like. Any license provided herein, whether implied or
* otherwise, applies only to this software file. Patent licenses, if
* any, provided herein do not apply to combinations of this program with
* other software, or any other product whatsoever.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
* Mountain View, CA 94043, or:
*
* http://www.sgi.com
*
* For further information regarding this notice, see:
*
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
*
*/
// -*- C++ -*-
/*
* Copyright (C) 1990,91 Silicon Graphics, Inc.
*
_______________________________________________________________________
______________ S I L I C O N G R A P H I C S I N C . ____________
|
| $Revision: 1.1.1.1 $
|
| Description:
| Definition of the SoFieldData class, which is used by all objects
| that have fields.
|
| Author(s) : Paul S. Strauss, Nick Thompson, Gavin Bell
|
______________ S I L I C O N G R A P H I C S I N C . ____________
_______________________________________________________________________
*/
// C-api: end
#ifndef _SO_FIELD_DATA_
#define _SO_FIELD_DATA_
#include <Inventor/misc/SoBasic.h>
#include <Inventor/SbPList.h>
#include <Inventor/SbString.h>
class SoField;
class SoInput;
class SoFieldContainer;
class SoOutput;
//////////////////////////////////////////////////////////////////////////////
//
// Class: SoFieldData
//
// The SoFieldData class holds data about fields of an object: the
// number of fields the object has, the names of the fields, and a
// pointer to a prototype instance of the field. (Typically, this
// prototype field is contained within a prototype instance of the
// node or engine.)
//
// All objects of a given class share the same field data. Therefore,
// to get information about a particular field in a particular object
// instance, it is necessary to pass that instance to the appropriate
// method.
//
//////////////////////////////////////////////////////////////////////////////
SoINTERNAL class SoFieldData {
public:
// Constructor
SoFieldData() {}
// Copy constructors
SoFieldData(const SoFieldData &);
SoFieldData(const SoFieldData *);
// Constructor that takes number of fields as a hint
SoFieldData(int numFields) : fields(numFields) {}
// Destructor
~SoFieldData();
// Adds a field to current data, given default value object, name of
// field and pointer to field within default value object. This is
// used to define fields of a FieldContainer (node or engine) class.
void addField(SoFieldContainer *defObject,
const char *fieldName,
const SoField *field);
// Copy values and flags of fields from one object to another (of
// the same type). If copyConnections is TRUE, any connections to
// the fields are copied as well
void overlay(SoFieldContainer *to,
const SoFieldContainer *from,
SbBool copyConnections) const;
// Returns number of fields
int getNumFields() const { return fields.getLength(); }
// Returns name of field with given index
const SbName & getFieldName(int index) const;
// Returns pointer to field with given index within given object instance
SoField * getField(const SoFieldContainer *object,
int index) const;
// Returns index of field, given the field and the instance it is in
int getIndex(const SoFieldContainer *fc,
const SoField *field) const;
// Enum name/value mechanism
void addEnumValue(const char *typeName,
const char *valName, int val);
void getEnumData(char *typeName, int &num,
int *&vals, SbName *&names);
SoINTERNAL public:
// Reads into fields according to SoInput. The third
// parameter indicates whether an unknown field should be reported
// as an error; this can be FALSE for nodes that have children.
// The last argument will be set to TRUE if a description of the
// fields (using the "inputs" or "fields" keywords) was read.
SbBool read(SoInput *in, SoFieldContainer *object,
SbBool errorOnUnknownField,
SbBool ¬BuiltIn) const;
// This function is used when the field name has already been
// read, and just the value needs to be read in. It is used by
// the above read() method and to read in GlobalFields. It
// returns TRUE if there were no problems reading, and will return
// FALSE in 'foundName' if the given name is not the name of one
// of the fields in the fieldData.
SbBool read(SoInput *in, SoFieldContainer *object,
const SbName &fieldName,
SbBool &foundName) const;
// Writes all fields of object according to SoOutput
void write(SoOutput *out,
const SoFieldContainer *object) const;
// Copies all fields from given field data into this one, creating
// new fields for them
void copy(const SoFieldData *from);
// Returns TRUE if the values in the fields of one container are
// the same as those in another (of the same type)
SbBool isSame(const SoFieldContainer *c1,
const SoFieldContainer *c2) const;
// Read field type information
SbBool readFieldDescriptions(
SoInput *in, SoFieldContainer *object,
int numDescriptionsExpected) const;
// Write field type information
void writeFieldDescriptions(
SoOutput *out,
const SoFieldContainer *object) const;
private:
// Used by binary reading to read in all the fields:
SbBool readFields(
SoInput *in, SoFieldContainer *object,
int numFieldsWritten) const;
SbPList fields; // List of fields (SoFieldEntry)
SbPList enums; // List of enums (SoEnumEntry)
};
#endif /* _SO_FIELD_DATA_ */
|