Collage  1.5.0
High-performance C++ library for developing object-oriented distributed applications.
co::DataIStream Class Referenceabstract

A std::istream-like input data stream for binary data. More...

#include <dataIStream.h>

+ Inheritance diagram for co::DataIStream:
+ Collaboration diagram for co::DataIStream:

Internal

virtual size_t nRemainingBuffers () const =0
 
virtual uint128_t getVersion () const =0
 
virtual void reset ()
 
void setSwapping (const bool onOff)
 
CO_API bool isSwapping () const
 
DataIStreamoperator= (const DataIStream &rhs)
 
CO_API DataIStream (const bool swap)
 
 DataIStream (const DataIStream &)
 
virtual CO_API ~DataIStream ()
 
virtual bool getNextBuffer (uint32_t &compressor, uint32_t &nChunks, const void **chunkData, uint64_t &size)=0
 

Data input

template<typename T >
read ()
 
template<class T >
DataIStreamoperator>> (T &value)
 Read a plain data item. More...
 
template<class T >
DataIStreamoperator>> (Array< T > array)
 Read a C array. More...
 
template<class T >
DataIStreamoperator>> (lunchbox::RefPtr< T > &)
 Read a lunchbox::RefPtr. More...
 
template<class T >
DataIStreamoperator>> (lunchbox::Buffer< T > &)
 Read a lunchbox::Buffer. More...
 
template<class T >
DataIStreamoperator>> (std::vector< T > &)
 Read a std::vector of serializable items. More...
 
template<class K , class V >
DataIStreamoperator>> (std::map< K, V > &)
 Read a std::map of serializable items. More...
 
template<class T >
DataIStreamoperator>> (std::set< T > &)
 Read a std::set of serializable items. More...
 
template<class K , class V >
DataIStreamoperator>> (stde::hash_map< K, V > &)
 Read a stde::hash_map of serializable items. More...
 
template<class T >
DataIStreamoperator>> (stde::hash_set< T > &)
 Read a stde::hash_set of serializable items. More...
 
template<typename O , typename C >
void deserializeChildren (O *object, const std::vector< C * > &old, std::vector< C * > &result)
 
CO_API const void * getRemainingBuffer (const uint64_t size)
 
CO_API uint64_t getRemainingBufferSize ()
 
bool wasUsed () const
 
bool hasData ()
 
virtual CO_API NodePtr getRemoteNode () const =0
 
virtual CO_API LocalNodePtr getLocalNode () const =0
 
template<class T >
static void swap (T &v)
 Byte-swap a plain data item. More...
 

Specialized input operators

template<>
DataIStreamoperator>> (std::string &str)
 Read a std::string. More...
 
template<>
DataIStreamoperator>> (Object *&object)
 Deserialize an object (id+version). More...
 
template<>
DataIStreamoperator>> (std::vector< uint8_t > &value)
 Optimized specialization to read a std::vector of uint8_t. More...
 
template<>
DataIStreamoperator>> (std::vector< uint16_t > &value)
 Optimized specialization to read a std::vector of uint16_t. More...
 
template<>
DataIStreamoperator>> (std::vector< int16_t > &value)
 Optimized specialization to read a std::vector of int16_t. More...
 
template<>
DataIStreamoperator>> (std::vector< uint32_t > &value)
 Optimized specialization to read a std::vector of uint32_t. More...
 
template<>
DataIStreamoperator>> (std::vector< int32_t > &value)
 Optimized specialization to read a std::vector of int32_t. More...
 
template<>
DataIStreamoperator>> (std::vector< uint64_t > &value)
 Optimized specialization to read a std::vector of uint64_t. More...
 
template<>
DataIStreamoperator>> (std::vector< int64_t > &value)
 Optimized specialization to read a std::vector of int64_t. More...
 
template<>
DataIStreamoperator>> (std::vector< float > &value)
 Optimized specialization to read a std::vector of float. More...
 
template<>
DataIStreamoperator>> (std::vector< double > &value)
 Optimized specialization to read a std::vector of double. More...
 
template<>
DataIStreamoperator>> (std::vector< ObjectVersion > &value)
 Optimized specialization to read a std::vector of ObjectVersion. More...
 

Detailed Description

A std::istream-like input data stream for binary data.

Definition at line 41 of file dataIStream.h.

Member Function Documentation

virtual CO_API LocalNodePtr co::DataIStream::getLocalNode ( ) const
pure virtual
Returns
the receiver of the istream.

Implemented in co::ICommand.

CO_API const void* co::DataIStream::getRemainingBuffer ( const uint64_t  size)
Deprecated:
Get the pointer to the remaining data in the current buffer.

The usage of this method is discouraged, no endian conversion or bounds checking is performed by the DataIStream on the returned raw pointer.

The buffer is advanced by the given size. If not enough data is present, 0 is returned and the buffer is unchanged.

The data written to the DataOStream by the sender is bucketized, it is sent in multiple blocks. The remaining buffer and its size points into one of the buffers, i.e., not all the data sent is returned by this function. However, a write operation on the other end is never segmented, that is, if the application writes n bytes to the DataOStream, a symmetric read from the DataIStream has at least n bytes available.

Parameters
sizethe number of bytes to advance the buffer
Version
1.0

Referenced by operator>>().

+ Here is the caller graph for this function:

