00001 /*---------------------------------------------------------------------------*\ 00002 * OpenSG * 00003 * * 00004 * * 00005 * Copyright (C) 2000-2002 by the OpenSG Forum * 00006 * * 00007 * www.opensg.org * 00008 * * 00009 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de * 00010 * * 00011 \*---------------------------------------------------------------------------*/ 00012 /*---------------------------------------------------------------------------*\ 00013 * License * 00014 * * 00015 * This library is free software; you can redistribute it and/or modify it * 00016 * under the terms of the GNU Library General Public License as published * 00017 * by the Free Software Foundation, version 2. * 00018 * * 00019 * This library is distributed in the hope that it will be useful, but * 00020 * WITHOUT ANY WARRANTY; without even the implied warranty of * 00021 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00022 * Library General Public License for more details. * 00023 * * 00024 * You should have received a copy of the GNU Library General Public * 00025 * License along with this library; if not, write to the Free Software * 00026 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 00027 * * 00028 \*---------------------------------------------------------------------------*/ 00029 /*---------------------------------------------------------------------------*\ 00030 * Changes * 00031 * * 00032 * * 00033 * * 00034 * * 00035 * * 00036 * * 00037 \*---------------------------------------------------------------------------*/ 00038 00039 #ifndef _OSGBINWRITER_H_ 00040 #define _OSGBINWRITER_H_ 00041 #ifdef __sgi 00042 #pragma once 00043 #endif 00044 #include <OSGConfig.h> 00045 00046 #include <map> 00047 #include <vector> 00048 00049 #include <OSGNode.h> 00050 #include <OSGBinaryDataHandler.h> 00051 #include <OSGBaseTypes.h> 00052 00053 OSG_BEGIN_NAMESPACE 00054 00055 class OSG_SYSTEMLIB_DLLMAPPING BINWriter 00056 { 00057 /*========================== PUBLIC =================================*/ 00058 public: 00059 00060 /*---------------------------------------------------------------------*/ 00064 BINWriter(std::ostream &os); 00065 virtual ~BINWriter(void ); 00066 00068 /*---------------------------------------------------------------------*/ 00072 bool write( NodePtr node ); 00073 bool write(std::vector<NodePtr> nodes); 00074 00076 /*========================= PROTECTED ===============================*/ 00077 protected: 00078 00079 /*---------------------------------------------------------------------*/ 00084 struct FCInfo 00085 { 00086 OSG::IDString type; 00087 FieldContainerPtr ptr; 00088 BitVector mask; //should match UInt32 00089 FCInfo(void); 00090 }; 00091 //FieldContainerId is of type UInt32 00092 typedef std::map< UInt32, FCInfo > FCInfoMap; 00093 typedef std::map<std::string, std::vector<UInt32> > FCTypeIdMap; 00094 00097 class BinaryFileHandler : public BinaryDataHandler 00098 { 00099 public: 00100 BinaryFileHandler(std::ostream &os); 00101 virtual ~BinaryFileHandler(); 00102 00103 void write(MemoryHandle mem, UInt32 size); 00104 00105 private: 00106 00107 std::vector<UInt8> _writeMemory; 00108 std::ostream &_os; 00109 00110 BinaryFileHandler(const BinaryFileHandler &source); 00111 void operator =(const BinaryFileHandler &source); 00112 }; 00114 /*---------------------------------------------------------------------*/ 00118 void addToIdMap (FieldContainerPtr fcPtr ); 00119 void writeFileHeader (void ); 00120 void doIndexFC (FieldContainerPtr fieldConPtr); 00121 void doWriteIndexedFC(void ); 00122 00124 /*========================== PRIVATE ================================*/ 00125 private: 00126 /*---------------------------------------------------------------------*/ 00130 FCInfoMap _fcMap; 00131 FCTypeIdMap _fcIdMap; 00132 BinaryFileHandler _outFileHandler; 00133 std::vector<NodePtr> _vec_pRootNodes; 00134 bool _valid_stream; 00135 00138 BINWriter(const BINWriter &source); 00139 void operator =(const BINWriter &source); 00140 }; 00141 00142 OSG_END_NAMESPACE 00143 00144 #define OSGBINWRITER_HEADER_CVSID "@(#)$Id: $" 00145 00146 #endif /* _OSGBINWRITER_H_ */
1.4.3