22 #ifndef CO_DATAISTREAM_H
23 #define CO_DATAISTREAM_H
29 #include <lunchbox/stdExt.h>
37 namespace detail {
class DataIStream; }
46 virtual size_t nRemainingBuffers()
const = 0;
48 virtual uint128_t getVersion()
const = 0;
49 virtual void reset() { _reset(); }
50 void setSwapping(
const bool onOff );
51 CO_API
bool isSwapping()
const;
59 { _read( &value,
sizeof( value )); _swap( value );
return *
this; }
71 template<
class K,
class V >
78 template<
class K,
class V >
89 # ifdef CO_IGNORE_BYTESWAP
91 template<
class T >
static void swap( T& ) { }
94 template<
class T >
static void swap( T& v ) { lunchbox::byteswap(v); }
108 template<
typename O,
typename C >
109 void deserializeChildren( O*
object,
const std::vector< C* >& old,
110 std::vector< C* >& result );
153 virtual bool getNextBuffer( uint32_t& compressor, uint32_t& nChunks,
154 const void** chunkData, uint64_t& size )=0;
158 detail::DataIStream*
const _impl;
161 CO_API
void _read(
void* data, uint64_t size );
167 CO_API
bool _checkBuffer();
168 CO_API
void _reset();
170 const uint8_t* _decompress(
const void* data,
const uint32_t name,
171 const uint32_t nChunks,
172 const uint64_t dataSize );
176 DataIStream& _readFlatVector ( std::vector< T >& value )
180 LBASSERTINFO( nElems < LB_BIT48,
181 "Out-of-sync co::DataIStream: " << nElems <<
" elements?" );
182 value.resize(
size_t( nElems ));
184 *
this >>
Array< T >( &value.front(), nElems );
189 template<
class T >
void _swap( T& value )
const
190 {
if( isSwapping( ))
swap( value ); }
193 template<
class T >
void _swap( Array< T > array )
const
197 #pragma omp parallel for
198 for( ssize_t i = 0; i < ssize_t( array.num ); ++i )
199 swap( array.data[i] );
204 #include "dataIStream.ipp"
206 #endif //CO_DATAISTREAM_H
A wrapper to (de)serialize arrays.
CO_API const void * getRemainingBuffer(const uint64_t size)
static void swap(T &v)
Byte-swap a plain data item.
lunchbox::RefPtr< Node > NodePtr
A reference pointer for Node pointers.
A std::istream-like input data stream for binary data.
virtual CO_API NodePtr getMaster()=0
CO_API uint64_t getRemainingBufferSize()
DataIStream & operator>>(T &value)
Read a plain data item.