5 #ifndef STK_UTIL_PARALLEL_mpi_filebuf_hpp 6 #define STK_UTIL_PARALLEL_mpi_filebuf_hpp 34 class mpi_filebuf :
public std::streambuf {
44 MPI_Comm communicator ,
45 const int root_processor ,
46 const std::ios_base::openmode file_mode ,
47 const char *
const file_name = NULL );
51 mpi_filebuf * close();
56 mpi_filebuf * flush();
60 virtual ~mpi_filebuf();
68 mpi_filebuf * set_buffer_length(
const size_t buffer_length );
71 void get_buffer(
const char * & ,
size_t & )
const ;
74 double wtime()
const ;
79 virtual int underflow();
82 virtual int overflow(
int c = EOF );
88 virtual std::streambuf * setbuf(
char * s , std::streamsize n );
92 mpi_filebuf(
const mpi_filebuf & );
93 mpi_filebuf & operator = (
const mpi_filebuf & );
97 std::FILE * comm_root_fp ;
100 size_t comm_buffer_len ;
106 inline int mpi_filebuf::is_open()
const {
return NULL != comm_buffer ; }
112 inline void mpi_filebuf::get_buffer(
const char * & b ,
size_t & n )
const 113 { b = comm_buffer ; n = ((mpi_filebuf*)
this)->pptr() - comm_buffer ; }
115 inline double mpi_filebuf::wtime()
const {
return comm_time ; }
117 #endif // STK_UTIL_PARALLEL_mpi_filebuf_hpp