OpenLB 1.7
Loading...
Searching...
No Matches
Public Member Functions | List of all members
olb::OMBuf Class Reference

userdefined stream buffer for OstreamManager More...

#include <ostreamManager.h>

+ Inheritance diagram for olb::OMBuf:
+ Collaboration diagram for olb::OMBuf:

Public Member Functions

 OMBuf ()
 
 ~OMBuf () override
 
 OMBuf (const OMBuf &rhs)
 
OMBufoperator= (const OMBuf &rhs)
 
void swap (OMBuf &rhs)
 
 OMBuf (std::ostream &str, std::string classname)
 
void setMultiOutput (bool b)
 
int sync () override
 sync the stream with the output:
 

Detailed Description

userdefined stream buffer for OstreamManager

that prefixes each line with a user specified string in squared brackets

Definition at line 36 of file ostreamManager.h.

Constructor & Destructor Documentation

◆ OMBuf() [1/3]

olb::OMBuf::OMBuf ( )

Definition at line 34 of file ostreamManager.cpp.

35 : output(nullptr), text("")
36{ }

◆ ~OMBuf()

olb::OMBuf::~OMBuf ( )
override

Definition at line 38 of file ostreamManager.cpp.

39{ }

◆ OMBuf() [2/3]

olb::OMBuf::OMBuf ( const OMBuf & rhs)

Definition at line 41 of file ostreamManager.cpp.

42 : output(rhs.output), text(rhs.text)
43{ }

◆ OMBuf() [3/3]

olb::OMBuf::OMBuf ( std::ostream & str,
std::string classname )

Definition at line 53 of file ostreamManager.cpp.

54 : output(&str), text(classname)
55{ }

Member Function Documentation

◆ operator=()

OMBuf & olb::OMBuf::operator= ( const OMBuf & rhs)

Definition at line 45 of file ostreamManager.cpp.

46{
47 output = rhs.output;
48 text = rhs.text;
49
50 return *this;
51}

◆ setMultiOutput()

void olb::OMBuf::setMultiOutput ( bool b)

Definition at line 57 of file ostreamManager.cpp.

58{
59 (*this).multiOutput = b;
60}
+ Here is the caller graph for this function:

◆ swap()

void olb::OMBuf::swap ( OMBuf & rhs)

◆ sync()

int olb::OMBuf::sync ( )
override

sync the stream with the output:

1) first Output "[text] ", then the buffer,
2) reset the buffer
3) and flush the actual output stream

Definition at line 62 of file ostreamManager.cpp.

63{
64#ifdef PARALLEL_MODE_MPI
65 #ifdef PARALLEL_MODE_OMP
66 if (multiOutput==true) {
67 *output << "["
68 << text << ":" << singleton::mpi().getRank()
69 << ":" << singleton::omp().getRank()
70 << "] " << str();
71 }
72 else { // multiOutput==false
73 if (singleton::mpi().getRank() == 0 && singleton::omp().getRank() == 0) {
74 *output << "[" << text << "] " << str();
75 }
76 }
77 #else
78 if (multiOutput==true) {
79 *output << "["
80 << text << ":" << singleton::mpi().getRank()
81 << "] " << str();
82 }
83 else { // multiOutput==false
84 if (singleton::mpi().getRank()==0) {
85 *output << "[" << text << "] " << str();
86 }
87 }
88 #endif
89#elif PARALLEL_MODE_OMP
90 if (multiOutput==true) {
91 *output << "["
92 << text << ":" << singleton::omp().getRank()
93 << "] " << str();
94 }
95 else { // multiOutput==false
96 if (singleton::omp().getRank()==0) {
97 *output << "[" << text << "] " << str();
98 }
99 }
100#else
101 *output << "[" << text << "] " << str();
102#endif
103 str("");
104 output->flush();
105 return 0;
106}
int getRank() const
Returns the process ID.
MpiManager & mpi()
ompManager omp()
int getRank() const

References olb::singleton::MpiManager::getRank(), olb::ompManager::getRank(), olb::singleton::mpi(), and olb::singleton::omp().

+ Here is the call graph for this function:

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