Rosetta  2020.37
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Static Private Member Functions | Private Attributes | List of all members
utility::io::mpi_stream::basic_mpi_ostream< Elem, Tr, ElemA, ByteT, ByteAT > Class Template Reference

A mpiper ostream. More...

#include <mpistream.hh>

Inheritance diagram for utility::io::mpi_stream::basic_mpi_ostream< Elem, Tr, ElemA, ByteT, ByteAT >:
Inheritance graph
[legend]

Public Types

typedef basic_mpi_ostreambase
< Elem, Tr, ElemA, ByteT,
ByteAT > 
mpi_ostreambase_type
 
typedef std::basic_ostream
< Elem, Tr > 
ostream_type
 
typedef std::basic_ostream
< Elem, Tr > & 
ostream_reference
 
typedef Elem char_type
 
- Public Types inherited from utility::io::mpi_stream::basic_mpi_ostreambase< Elem, Tr, ElemA, ByteT, ByteAT >
typedef std::basic_ostream
< Elem, Tr > & 
ostream_reference
 
typedef basic_mpi_streambuf
< Elem, Tr, ElemA, ByteT,
ByteAT > 
mpi_streambuf_type
 

Public Member Functions

 basic_mpi_ostream (std::string filename, int master_rank, std::stringstream &header, bool append=false, std::size_t buffer_size_=default_buffer_size)
 Constructs a mpiper ostream decorator. More...
 
void close ()
 
 ~basic_mpi_ostream () override
 
template<typename T >
basic_mpi_ostreamoperator<< (T const &t)
 stream output More...
 
basic_mpi_ostreamput (char const c)
 write char More...
 
basic_mpi_ostreamwrite (char const *str, std::streamsize const count)
 write a string More...
 
basic_mpi_ostreamflush ()
 
- Public Member Functions inherited from utility::io::mpi_stream::basic_mpi_ostreambase< Elem, Tr, ElemA, ByteT, ByteAT >
 basic_mpi_ostreambase (std::string filename, size_t buffer_size_, int master_rank, bool append)
 Construct a mpi stream. More...
 
mpi_streambuf_typerdbuf ()
 returns the underlying mpi ostream object More...
 
int file_status () const
 
void release_file ()
 
void print_header (std::string const &header)
 

Static Private Member Functions

static void put_long_as_uint32 (ostream_reference out_, unsigned long x_)
 

Private Attributes

bool m_mpi_stream_finalized
 tracks to see if mpi stream was finalized More...
 

Detailed Description

template<typename Elem, typename Tr = std::char_traits< Elem >, typename ElemA = std::allocator< Elem >, typename ByteT = unsigned char, typename ByteAT = std::allocator< ByteT >>
class utility::io::mpi_stream::basic_mpi_ostream< Elem, Tr, ElemA, ByteT, ByteAT >

A mpiper ostream.

Remarks

This class is a ostream decorator that behaves 'almost' like any other ostream.

At construction, it takes any ostream that shall be used to output of the compressed data.

When finished, you need to call the special method zflush or call the destructor to flush all the intermidiate streams.

Example:

// creating the target mpi string, could be a fstream
ostringstream ostringstream_;
// creating the mpi layer
mpi_ostream mpiper(ostringstream_);
// writing data
mpiper<<f<<" "<<d<<" "<<ui<<" "<<ul<<" "<<us<<" "<<c<<" "<<dum;
// mpi ostream needs special flushing...
mpiper.zflush();

Member Typedef Documentation

template<typename Elem, typename Tr = std::char_traits< Elem >, typename ElemA = std::allocator< Elem >, typename ByteT = unsigned char, typename ByteAT = std::allocator< ByteT >>
typedef Elem utility::io::mpi_stream::basic_mpi_ostream< Elem, Tr, ElemA, ByteT, ByteAT >::char_type
template<typename Elem, typename Tr = std::char_traits< Elem >, typename ElemA = std::allocator< Elem >, typename ByteT = unsigned char, typename ByteAT = std::allocator< ByteT >>
typedef basic_mpi_ostreambase< Elem, Tr, ElemA, ByteT, ByteAT > utility::io::mpi_stream::basic_mpi_ostream< Elem, Tr, ElemA, ByteT, ByteAT >::mpi_ostreambase_type
template<typename Elem, typename Tr = std::char_traits< Elem >, typename ElemA = std::allocator< Elem >, typename ByteT = unsigned char, typename ByteAT = std::allocator< ByteT >>
typedef std::basic_ostream< Elem, Tr >& utility::io::mpi_stream::basic_mpi_ostream< Elem, Tr, ElemA, ByteT, ByteAT >::ostream_reference
template<typename Elem, typename Tr = std::char_traits< Elem >, typename ElemA = std::allocator< Elem >, typename ByteT = unsigned char, typename ByteAT = std::allocator< ByteT >>
typedef std::basic_ostream< Elem, Tr > utility::io::mpi_stream::basic_mpi_ostream< Elem, Tr, ElemA, ByteT, ByteAT >::ostream_type

Constructor & Destructor Documentation

