Changeset 13041 for OpenSceneGraph/trunk/include/osgDB/OutputStream
- Timestamp:
- 03/21/12 18:36:20 (15 months ago)
- Files:
-
- 1 modified
-
OpenSceneGraph/trunk/include/osgDB/OutputStream (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/include/osgDB/OutputStream
r12410 r13041 42 42 } 43 43 } 44 44 45 45 const std::string& getField() const { return _field; } 46 46 const std::string& getError() const { return _error; } 47 47 48 48 protected: 49 49 std::string _field; … … 56 56 typedef std::map<const osg::Array*, unsigned int> ArrayMap; 57 57 typedef std::map<const osg::Object*, unsigned int> ObjectMap; 58 58 59 59 enum WriteType 60 60 { … … 64 64 WRITE_OBJECT 65 65 }; 66 66 67 67 enum WriteImageHint 68 68 { … … 73 73 WRITE_EXTERNAL_FILE /*!< Write Image::data() to disk and use it as external file */ 74 74 }; 75 75 76 76 OutputStream( const osgDB::Options* options ); 77 77 virtual ~OutputStream(); 78 78 79 79 bool isBinary() const { return _out->isBinary(); } 80 80 const std::string& getSchemaName() const { return _schemaName; } 81 81 const osgDB::Options* getOptions() const { return _options.get(); } 82 82 83 83 void setWriteImageHint( WriteImageHint hint ) { _writeImageHint = hint; } 84 84 WriteImageHint getWriteImageHint() const { return _writeImageHint; } 85 85 86 86 // Serialization related functions 87 87 OutputStream& operator<<( bool b ) { _out->writeBool(b); return *this; } … … 100 100 OutputStream& operator<<( std::ostream& (*fn)(std::ostream&) ) { _out->writeStream(fn); return *this; } 101 101 OutputStream& operator<<( std::ios_base& (*fn)(std::ios_base&) ) { _out->writeBase(fn); return *this; } 102 102 103 103 OutputStream& operator<<( const ObjectGLenum& value ) { _out->writeGLenum(value); return *this; } 104 104 OutputStream& operator<<( const ObjectProperty& prop ) { _out->writeProperty(prop); return *this; } 105 105 OutputStream& operator<<( const ObjectMark& mark ) { _out->writeMark(mark); return *this; } 106 106 107 107 OutputStream& operator<<( const osg::Vec2b& v ); 108 108 OutputStream& operator<<( const osg::Vec3b& v ); … … 122 122 OutputStream& operator<<( const osg::Matrixf& mat ); 123 123 OutputStream& operator<<( const osg::Matrixd& mat ); 124 124 125 125 OutputStream& operator<<( const osg::Array* a ) { writeArray(a); return *this; } 126 126 OutputStream& operator<<( const osg::Image* img ) { writeImage(img); return *this; } 127 127 OutputStream& operator<<( const osg::PrimitiveSet* p ) { writePrimitiveSet(p); return *this; } 128 128 OutputStream& operator<<( const osg::Object* obj ) { writeObject(obj); return *this; } 129 129 130 130 OutputStream& operator<<( const osg::ref_ptr<osg::Array>& ptr ) { writeArray(ptr.get()); return *this; } 131 131 OutputStream& operator<<( const osg::ref_ptr<osg::Image>& ptr ) { writeImage(ptr.get()); return *this; } 132 132 OutputStream& operator<<( const osg::ref_ptr<osg::PrimitiveSet>& ptr ) { writePrimitiveSet(ptr.get()); return *this; } 133 133 134 134 template<typename T> OutputStream& operator<<( const osg::ref_ptr<T>& ptr ) 135 135 { writeObject(ptr.get()); return *this; } 136 136 137 137 // Convenient methods for writing 138 138 void writeWrappedString( const std::string& str ) { _out->writeWrappedString(str); } … … 149 149 void writeObject( const osg::Object* obj ); 150 150 void writeObjectFields( const osg::Object* obj ); 151 151 152 152 /// set an output iterator, used directly when not using OutputStream with a traditional file releated stream. 153 153 void setOutputIterator( OutputIterator* oi ) { _out = oi; } … … 157 157 158 158 void compress( std::ostream* ostream ); 159 159 160 160 // Schema handlers 161 161 void writeSchema( std::ostream& fout ); 162 162 163 163 // Exception handlers 164 164 inline void throwException( const std::string& msg ); 165 165 const OutputException* getException() const { return _exception.get(); } 166 166 167 167 protected: 168 168 template<typename T> 169 169 void writeArrayImplementation( const T*, int write_size, unsigned int numInRow=1 ); 170 170 171 171 unsigned int findOrCreateArrayID( const osg::Array* array, bool& newID ); 172 172 unsigned int findOrCreateObjectID( const osg::Object* obj, bool& newID ); 173 173 174 174 ArrayMap _arrayMap; 175 175 ObjectMap _objectMap; 176 176 177 177 WriteImageHint _writeImageHint; 178 178 bool _useSchemaData;
