Open Inventor Reference
SoTranscribe.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 $
45  |
46  | Description:
47  | This file contains definitions of the SoTranSender and SoTranReceiver
48  | classes used for transcribing Inventor data. Transcribing is the
49  | process of packaging changes to a database and sending them over a
50  | "wire" to another database.
51  |
52  | Classes:
53  | SoTranSender, SoTranReceiver
54  |
55  | Author(s) : Paul S. Strauss
56  |
57  ______________ S I L I C O N G R A P H I C S I N C . ____________
58  _______________________________________________________________________
59  */
60 
61 #ifndef _SO_TRANSCRIBE_
62 #define _SO_TRANSCRIBE_
63 
64 #include <Inventor/misc/SoBasic.h>
65 #include <Inventor/SbString.h>
66 #include <Inventor/SbDict.h>
67 
68 class SoGroup;
69 class SoInput;
70 class SoNode;
71 class SoOutput;
72 
73 
76 
96 
98  public:
99 
103 
106 
108  SoOutput * getOutput() const { return out; }
109 
112  void insert(SoNode *node);
117  void insert(SoNode *node, SoNode *parent, int n);
120  void remove(SoNode *parent, int n);
124  void replace(SoNode *parent, int n, SoNode *newNode);
129  void modify(SoNode *node);
130 
135 
136  private:
137  SoOutput *out;
138 
140  void addBytes(const void *bytes, size_t nBytes);
141  void addCommand(int command);
142  void addInt(int n);
143  void addNode(SoNode *node, bool addNames = TRUE);
144  void addNodeNames(const SoNode *root);
145  void addNodeRef(const SoNode *node);
146  void addString(const char *cmdString);
147 
148 friend class SoTranReceiver;
149 };
150 
151 
154 
171 
173 
174  public:
175 
180 
183 
188  bool interpret(SoInput *in);
189 
190  private:
191  SoGroup *root;
192  SbDict nameToEntryDict;
193  SbDict nodeToNameDict;
194 
197  bool interpretCommand(int commandCode, SoInput *in, bool &done);
198 
200  bool getNodeAndNames(SoInput *in, SoNode *&node);
201 
203  bool getNode(SoInput *in, SoNode *&root);
204 
206  bool getNodeNames(SoInput *in, SoNode *root,
207  bool lookForNode, SoNode *&oldRoot);
208 
211  bool getNodeReference(SoInput *in, SoNode *&node);
212 
214  void removeNodeReferences(SoNode *node);
215 
217  void addEntry(SoNode *node, SbName &name);
218 
220  static void deleteDictEntry(size_t key, void *value);
221 
222 };
223 
224 #endif /* _SO_TRANSCRIBE_ */
225 
#define TRUE
Definition: SbBasic.h:76
#define INVENTOR_API
Disable some annoying warnings on MSVC 6.
Definition: SbSystem.h:81
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
Base class for all group nodes.
Definition: SoGroup.h:104
Used to read Inventor data files.
Definition: SoInput.h:128
Abstract base class for all database nodes.
Definition: SoNode.h:103
Used to write Inventor data files.
Definition: SoOutput.h:90
Interprets database changes for transcription.
Definition: SoTranscribe.h:172
~SoTranReceiver()
Destructor.
bool interpret(SoInput *in)
Interprets the transcription commands found in the given input stream.
SoTranReceiver(SoGroup *rootNode)
The constructor takes a pointer to an SoGroup instance that is the root node of the scene graph on th...
Sends database changes for transcription.
Definition: SoTranscribe.h:97
void prepareToSend()
Prepares a SoTranSender instance for transcription, making sure the transcription area is complete an...
void modify(SoNode *node)
Adds a MODIFY command to the transcription area.
SoTranSender(SoOutput *output)
The constructor takes a pointer to an SoOutput instance that determines what the transcription area i...
void remove(SoNode *parent, int n)
Adds a REMOVE command to the transcription area.
~SoTranSender()
Destructor.
Definition: SoTranscribe.h:105
void replace(SoNode *parent, int n, SoNode *newNode)
Adds a REPLACE command to the transcription area.
void insert(SoNode *node, SoNode *parent, int n)
Adds an INSERT command to the transcription area.
void insert(SoNode *node)
Adds an INSERT command to the transcription area.
SoOutput * getOutput() const
Returns pointer to current SoOutput instance.
Definition: SoTranscribe.h:108