#include <OSGBINWriter.h>
Inheritance diagram for osg::BINWriter::BinaryFileHandler:

Public Member Functions | |
| BinaryFileHandler (std::ostream &os) | |
| virtual | ~BinaryFileHandler () |
| void | write (MemoryHandle mem, UInt32 size) |
Put | |
| *void | put (void const *src, UInt32 size) |
| void | putAndFree (MemoryHandle src, UInt32 size) |
| void | putValue (const bool &value) |
| void | putValue (const UInt8 &value) |
| void | putValue (const UInt16 &value) |
| void | putValue (const UInt32 &value) |
| void | putValue (const UInt64 &value) |
| void | putValue (const Int8 &value) |
| void | putValue (const Int16 &value) |
| void | putValue (const Int32 &value) |
| void | putValue (const Int64 &value) |
| void | putValue (const Real16 &value) |
| void | putValue (const Real32 &value) |
| void | putValue (const Real64 &value) |
| void | putValue (const Real128 &value) |
| void | putValue (const std::string &value) |
| void | putValues (const bool *value, UInt32 size) |
| void | putValues (const UInt8 *value, UInt32 size) |
| void | putValues (const UInt16 *value, UInt32 size) |
| void | putValues (const UInt32 *value, UInt32 size) |
| void | putValues (const UInt64 *value, UInt32 size) |
| void | putValues (const Int8 *value, UInt32 size) |
| void | putValues (const Int16 *value, UInt32 size) |
| void | putValues (const Int32 *value, UInt32 size) |
| void | putValues (const Int64 *value, UInt32 size) |
| void | putValues (const Real16 *value, UInt32 size) |
| void | putValues (const Real32 *value, UInt32 size) |
| void | putValues (const Real64 *value, UInt32 size) |
| void | putValues (const Real128 *value, UInt32 size) |
| void | putValues (const std::string *value, UInt32 size) |
Get | |
| *void | get (void *dst, UInt32 size) |
| void | getAndAlloc (MemoryHandle &src, UInt32 size) |
| void | getValue (bool &value) |
| void | getValue (UInt8 &value) |
| void | getValue (UInt16 &value) |
| void | getValue (UInt32 &value) |
| void | getValue (UInt64 &value) |
| void | getValue (Int8 &value) |
| void | getValue (Int16 &value) |
| void | getValue (Int32 &value) |
| void | getValue (Int64 &value) |
| void | getValue (Real16 &value) |
| void | getValue (Real32 &value) |
| void | getValue (Real64 &value) |
| void | getValue (Real128 &value) |
| void | getValue (std::string &value) |
| void | getValues (bool *value, UInt32 size) |
| void | getValues (UInt8 *value, UInt32 size) |
| void | getValues (UInt16 *value, UInt32 size) |
| void | getValues (UInt32 *value, UInt32 size) |
| void | getValues (UInt64 *value, UInt32 size) |
| void | getValues (Int8 *value, UInt32 size) |
| void | getValues (Int16 *value, UInt32 size) |
| void | getValues (Int32 *value, UInt32 size) |
| void | getValues (Int64 *value, UInt32 size) |
| void | getValues (Real16 *value, UInt32 size) |
| void | getValues (Real32 *value, UInt32 size) |
| void | getValues (Real64 *value, UInt32 size) |
| void | getValues (Real128 *value, UInt32 size) |
| void | getValues (std::string *value, UInt32 size) |
Helper | |
| *virtual void | forceCopy (void) |
| virtual void | forceDirectIO (void) |
| void | flush (void) |
| write data not yet written | |
| void | setNetworkOrder (bool value) |
| bool | getNetworkOrder (void) |
Protected Types | |
| typedef std::vector< MemoryBlock > | BuffersT |
| typedef std::list< MemoryHandle > | FreeMemT |
Protected Member Functions | |
Read | |
| *BuffersT::iterator | readBufBegin (void) |
| BuffersT::iterator | readBufEnd (void) |
| void | readBufAdd (MemoryHandle mem, UInt32 size, UInt32 dataSize=0) |
| void | readBufClear (void) |
| virtual void | read (MemoryHandle src, UInt32 size) |
| virtual void | readBuffer (void) |
Write | |
| *BuffersT::iterator | writeBufBegin (void) |
| BuffersT::iterator | writeBufEnd (void) |
| void | writeBufAdd (MemoryHandle mem, UInt32 size, UInt32 dataSize=0) |
| void | writeBufClear (void) |
| virtual void | writeBuffer (void) |
Helper | |
| *bool | isReadBufferEmpty (void) |
Protected Attributes | |
Member | |
| *BuffersT | _readBuffers |
| BuffersT | _writeBuffers |
| BuffersT | _zeroCopyBuffers |
| UInt32 | _zeroCopyThreshold |
| FreeMemT | _freeMem |
| BuffersT::iterator | _currentReadBuffer |
| UInt32 | _currentReadBufferPos |
| BuffersT::iterator | _currentWriteBuffer |
| UInt32 | _currentWriteBufferPos |
| bool | _networkOrder |
Private Member Functions | |
| BinaryFileHandler (const BinaryFileHandler &source) | |
| void | operator= (const BinaryFileHandler &source) |
Private Attributes | |
| std::vector< UInt8 > | _writeMemory |
| std::ostream & | _os |
Definition at line 97 of file OSGBINWriter.h.
|
|
Definition at line 213 of file OSGBinaryDataHandler.h. |
|
|
Definition at line 214 of file OSGBinaryDataHandler.h. |
|
|
constructor Definition at line 399 of file OSGBINWriter.cpp. References _writeMemory, and osg::BinaryDataHandler::writeBufAdd(). 00399 : 00400 BinaryDataHandler(0), 00401 _os(os) 00402 { 00403 _writeMemory.resize(10000); 00404 writeBufAdd(&_writeMemory[0], _writeMemory.size()); 00405 }
|
|
|
destructor Definition at line 409 of file OSGBINWriter.cpp.
|
|
|
|
|
||||||||||||
|
write to binary file Reimplemented from osg::BinaryDataHandler. Definition at line 415 of file OSGBINWriter.cpp. References _os. 00416 { 00417 _os.write((const char *) mem, size); 00418 }
|
|
|
|
|
||||||||||||
|
Definition at line 83 of file OSGBinaryDataHandler.cpp. References osg::BinaryDataHandler::_currentWriteBuffer, osg::BinaryDataHandler::_currentWriteBufferPos, osg::BinaryDataHandler::_zeroCopyBuffers, osg::BinaryDataHandler::_zeroCopyThreshold, osg::osgMin(), osg::BinaryDataHandler::pushBuffer(), osg::BinaryDataHandler::write(), and osg::BinaryDataHandler::writeBufEnd(). Referenced by osg::BinaryDataHandler::putAndFree(), osg::BinaryDataHandler::putValue(), osg::BinaryDataHandler::putValues(), and osg::ClusterViewBuffer::send(). 00084 { 00085 UInt8 const *data = static_cast<UInt8 const *>(src); 00086 00087 if(_zeroCopyThreshold && size >= _zeroCopyThreshold) 00088 { 00089 if(_zeroCopyThreshold == 1) 00090 { 00091 write(const_cast<MemoryHandle>(data), size); 00092 } 00093 else 00094 { 00095 UInt8 tag = 1; 00096 00097 // we have to write a tag, to indicate the membership 00098 // of this zero copy block to the current data block 00099 put(&tag, sizeof(tag)); 00100 00101 _zeroCopyBuffers.push_back( 00102 MemoryBlock(const_cast<MemoryHandle>(data), size, size)); 00103 } 00104 } 00105 else 00106 { 00107 UInt32 copySize; 00108 00109 while(size != 0) 00110 { 00111 if(_currentWriteBuffer == writeBufEnd()) 00112 { 00113 pushBuffer(); 00114 } 00115 00116 copySize = osgMin((_currentWriteBuffer->getSize() - 00117 _currentWriteBufferPos), 00118 size); 00119 00120 memcpy(_currentWriteBuffer->getMem() + _currentWriteBufferPos, 00121 data, 00122 copySize); 00123 00124 size -= copySize; 00125 _currentWriteBufferPos += copySize; 00126 data += copySize; 00127 00128 // skip to next buffer if current buffer is full 00129 if(_currentWriteBufferPos == _currentWriteBuffer->getSize()) 00130 { 00131 _currentWriteBuffer->setDataSize(_currentWriteBufferPos); 00132 _currentWriteBuffer++; 00133 _currentWriteBufferPos = 0; 00134 } 00135 } 00136 } 00137 }
|
|
||||||||||||
|
Put data from dynamic allocated block The caller doesn't know, when the block will be written. So we are responsible for freeing this block. Definition at line 144 of file OSGBinaryDataHandler.cpp. References osg::BinaryDataHandler::_freeMem, osg::BinaryDataHandler::_zeroCopyThreshold, and osg::BinaryDataHandler::put(). 00145 { 00146 put(src, size); 00147 00148 if(_zeroCopyThreshold && size > _zeroCopyThreshold) 00149 { 00150 _freeMem.push_back(src); 00151 } 00152 else 00153 { 00154 delete [] src; 00155 } 00156 }
|
|
|
|
Definition at line 71 of file OSGBinaryDataHandler.inl. References osg::BinaryDataHandler::put().
|
|
|
Definition at line 77 of file OSGBinaryDataHandler.inl. References osg::osghtons(), and osg::BinaryDataHandler::put().
|
|
|
Definition at line 85 of file OSGBinaryDataHandler.inl. References osg::osghtonl(), and osg::BinaryDataHandler::put().
|
|
|
Definition at line 93 of file OSGBinaryDataHandler.inl. References osg::osghtonll(), and osg::BinaryDataHandler::put().
|
|
|
Definition at line 101 of file OSGBinaryDataHandler.inl. References osg::BinaryDataHandler::put().
|
|
|
Definition at line 107 of file OSGBinaryDataHandler.inl. References osg::osghtons(), and osg::BinaryDataHandler::put().
|
|
|
Definition at line 115 of file OSGBinaryDataHandler.inl. References osg::osghtonl(), and osg::BinaryDataHandler::put().
|
|
|
Definition at line 123 of file OSGBinaryDataHandler.inl. References osg::osghtonll(), and osg::BinaryDataHandler::put().
|
|
|
Definition at line 131 of file OSGBinaryDataHandler.inl. References osg::Real16::bits(), osg::osghtons(), and osg::BinaryDataHandler::put().
|
|
|
Definition at line 139 of file OSGBinaryDataHandler.inl. References osg::osghtonl(), and osg::BinaryDataHandler::put(). 00140 { 00141 UInt32 v = osghtonl( *((const UInt32 *)(&value)) ); 00142 00143 put(&v, sizeof(Real32)); 00144 }
|
|
|
Definition at line 147 of file OSGBinaryDataHandler.inl. References osg::osghtonll(), and osg::BinaryDataHandler::put(). 00148 { 00149 UInt64 v = osghtonll( *((const UInt64 *)(&value)) ); 00150 00151 put(&v, sizeof(Real64)); 00152 }
|
|
|
Definition at line 155 of file OSGBinaryDataHandler.inl. References osg::osghtonll(), and osg::BinaryDataHandler::put(). 00156 { 00157 UInt64 v = osghtonll( *( (const UInt64 *)(&value)) ); 00158 UInt64 w = osghtonll( *(((const UInt64 *)(&value)) + 1) ); 00159 00160 #if BYTE_ORDER == LITTLE_ENDIAN 00161 put(&w, sizeof(UInt64)); 00162 put(&v, sizeof(UInt64)); 00163 #else 00164 put(&v, sizeof(UInt64)); 00165 put(&w, sizeof(UInt64)); 00166 #endif 00167 }
|
|
|
Definition at line 170 of file OSGBinaryDataHandler.inl. References osg::BinaryDataHandler::put(), osg::BinaryDataHandler::putValue(), and osg::stringlen(). 00171 { 00172 UInt32 len = stringlen(value.c_str()) + 1; 00173 00174 putValue(len); 00175 00176 if(len != 0) 00177 { 00178 put(value.c_str(), len); 00179 } 00180 }
|
|
||||||||||||
|
||||||||||||
|
Definition at line 190 of file OSGBinaryDataHandler.inl. References osg::BinaryDataHandler::put().
|
|
||||||||||||
|
Definition at line 196 of file OSGBinaryDataHandler.inl. References osg::BinaryDataHandler::_networkOrder, osg::BinaryDataHandler::put(), and osg::BinaryDataHandler::putValue(). 00197 { 00198 #if BYTE_ORDER == LITTLE_ENDIAN 00199 00200 if(_networkOrder == true) 00201 { 00202 for(UInt32 i = 0; i < size; ++i) 00203 { 00204 putValue(value[i]); 00205 } 00206 } 00207 else 00208 #endif 00209 { 00210 put(value, size * sizeof(UInt16)); 00211 } 00212 }
|
|
||||||||||||
|
Definition at line 215 of file OSGBinaryDataHandler.inl. References osg::BinaryDataHandler::_networkOrder, osg::BinaryDataHandler::put(), and osg::BinaryDataHandler::putValue(). 00216 { 00217 #if BYTE_ORDER == LITTLE_ENDIAN 00218 if(_networkOrder == true) 00219 { 00220 for(UInt32 i = 0; i < size; ++i) 00221 { 00222 putValue(value[i]); 00223 } 00224 } 00225 else 00226 #endif 00227 { 00228 put(value, size * sizeof(UInt32)); 00229 } 00230 }
|
|
||||||||||||
|
Definition at line 233 of file OSGBinaryDataHandler.inl. References osg::BinaryDataHandler::_networkOrder, osg::BinaryDataHandler::put(), and osg::BinaryDataHandler::putValue(). 00234 { 00235 #if BYTE_ORDER == LITTLE_ENDIAN 00236 if(_networkOrder == true) 00237 { 00238 for(UInt32 i = 0; i < size; ++i) 00239 { 00240 putValue(value[i]); 00241 } 00242 } 00243 else 00244 #endif 00245 { 00246 put(value, size * sizeof(UInt64)); 00247 } 00248 }
|
|
||||||||||||
|
Definition at line 251 of file OSGBinaryDataHandler.inl. References osg::BinaryDataHandler::_networkOrder, osg::BinaryDataHandler::put(), and osg::BinaryDataHandler::putValue(). 00252 { 00253 #if BYTE_ORDER == LITTLE_ENDIAN 00254 if(_networkOrder == true) 00255 { 00256 for(UInt32 i = 0; i < size; ++i) 00257 { 00258 putValue(value[i]); 00259 } 00260 } 00261 else 00262 #endif 00263 { 00264 put(value, size * sizeof(Int8)); 00265 } 00266 }
|
|
||||||||||||
|
Definition at line 269 of file OSGBinaryDataHandler.inl. References osg::BinaryDataHandler::_networkOrder, osg::BinaryDataHandler::put(), and osg::BinaryDataHandler::putValue(). 00270 { 00271 #if BYTE_ORDER == LITTLE_ENDIAN 00272 if(_networkOrder == true) 00273 { 00274 for(UInt32 i = 0; i < size; ++i) 00275 { 00276 putValue(value[i]); 00277 } 00278 } 00279 else 00280 #endif 00281 { 00282 put(value, size * sizeof(Int16)); 00283 } 00284 }
|
|
||||||||||||
|
Definition at line 287 of file OSGBinaryDataHandler.inl. References osg::BinaryDataHandler::_networkOrder, osg::BinaryDataHandler::put(), and osg::BinaryDataHandler::putValue(). 00288 { 00289 #if BYTE_ORDER == LITTLE_ENDIAN 00290 if(_networkOrder == true) 00291 { 00292 for(UInt32 i = 0; i < size; ++i) 00293 { 00294 putValue(value[i]); 00295 } 00296 } 00297 else 00298 #endif 00299 { 00300 put(value, size * sizeof(Int32)); 00301 } 00302 }
|
|
||||||||||||
|
Definition at line 305 of file OSGBinaryDataHandler.inl. References osg::BinaryDataHandler::_networkOrder, osg::BinaryDataHandler::put(), and osg::BinaryDataHandler::putValue(). 00306 { 00307 #if BYTE_ORDER == LITTLE_ENDIAN 00308 if(_networkOrder == true) 00309 { 00310 for(UInt32 i = 0; i < size; ++i) 00311 { 00312 putValue(value[i]); 00313 } 00314 } 00315 else 00316 #endif 00317 { 00318 put(value, size * sizeof(Int64)); 00319 } 00320 }
|
|
||||||||||||
|
Definition at line 323 of file OSGBinaryDataHandler.inl. References osg::BinaryDataHandler::_networkOrder, osg::BinaryDataHandler::put(), and osg::BinaryDataHandler::putValue(). 00324 { 00325 #if BYTE_ORDER == LITTLE_ENDIAN 00326 if(_networkOrder == true) 00327 { 00328 for(UInt32 i = 0; i < size; ++i) 00329 { 00330 putValue(value[i]); 00331 } 00332 } 00333 else 00334 #endif 00335 { 00336 put(value, size * sizeof(Real16)); 00337 } 00338 }
|
|
||||||||||||
|
Definition at line 341 of file OSGBinaryDataHandler.inl. References osg::BinaryDataHandler::_networkOrder, osg::BinaryDataHandler::put(), and osg::BinaryDataHandler::putValue(). 00342 { 00343 #if BYTE_ORDER == LITTLE_ENDIAN 00344 if(_networkOrder == true) 00345 { 00346 for(UInt32 i = 0; i < size; ++i) 00347 { 00348 putValue(value[i]); 00349 } 00350 } 00351 else 00352 #endif 00353 { 00354 put(value, size * sizeof(Real32)); 00355 } 00356 }
|
|
||||||||||||
|
Definition at line 359 of file OSGBinaryDataHandler.inl. References osg::BinaryDataHandler::_networkOrder, osg::BinaryDataHandler::put(), and osg::BinaryDataHandler::putValue(). 00360 { 00361 #if BYTE_ORDER == LITTLE_ENDIAN 00362 if(_networkOrd |