www.cemf.ir
masterOstream.hpp
Go to the documentation of this file.
1 /*------------------------------- phasicFlow ---------------------------------
2  O C enter of
3  O O E ngineering and
4  O O M ultiscale modeling of
5  OOOOOOO F luid flow
6 ------------------------------------------------------------------------------
7  Copyright (C): www.cemf.ir
8  email: hamid.r.norouzi AT gmail.com
9 ------------------------------------------------------------------------------
10 Licence:
11  This file is part of phasicFlow code. It is a free software for simulating
12  granular and multiphase flows. You can redistribute it and/or modify it under
13  the terms of GNU General Public License v3 or any other later versions.
14 
15  phasicFlow is distributed to help others in their research in the field of
16  granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
17  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 
19 -----------------------------------------------------------------------------*/
20 #ifndef __masterOstream_hpp__
21 #define __masterOstream_hpp__
22 
23 #include "Ostream.hpp"
24 
25 namespace pFlow
26 {
27 
37 :
38  public Ostream
39 {
40 protected:
41 
43  bool isThisMaster_ = true;
44 
45 
46  inline bool showOutput() const
47  {
48  return isThisMaster_;
49  }
50 
51 public:
52 
54 
56  masterOstream(std::ostream& os, const word& streamName);
57 
59  masterOstream(const masterOstream&) = delete;
60 
62  void operator=(const masterOstream&) = delete;
63 
64 
65 
68  void setMasterSlave(bool master)
69  {
70  isThisMaster_ = master;
71  }
72 
75  bool write(const token& tok)
76  // to prevent compiler warning, this method is overriden agian
77  {
78  return Ostream::write(tok);
79  }
80 
82  iOstream& write(const char c)override;
83 
85  iOstream& write(const char* str)override;
86 
88  iOstream& write(const word& str)override;
89 
91  // Optional write without quotes.
92  iOstream& writeQuoted ( const word& str, const bool quoted=true ) override;
93 
95  iOstream& write(const int64 val) override;
96 
98  iOstream& write(const int32 val) override;
99 
101  iOstream& write(const int8 val) override;
102 
104  iOstream& write(const uint64 val) override;
105 
107  iOstream& write(const uint32 val) override;
108 
110  iOstream& write(const uint8 val) override;
111 
113  iOstream& write(const float val) override;
114 
116  iOstream& write(const double val) override;
117 
119  iOstream& write(const size_t val) override;
120 
122  iOstream& write(const char* binaryData, std::streamsize count) override;
123 
125  void indent() override;
126 
127 
128 }; // masterOstream
129 
130 
131 
132 } // pFlow
133 
134 
135 #endif // __masterOstream_hpp__
pFlow::masterOstream::write
bool write(const token &tok)
Write token to stream or otherwise handle it.
Definition: masterOstream.hpp:75
Ostream.hpp
pFlow::token
Token class based on OpenFOAM stream, with some modifications/simplifications to be tailored to our n...
Definition: token.hpp:44
pFlow::masterOstream::isThisMaster_
bool isThisMaster_
Print prefix?
Definition: masterOstream.hpp:43
pFlow::uint32
unsigned int uint32
Definition: builtinTypes.hpp:56
pFlow::word
std::string word
Definition: builtinTypes.hpp:64
pFlow::int64
long long int int64
Definition: builtinTypes.hpp:52
pFlow
Definition: demGeometry.hpp:27
pFlow::masterOstream::writeQuoted
iOstream & writeQuoted(const word &str, const bool quoted=true) override
Write std::string surrounded by quotes.
Definition: masterOstream.cpp:67
pFlow::masterOstream::showOutput
bool showOutput() const
Definition: masterOstream.hpp:46
pFlow::masterOstream
Output stream for MPI parallel run, when we need to know which the processor number in the output lin...
Definition: masterOstream.hpp:36
pFlow::int32
int int32
Definition: builtinTypes.hpp:50
pFlow::count
auto count(const Vector< T, Allocator > &vec, const T &val)
Definition: VectorAlgorithm.hpp:26
pFlow::masterOstream::indent
void indent() override
Add indentation characters.
Definition: masterOstream.cpp:180
pFlow::masterOstream::setMasterSlave
void setMasterSlave(bool master)
Set if this processor is slave or master.
Definition: masterOstream.hpp:68
pFlow::uint64
unsigned long long int uint64
Definition: builtinTypes.hpp:58
pFlow::int8
signed char int8
Definition: builtinTypes.hpp:48
pFlow::masterOstream::masterOstream
masterOstream(std::ostream &os, const word &streamName)
From components.
Definition: masterOstream.cpp:27
pFlow::Ostream::write
bool write(const token &tok) override
Write token to stream or otherwise handle it.
Definition: Ostream.cpp:51
pFlow::Ostream
Standard output stream for BINARY and ASCII formats.
Definition: Ostream.hpp:39
pFlow::uint8
unsigned char uint8
Definition: builtinTypes.hpp:54
pFlow::iOstream
Interface class for any output stream.
Definition: iOstream.hpp:59
pFlow::masterOstream::operator=
void operator=(const masterOstream &)=delete
No copy assignment.