Open Inventor Reference
SoFieldContainer.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,92 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 | Defines the SoFieldContainer class, which is the base class of
48 | all classes that contain fields (engines and nodes)
49 |
50 | Classes:
51 | SoFieldContainer
52 |
53 | Author(s) : Gavin Bell
54 |
55 ______________ S I L I C O N G R A P H I C S I N C . ____________
56 _______________________________________________________________________
57 */
58
59#ifndef _SO_FIELD_CONTAINER_
60#define _SO_FIELD_CONTAINER_
61
64
65
66class SbDict;
67class SoFieldData;
68class SoFieldList;
69class SoSensor;
70
73
91
93
94 public:
95
97 static SoType getClassTypeId() { return classTypeId; }
98
101
110 bool hasDefaultValues() const;
111
114 bool fieldsAreEqual(const SoFieldContainer *fc) const;
115
121 bool copyConnections = FALSE);
122
131 bool set(const char *fieldDataString)
132 { return set(fieldDataString, NULL); }
133
140 void get(SbString &fieldDataString)
141 { get(fieldDataString, NULL); }
142
149 virtual int getFields(SoFieldList &list) const;
150
153 virtual SoField * getField(const SbName &fieldName) const;
154
157 bool getFieldName(const SoField *field,
158 SbName &fieldName) const;
159
163 bool enableNotify(bool flag) // returns old value
164 { bool e = notifyEnabled; notifyEnabled = flag; return e; }
190 bool isNotifyEnabled() const { return notifyEnabled; }
191
192 SoINTERNAL public:
194 static void initClass();
195
204 bool set(const char *fieldDataString, SoInput *dictIn);
211 void get(SbString &fieldDataString, SoOutput *dictOut);
212
214 virtual void notify(SoNotList *);
215
219 virtual void addWriteReference(SoOutput *out,
220 bool isFromField = FALSE);
221
223 virtual void writeInstance(SoOutput *out);
224
227 bool getIsBuiltIn() const { return isBuiltIn; }
228
231 virtual const SoFieldData * getFieldData() const;
232
239
241 static void initCopyDict();
242
244 static void addCopy(const SoFieldContainer *orig,
245 const SoFieldContainer *copy);
246
251
257 bool copyConnections);
258
260 static void copyDone();
261
264
267 virtual void copyContents(const SoFieldContainer *fromFC,
268 bool copyConnections);
269
276
280
281 protected:
282
286
289
291 virtual bool readInstance(SoInput *in, unsigned short flags);
292
293 private:
294 static SoType classTypeId;
295 bool notifyEnabled;
296
298 SbPList* _managedSensors;
299
302 static SbPList *copyDictList;
303
306 static void unrefCopy(size_t key, void *instPtr);
307
310 static char *fieldBuf;
311 static size_t fieldBufSize;
312
315 static void * reallocFieldBuf(void *ptr, size_t newSize);
316};
317
318#endif /* _SO_FIELD_CONTAINER_ */
#define FALSE
Definition SbBasic.h:79
#define SoINTERNAL
Definition SbBasic.h:155
#define INVENTOR_API
Disable some annoying warnings on MSVC 6.
Definition SbSystem.h:77
This is a dictionary mapping (size_t) integer keys to (void *) data pointers.
Definition SbDict.h:101
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
Base class for all nodes, paths, and engines.
Definition SoBase.h:90
Abstract base class for objects that contain fields.
virtual void addWriteReference(SoOutput *out, bool isFromField=FALSE)
Adds a reference to the instance when writing.
static void addCopy(const SoFieldContainer *orig, const SoFieldContainer *copy)
Adds an instance to the dictionary.
bool enableNotify(bool flag)
Notification at this Field Container is enabled (if flag == TRUE) or disabled (if flag == FALSE).
virtual void notify(SoNotList *)
Propagates modification notification through an instance.
void addManagedSensor(SoSensor *sensor)
Adds a sensor which is managed by the field container.
bool hasDefaultValues() const
Returns TRUE if all of the object's fields have their default values.
void get(SbString &fieldDataString)
Returns the values of the fields of this object in the Inventor ASCII file format in the given string...
static SoType getClassTypeId()
Returns the type of this class.
virtual void copyContents(const SoFieldContainer *fromFC, bool copyConnections)
Copies the contents of the given node into this instance.
void setToDefaults()
Sets all fields in this object to their default values.
virtual void writeInstance(SoOutput *out)
Writes instance to SoOutput. (Used only for last stage of writing)
virtual bool readInstance(SoInput *in, unsigned short flags)
Reads stuff into instance. Returns FALSE on error.
virtual SoField * getField(const SbName &fieldName) const
Returns a pointer to the field with the given name.
virtual const SoFieldData * getFieldData() const
Returns an SoFieldData structure for the node.
static SoFieldContainer * findCopy(const SoFieldContainer *orig, bool copyConnections)
If a copy of the given instance is not in the dictionary, this returns NULL.
static void initCopyDict()
During a copy operation, copies of nodes and engines are stored in a dictionary, keyed by the origina...
bool fieldsAreEqual(const SoFieldContainer *fc) const
Returns TRUE if this object's fields are exactly equal to fc's fields.
bool set(const char *fieldDataString)
Sets one or more fields in this object to the values specified in the given string,...
static void copyDone()
Cleans up the dictionary when done.
static SoFieldContainer * checkCopy(const SoFieldContainer *orig)
If a copy of the given instance is in the dictionary, this returns it.
bool getFieldName(const SoField *field, SbName &fieldName) const
Returns the name of the given field in the fieldName argument.
bool isBuiltIn
Is the subclass a built-in Inventor subclass or an extender subclass? This is used to determine wheth...
bool getIsBuiltIn() const
Returns whether or not instance is considered 'built-in' to the library.
virtual SoFieldContainer * copyThroughConnection() const
During a copy operation, this copies an instance that is encountered through a field connection.
bool set(const char *fieldDataString, SoInput *dictIn)
Sets one or more fields in this object to the values specified in the given string,...
void copyFieldValues(const SoFieldContainer *fc, bool copyConnections=FALSE)
Copies the contents of fc's fields into this object's fields.
void get(SbString &fieldDataString, SoOutput *dictOut)
Returns the values of the fields of this object in the Inventor ASCII file format in the given string...
bool isNotifyEnabled() const
Notification is the process of telling interested objects that this object has changed.
static void initClass()
Setup type information.
virtual int getFields(SoFieldList &list) const
Appends pointers to all of this object's fields to resultList, and returns the number of fields appen...
The SoFieldData class holds data about fields of an object: the number of fields the object has,...
Definition SoFieldData.h:88
Maintains a list of pointers to fields.
Definition SoLists.h:426
Base class for all fields.
Definition SoField.h:185
Used to read Inventor data files.
Definition SoInput.h:128
Holds a list of SoNotRec notification records.
Used to write Inventor data files.
Definition SoOutput.h:90
Abstract base class for Inventor sensors.
Definition SoSensor.h:108
SoType has no virtual functions to keep it small...
Definition SoType.h:103