Open Inventor Reference
SoFieldData.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved.
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * Further, this software is distributed without any warranty that it is
16  * free of the rightful claim of any third person regarding infringement
17  * or the like. Any license provided herein, whether implied or
18  * otherwise, applies only to this software file. Patent licenses, if
19  * any, provided herein do not apply to combinations of this program with
20  * other software, or any other product whatsoever.
21  *
22  * You should have received a copy of the GNU Lesser General Public
23  * License along with this library; if not, write to the Free Software
24  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25  *
26  * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
27  * Mountain View, CA 94043, or:
28  *
29  * http://www.sgi.com
30  *
31  * For further information regarding this notice, see:
32  *
33  * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
34  *
35  */
36 
37 
38 /*
39  * Copyright (C) 1990,91 Silicon Graphics, Inc.
40  *
41  _______________________________________________________________________
42  ______________ S I L I C O N G R A P H I C S I N C . ____________
43  |
44  | $Revision: 1.1.1.1 $
45  |
46  | Description:
47  | Definition of the SoFieldData class, which is used by all objects
48  | that have fields.
49  |
50  | Author(s) : Paul S. Strauss, Nick Thompson, Gavin Bell
51  |
52  ______________ S I L I C O N G R A P H I C S I N C . ____________
53  _______________________________________________________________________
54  */
55 
56 
57 #ifndef _SO_FIELD_DATA_
58 #define _SO_FIELD_DATA_
59 
60 #include <Inventor/misc/SoBasic.h>
61 #include <Inventor/SbPList.h>
62 #include <Inventor/SbString.h>
63 
64 #include <vector>
65 
66 class SoField;
67 class SoInput;
68 class SoFieldContainer;
69 class SoOutput;
70 
87 
89  public:
92 
96 
98  SoFieldData(int numFields) : fields(numFields) {}
99 
102 
106  void addField(SoFieldContainer *defObject,
107  const char *fieldName,
108  const SoField *field);
109 
114  const SoFieldContainer *from,
115  bool copyConnections) const;
116 
118  int getNumFields() const { return fields.getLength(); }
119 
121  const SbName & getFieldName(int index) const;
122 
125  int index) const;
126 
128  int getIndex(const SoFieldContainer *fc,
129  const SoField *field) const;
130 
132  void addEnumValue(const char *typeName,
133  const char *valName, int val);
134  void getEnumData(const char *typeName, int &num,
135  int *&vals, SbName *&names);
136 
140  const std::vector<SbString>& getRemovedFieldNames() const { return removedFields; }
141 
143  void addRemovedFieldName(const SbString& name);
144 
145  SoINTERNAL public:
146 
152  bool read(SoInput *in, SoFieldContainer *object,
153  bool errorOnUnknownField,
154  bool &notBuiltIn) const;
155 
162  bool read(SoInput *in, SoFieldContainer *object,
163  const SbName &fieldName,
164  bool &foundName) const;
165 
167  void write(SoOutput *out,
168  const SoFieldContainer *object) const;
169 
172  void copy(const SoFieldData *from);
173 
176  bool isSame(const SoFieldContainer *c1,
177  const SoFieldContainer *c2) const;
178 
181  SoInput *in, SoFieldContainer *object,
182  int numDescriptionsExpected) const;
183 
186  SoOutput *out,
187  const SoFieldContainer *object) const;
188 
189  private:
191  bool readFields(
192  SoInput *in, SoFieldContainer *object,
193  int numFieldsWritten) const;
194 
195  SbPList fields;
196  SbPList enums;
197  std::vector<SbString> removedFields;
198 };
199 
200 #endif /* _SO_FIELD_DATA_ */
#define SoINTERNAL
Definition: SbBasic.h:155
#define INVENTOR_API
Disable some annoying warnings on MSVC 6.
Definition: SbSystem.h:81
Character string stored in a hash table.
Definition: SbString.h:264
List of generic (void *) pointers.
Definition: SbPList.h:78
Class for smart character strings.
Definition: SbString.h:85
Abstract base class for objects that contain fields.
The SoFieldData class holds data about fields of an object: the number of fields the object has,...
Definition: SoFieldData.h:88
void copy(const SoFieldData *from)
Copies all fields from given field data into this one, creating new fields for them.
void addEnumValue(const char *typeName, const char *valName, int val)
Enum name/value mechanism.
const SbName & getFieldName(int index) const
Returns name of field with given index.
~SoFieldData()
Destructor.
int getNumFields() const
Returns number of fields.
Definition: SoFieldData.h:118
void writeFieldDescriptions(SoOutput *out, const SoFieldContainer *object) const
Write field type information.
void overlay(SoFieldContainer *to, const SoFieldContainer *from, bool copyConnections) const
Copy values and flags of fields from one object to another (of the same type).
void write(SoOutput *out, const SoFieldContainer *object) const
Writes all fields of object according to SoOutput.
bool readFieldDescriptions(SoInput *in, SoFieldContainer *object, int numDescriptionsExpected) const
Read field type information.
bool isSame(const SoFieldContainer *c1, const SoFieldContainer *c2) const
Returns TRUE if the values in the fields of one container are the same as those in another (of the sa...
void addField(SoFieldContainer *defObject, const char *fieldName, const SoField *field)
Adds a field to current data, given default value object, name of field and pointer to field within d...
SoFieldData(const SoFieldData *)
bool read(SoInput *in, SoFieldContainer *object, const SbName &fieldName, bool &foundName) const
This function is used when the field name has already been read, and just the value needs to be read ...
SoField * getField(const SoFieldContainer *object, int index) const
Returns pointer to field with given index within given object instance.
SoFieldData(int numFields)
Constructor that takes number of fields as a hint.
Definition: SoFieldData.h:98
int getIndex(const SoFieldContainer *fc, const SoField *field) const
Returns index of field, given the field and the instance it is in.
void addRemovedFieldName(const SbString &name)
Adds the given name as a removed field. (MEVIS only)
SoFieldData()
Constructor.
Definition: SoFieldData.h:91
const std::vector< SbString > & getRemovedFieldNames() const
Get access to the names of removed fields.
Definition: SoFieldData.h:140
void getEnumData(const char *typeName, int &num, int *&vals, SbName *&names)
SoFieldData(const SoFieldData &)
Copy constructors.
bool read(SoInput *in, SoFieldContainer *object, bool errorOnUnknownField, bool &notBuiltIn) const
Reads into fields according to SoInput.
Base class for all fields.
Definition: SoField.h:185
Used to read Inventor data files.
Definition: SoInput.h:128
Used to write Inventor data files.
Definition: SoOutput.h:90