Open Inventor Reference
|
00001 /* 00002 * 00003 * Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved. 00004 * 00005 * This library is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU Lesser General Public 00007 * License as published by the Free Software Foundation; either 00008 * version 2.1 of the License, or (at your option) any later version. 00009 * 00010 * This library is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Lesser General Public License for more details. 00014 * 00015 * Further, this software is distributed without any warranty that it is 00016 * free of the rightful claim of any third person regarding infringement 00017 * or the like. Any license provided herein, whether implied or 00018 * otherwise, applies only to this software file. Patent licenses, if 00019 * any, provided herein do not apply to combinations of this program with 00020 * other software, or any other product whatsoever. 00021 * 00022 * You should have received a copy of the GNU Lesser General Public 00023 * License along with this library; if not, write to the Free Software 00024 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00025 * 00026 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, 00027 * Mountain View, CA 94043, or: 00028 * 00029 * http://www.sgi.com 00030 * 00031 * For further information regarding this notice, see: 00032 * 00033 * http://oss.sgi.com/projects/GenInfo/NoticeExplan/ 00034 * 00035 */ 00036 00037 00038 /* 00039 * Copyright (C) 1990,91 Silicon Graphics, Inc. 00040 * 00041 _______________________________________________________________________ 00042 ______________ S I L I C O N G R A P H I C S I N C . ____________ 00043 | 00044 | $Revision $ 00045 | 00046 | Description: 00047 | This file contains definitions of the SoTranSender and SoTranReceiver 00048 | classes used for transcribing Inventor data. Transcribing is the 00049 | process of packaging changes to a database and sending them over a 00050 | "wire" to another database. 00051 | 00052 | Classes: 00053 | SoTranSender, SoTranReceiver 00054 | 00055 | Author(s) : Paul S. Strauss 00056 | 00057 ______________ S I L I C O N G R A P H I C S I N C . ____________ 00058 _______________________________________________________________________ 00059 */ 00060 00061 #ifndef _SO_TRANSCRIBE_ 00062 #define _SO_TRANSCRIBE_ 00063 00064 #include <Inventor/misc/SoBasic.h> 00065 #include <Inventor/SbString.h> 00066 #include <Inventor/SbDict.h> 00067 00068 class SoGroup; 00069 class SoInput; 00070 class SoNode; 00071 class SoOutput; 00072 00073 00076 00095 00096 00097 class INVENTOR_API SoTranSender { 00098 public: 00099 00102 SoTranSender(SoOutput *output); 00103 00105 ~SoTranSender() {} 00106 00108 SoOutput * getOutput() const { return out; } 00109 00112 void insert(SoNode *node); 00117 void insert(SoNode *node, SoNode *parent, int n); 00120 void remove(SoNode *parent, int n); 00124 void replace(SoNode *parent, int n, SoNode *newNode); 00129 void modify(SoNode *node); 00130 00134 void prepareToSend(); 00135 00136 private: 00137 SoOutput *out; 00138 00140 void addBytes(const void *bytes, size_t nBytes); 00141 void addCommand(int command); 00142 void addInt(int n); 00143 void addNode(SoNode *node, SbBool addNames = TRUE); 00144 void addNodeNames(const SoNode *root); 00145 void addNodeRef(const SoNode *node); 00146 void addString(const char *cmdString); 00147 00148 friend class SoTranReceiver; 00149 }; 00150 00151 00154 00170 00171 00172 class INVENTOR_API SoTranReceiver { 00173 00174 public: 00175 00179 SoTranReceiver(SoGroup *rootNode); 00180 00182 ~SoTranReceiver(); 00183 00188 SbBool interpret(SoInput *in); 00189 00190 private: 00191 SoGroup *root; 00192 SbDict nameToEntryDict; 00193 SbDict nodeToNameDict; 00194 00197 SbBool interpretCommand(int commandCode, SoInput *in, SbBool &done); 00198 00200 SbBool getNodeAndNames(SoInput *in, SoNode *&node); 00201 00203 SbBool getNode(SoInput *in, SoNode *&root); 00204 00206 SbBool getNodeNames(SoInput *in, SoNode *root, 00207 SbBool lookForNode, SoNode *&oldRoot); 00208 00211 SbBool getNodeReference(SoInput *in, SoNode *&node); 00212 00214 void removeNodeReferences(SoNode *node); 00215 00217 void addEntry(SoNode *node, SbName &name); 00218 00220 static void deleteDictEntry(unsigned long key, void *value); 00221 00223 00224 }; 00225 00226 #endif /* _SO_TRANSCRIBE_ */ 00227