22 #ifndef CO_DATAOSTREAM_H
23 #define CO_DATAOSTREAM_H
28 #include <lunchbox/nonCopyable.h>
29 #include <lunchbox/stdExt.h>
37 namespace detail {
class DataOStream; }
38 namespace DataStreamTest {
class Sender; }
52 CO_API
void disable();
61 CO_API
bool hasSentData()
const;
71 const uint64_t size );
74 uint64_t getCompressedDataSize()
const;
81 { _write( &value,
sizeof( value ));
return *
this; }
84 template<
class T >
DataOStream& operator << ( Array< T > array )
85 { _write( array.data, array.getNumBytes( ));
return *
this; }
89 DataOStream& operator << ( const lunchbox::Buffer< T >& buffer );
93 DataOStream& operator << ( const std::vector< T >& value );
96 template<
class K,
class V >
97 DataOStream& operator << ( const std::map< K, V >& value );
101 DataOStream& operator << ( const std::set< T >& value );
104 template<
class K,
class V >
105 DataOStream& operator << ( const stde::hash_map< K, V >& value );
109 DataOStream& operator << ( const stde::hash_set< T >& value );
117 template<
typename C >
118 void serializeChildren(
const std::vector< C* >& children );
127 CO_API lunchbox::Bufferb& getBuffer();
130 void _initCompressor(
const uint32_t compressor );
133 CO_API
void _enable();
136 void flush(
const bool last );
142 void _setupConnections(
const Nodes& receivers );
144 void _setupConnections(
const Connections& connections );
147 void _setupConnection(
NodePtr node,
const bool useMulticast );
151 friend class DataStreamTest::Sender;
156 void _clearConnections();
161 virtual void sendData(
const void* buffer,
const uint64_t size,
162 const bool last ) = 0;
166 virtual CO_API
void reset();
169 detail::DataOStream*
const _impl;
172 CO_API uint64_t _getCompressedData(
void** chunks,
173 uint64_t* chunkSizes )
const;
176 CO_API
void _write(
const void* data, uint64_t size );
179 void _sendData(
const void* data,
const uint64_t size );
186 DataOStream& _writeFlatVector(
const std::vector< T >& value )
188 const uint64_t nElems = value.size();
189 _write( &nElems,
sizeof( nElems ));
191 _write( &value.front(), nElems *
sizeof( T ));
195 void _sendFooter(
const void* buffer,
const uint64_t size );
198 std::ostream& operator << ( std::ostream&,
const DataOStream& );
201 #include "dataOStream.ipp"
203 #endif //CO_DATAOSTREAM_H
std::vector< ConnectionPtr > Connections
A vector of ConnectionPtr's.
lunchbox::RefPtr< Node > NodePtr
A reference pointer for Node pointers.
A std::ostream-like interface for object serialization.
std::vector< NodePtr > Nodes
A vector of NodePtr's.
DataOStream & operator<<(const T &value)
Write a plain data item by copying it to the stream.
lunchbox::RefPtr< Connection > ConnectionPtr
A reference pointer for Connection pointers.