CO_API uint64_t co::DataIStream::getRemainingBufferSize ( )
Returns
the size of the remaining data in the current buffer.
Version
1.0

Referenced by operator>>().

+ Here is the caller graph for this function:

virtual CO_API NodePtr co::DataIStream::getRemoteNode ( ) const
pure virtual
Returns
the provider of the istream.

Implemented in co::ICommand.

bool co::DataIStream::hasData ( )
inline
Returns
true if not all data has been read.
Version
1.0

Definition at line 155 of file dataIStream.h.

template<>
DataIStream& co::DataIStream::operator>> ( std::string &  str)
inline

Read a std::string.

Definition at line 28 of file dataIStream.ipp.

References getRemainingBuffer(), and getRemainingBufferSize().

+ Here is the call graph for this function:

template<>
DataIStream& co::DataIStream::operator>> ( Object *&  object)
inline

Deserialize an object (id+version).

Definition at line 48 of file dataIStream.ipp.

References co::Object::getID(), co::ObjectVersion::identifier, and co::ObjectVersion::version.

+ Here is the call graph for this function:

template<class T >
DataIStream& co::DataIStream::operator>> ( T &  value)
inline

Read a plain data item.

Version
1.0

Definition at line 63 of file dataIStream.h.

template<class T >
DataIStream& co::DataIStream::operator>> ( Array< T >  array)
inline

Read a C array.

Version
1.0

Definition at line 67 of file dataIStream.h.

template<class T >
DataIStream& co::DataIStream::operator>> ( lunchbox::RefPtr< T > &  )

Read a lunchbox::RefPtr.

Refcount has to managed by caller.

Version
1.1
template<class T >
DataIStream& co::DataIStream::operator>> ( lunchbox::Buffer< T > &  )

Read a lunchbox::Buffer.

Version
1.0
template<class T >
DataIStream& co::DataIStream::operator>> ( std::vector< T > &  )

Read a std::vector of serializable items.

Version
1.0
template<class K , class V >
DataIStream& co::DataIStream::operator>> ( std::map< K, V > &  )

Read a std::map of serializable items.

Version
1.0
template<class T >
DataIStream& co::DataIStream::operator>> ( std::set< T > &  )

Read a std::set of serializable items.

Version
1.0
template<class K , class V >
DataIStream& co::DataIStream::operator>> ( stde::hash_map< K, V > &  )

Read a stde::hash_map of serializable items.

Version
1.0
template<class T >
DataIStream& co::DataIStream::operator>> ( stde::hash_set< T > &  )

Read a stde::hash_set of serializable items.

Version
1.0
template<>
DataIStream& co::DataIStream::operator>> ( std::vector< uint8_t > &  value)
inline

Optimized specialization to read a std::vector of uint8_t.

Definition at line 262 of file dataIStream.ipp.

template<>
DataIStream& co::DataIStream::operator>> ( std::vector< uint16_t > &  value)
inline

Optimized specialization to read a std::vector of uint16_t.

Definition at line 267 of file dataIStream.ipp.

template<>
DataIStream& co::DataIStream::operator>> ( std::vector< int16_t > &  value)
inline

Optimized specialization to read a std::vector of int16_t.

Definition at line 272 of file dataIStream.ipp.

template<>
DataIStream& co::DataIStream::operator>> ( std::vector< uint32_t > &  value)
inline

Optimized specialization to read a std::vector of uint32_t.

Definition at line 277 of file dataIStream.ipp.

template<>
DataIStream& co::DataIStream::operator>> ( std::vector< int32_t > &  value)
inline

Optimized specialization to read a std::vector of int32_t.

Definition at line 282 of file dataIStream.ipp.

template<>
DataIStream& co::DataIStream::operator>> ( std::vector< uint64_t > &  value)
inline

Optimized specialization to read a std::vector of uint64_t.

Definition at line 287 of file dataIStream.ipp.

template<>
DataIStream& co::DataIStream::operator>> ( std::vector< int64_t > &  value)
inline

Optimized specialization to read a std::vector of int64_t.

Definition at line 292 of file dataIStream.ipp.

template<>
DataIStream& co::DataIStream::operator>> ( std::vector< float > &  value)
inline

Optimized specialization to read a std::vector of float.

Definition at line 297 of file dataIStream.ipp.

template<>
DataIStream& co::DataIStream::operator>> ( std::vector< double > &  value)
inline

Optimized specialization to read a std::vector of double.

Definition at line 302 of file dataIStream.ipp.

template<>
DataIStream& co::DataIStream::operator>> ( std::vector< ObjectVersion > &  value)
inline

Optimized specialization to read a std::vector of ObjectVersion.

Definition at line 307 of file dataIStream.ipp.

template<typename T >
T co::DataIStream::read ( )
inline
Returns
a value from the stream.
Version
1.0

Definition at line 59 of file dataIStream.h.

template<class T >
static void co::DataIStream::swap ( T &  v)
inlinestatic

Byte-swap a plain data item.

Defines:
CO_IGNORE_BYTESWAP: If set, no byteswapping of transmitted data is performed. Enable when you get unresolved symbols for lunchbox::byteswap and you don't care about mixed-endian environments.
Version
1.0

Definition at line 106 of file dataIStream.h.


The documentation for this class was generated from the following files: