Open Inventor Release 2024.2.1
 
Loading...
Searching...
No Matches
SoTranscribe.h
1/*=======================================================================
2 * Copyright 1991-1996, Silicon Graphics, Inc.
3 * ALL RIGHTS RESERVED
4 *
5 * UNPUBLISHED -- Rights reserved under the copyright laws of the United
6 * States. Use of a copyright notice is precautionary only and does not
7 * imply publication or disclosure.
8 *
9 * U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND:
10 * Use, duplication or disclosure by the Government is subject to restrictions
11 * as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights
12 * in Technical Data and Computer Software clause at DFARS 252.227-7013 and/or
13 * in similar or successor clauses in the FAR, or the DOD or NASA FAR
14 * Supplement. Contractor/manufacturer is Silicon Graphics, Inc.,
15 * 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311.
16 *
17 * THE CONTENT OF THIS WORK CONTAINS CONFIDENTIAL AND PROPRIETARY
18 * INFORMATION OF SILICON GRAPHICS, INC. ANY DUPLICATION, MODIFICATION,
19 * DISTRIBUTION, OR DISCLOSURE IN ANY FORM, IN WHOLE, OR IN PART, IS STRICTLY
20 * PROHIBITED WITHOUT THE PRIOR EXPRESS WRITTEN PERMISSION OF SILICON
21 * GRAPHICS, INC.
22**=======================================================================*/
23/*=======================================================================
24** Author : Paul S. Strauss (MMM yyyy)
25**=======================================================================*/
26/*=======================================================================
27 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), ***
28 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. ***
29 *** ***
30 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS ***
31 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR ***
32 *** WRITTEN AUTHORIZATION OF FEI S.A.S. ***
33 *** ***
34 *** RESTRICTED RIGHTS LEGEND ***
35 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS ***
36 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN ***
37 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT ***
38 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN ***
39 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. ***
40 *** ***
41 *** COPYRIGHT (C) 1996-2014 BY FEI S.A.S, ***
42 *** BORDEAUX, FRANCE ***
43 *** ALL RIGHTS RESERVED ***
44**=======================================================================*/
45/*=======================================================================
46** Modified by : VSG (MMM YYYY)
47**=======================================================================*/
48
49
50#ifndef _SO_TRANSCRIBE_
51#define _SO_TRANSCRIBE_
52
53#include <Inventor/misc/SoBasic.h>
54#include <Inventor/SbString.h>
55#include <Inventor/SbDict.h>
56
57class SoGroup;
58class SoInput;
59class SoNode;
60class SoOutput;
61
63//
64// Class: SoTranSender
65//
66// This stores database changes that are to be transcribed. The
67// changes are written to an SoOutput instance allocated and managed
68// by the caller.
69//
70// These database change routines are supported:
71//
72// INSERT node [parent n]
73// Creates and adds a node to other database. With 1 argument,
74// the node is added as the last child of the root of the
75// database. With 3 arguments, the node is added as the nth
76// child of the given parent. (The parent may be NULL to
77// indicate the root.) Note that if the inserted node is already
78// in the graph, a link is made from the parent to the existing
79// version of the node. (Therefore, if the new node is different
80// from the old one, any changes are lost.)
81//
82// REMOVE parent n
83// Removes nth child from the given parent node. (The parent may
84// be NULL to indicate the root.)
85//
86// REPLACE parent n newNode
87// This is exactly equivalent to "REMOVE parent n" followed by
88// "INSERT newNode parent n".
89//
90// MODIFY node
91// Updates the field data for the given node to the new
92// contents. Note that this changes only field data; children of
93// groups are not affected, nor is any non-field instance data.
94//
96
120 public:
121
127
132
133
137 SoOutput * getOutput() const { return out; }
138
143 void insert(SoNode *node);
144
150 void insert(SoNode *node, SoNode *parent, int n);
151
156 void remove(SoNode *parent, int n);
157
163 void replace(SoNode *parent, int n, SoNode *newNode);
169 void modify(SoNode *node);
170
177
178 private:
179 SoOutput *out;
180
181 // Adding items to send
182 void addBytes(const void *bytes, size_t nBytes);
183 void addCommand(int command);
184 void addInt(int n);
185 void addNode(SoNode *node, SbBool addNames = TRUE);
186 void addNodeNames(const SoNode *root);
187 void addNodeRef(const SoNode *node);
188 void addString(const char *cmdString);
189
190 friend class SoTranReceiver;
191};
192
194//
195// Class: SoTranReceiver
196//
197// An SoTranReceiver is used on the receiving end to interpret the
198// data packaged up by an SoTranSender. It is given a root node that
199// is the default place to add incoming nodes. The input for the
200// receiver comes from an SoInput.
201//
203
224
225 public:
226
234
239
246
247 private:
248 SoGroup *root;
249 SbDict nameToEntryDict; // Maps node keyname to SoTranDictEntry
250 SbDict nodeToNameDict; // Maps node pointer to node keyname
251
252 // Interprets one database change command (with given code) from stream.
253 // Sets done to TRUE if end command was found. Returns T/F error status.
254 SbBool interpretCommand(int commandCode, SoInput *in, SbBool &done);
255
256 // Gets a node and node names from the input
257 SbBool getNodeAndNames(SoInput *in, SoNode *&node);
258
259 // Gets node from input
260 SbBool getNode(SoInput *in, SoNode *&root);
261
262 // Recursively gets node names and sets up dictionaries.
263 SbBool getNodeNames(SoInput *in, SoNode *root,
264 SbBool lookForNode, SoNode *&oldRoot);
265
266 // Gets reference to a node, looks it up in dictionary, returns
267 // node pointer.
268 SbBool getNodeReference(SoInput *in, SoNode *&node);
269
270 // Removes reference to node in dictionaries, recursively.
271 void removeNodeReferences(SoNode *node);
272
273 // Adds an entry to the dictionaries
274 void addEntry(SoNode *node, SbName &name);
275
276 // Deletes (frees up) an entry from the nodeDict
277 static void deleteDictEntry(uintptr_t key, void *value);
278};
279
280#endif /* _SO_TRANSCRIBE_ */
281
282
283
Character string stored in a hash table.
Definition SbName.h:162
Base class for all group nodes.
Definition SoGroup.h:122
Used to read Open Inventor data files.
Definition SoInput.h:363
Abstract base class for all database nodes.
Definition SoNode.h:145
Used to write Open Inventor data files.
Definition SoOutput.h:186
Interprets database changes for transcription.
SbBool interpret(SoInput *in)
Interprets the transcription commands found in the given input stream.
~SoTranReceiver()
Destructor.
SoTranReceiver(SoGroup *rootNode)
Constructor.
Sends database changes for transcription.
void prepareToSend()
Prepares an SoTranSender instance for transcription, making sure the transcription area is complete a...
SoOutput * getOutput() const
void modify(SoNode *node)
Adds a MODIFY command to the transcription area.
SoTranSender(SoOutput *output)
Constructor.
void remove(SoNode *parent, int n)
Adds a REMOVE command to the transcription area.
~SoTranSender()
Destructor.
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.
int SbBool
Boolean type.
Definition SbBase.h:87