template<typename Elem, typename Tr = std::char_traits< Elem >, typename ElemA = std::allocator< Elem >, typename ByteT = unsigned char, typename ByteAT = std::allocator< ByteT >>
utility::io::mpi_stream::basic_mpi_ostream< Elem, Tr, ElemA, ByteT, ByteAT >::basic_mpi_ostream ( std::string  filename,
int  master_rank,
std::stringstream &  header,
bool  append = false,
std::size_t  buffer_size_ = default_buffer_size 
)
inline

Constructs a mpiper ostream decorator.

Parameters
ostream_ostream where the compressed output is written
is_gmpi_true if gmpi header and footer have to be added
level_level of compression 0, bad and fast, 9, good and slower,
strategy_compression strategy
window_size_see zlib doc
memory_level_see zlib doc
buffer_size_the buffer size used to mpi data
Note
When is_gmpi_ is true, a gmpi header and footer is automatically added

References utility::io::mpi_stream::basic_mpi_ostreambase< Elem, Tr, ElemA, ByteT, ByteAT >::file_status(), utility::io::mpi_stream::MPI_FAIL, utility::io::mpi_stream::MPI_SUCCESS_NEW, and utility::io::mpi_stream::basic_mpi_ostreambase< Elem, Tr, ElemA, ByteT, ByteAT >::print_header().

template<typename Elem, typename Tr = std::char_traits< Elem >, typename ElemA = std::allocator< Elem >, typename ByteT = unsigned char, typename ByteAT = std::allocator< ByteT >>
utility::io::mpi_stream::basic_mpi_ostream< Elem, Tr, ElemA, ByteT, ByteAT >::~basic_mpi_ostream ( )
inlineoverride

Member Function Documentation

template<typename Elem, typename Tr = std::char_traits< Elem >, typename ElemA = std::allocator< Elem >, typename ByteT = unsigned char, typename ByteAT = std::allocator< ByteT >>
void utility::io::mpi_stream::basic_mpi_ostream< Elem, Tr, ElemA, ByteT, ByteAT >::close ( )
inline
template<typename Elem, typename Tr = std::char_traits< Elem >, typename ElemA = std::allocator< Elem >, typename ByteT = unsigned char, typename ByteAT = std::allocator< ByteT >>
basic_mpi_ostream& utility::io::mpi_stream::basic_mpi_ostream< Elem, Tr, ElemA, ByteT, ByteAT >::flush ( )
inline
template<typename Elem, typename Tr = std::char_traits< Elem >, typename ElemA = std::allocator< Elem >, typename ByteT = unsigned char, typename ByteAT = std::allocator< ByteT >>
template<typename T >
basic_mpi_ostream& utility::io::mpi_stream::basic_mpi_ostream< Elem, Tr, ElemA, ByteT, ByteAT >::operator<< ( T const &  t)
inline

stream output

if mpi stream has been finalized, will reset

the stream and add header if necessary

References basic::options::OptionKeys::in::file::t.

template<typename Elem, typename Tr = std::char_traits< Elem >, typename ElemA = std::allocator< Elem >, typename ByteT = unsigned char, typename ByteAT = std::allocator< ByteT >>
basic_mpi_ostream& utility::io::mpi_stream::basic_mpi_ostream< Elem, Tr, ElemA, ByteT, ByteAT >::put ( char const  c)
inline

write char

if mpi stream has been finalized, will reset

the stream and add header if necessary

References utility::io::mpi_stream::basic_mpi_ostream< Elem, Tr, ElemA, ByteT, ByteAT >::put().

Referenced by utility::io::ozstream::put(), and utility::io::mpi_stream::basic_mpi_ostream< Elem, Tr, ElemA, ByteT, ByteAT >::put().

template<typename Elem, typename Tr = std::char_traits< Elem >, typename ElemA = std::allocator< Elem >, typename ByteT = unsigned char, typename ByteAT = std::allocator< ByteT >>
void utility::io::mpi_stream::basic_mpi_ostream< Elem, Tr, ElemA, ByteT, ByteAT >::put_long_as_uint32 ( ostream_reference  out_,
unsigned long  x_ 
)
staticprivate
template<typename Elem, typename Tr = std::char_traits< Elem >, typename ElemA = std::allocator< Elem >, typename ByteT = unsigned char, typename ByteAT = std::allocator< ByteT >>
basic_mpi_ostream& utility::io::mpi_stream::basic_mpi_ostream< Elem, Tr, ElemA, ByteT, ByteAT >::write ( char const *  str,
std::streamsize const  count 
)
inline

Member Data Documentation

template<typename Elem, typename Tr = std::char_traits< Elem >, typename ElemA = std::allocator< Elem >, typename ByteT = unsigned char, typename ByteAT = std::allocator< ByteT >>
bool utility::io::mpi_stream::basic_mpi_ostream< Elem, Tr, ElemA, ByteT, ByteAT >::m_mpi_stream_finalized
private

tracks to see if mpi stream was finalized

set to true during zflush_finalize()

set to false during reset_state()


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