DFT-EFE
 
Loading...
Searching...
No Matches
ConditionalOStream.h
Go to the documentation of this file.
1/******************************************************************************
2 * Copyright (c) 2021. *
3 * The Regents of the University of Michigan and DFT-EFE developers. *
4 * *
5 * This file is part of the DFT-EFE code. *
6 * *
7 * DFT-EFE is free software: you can redistribute it and/or modify *
8 * it under the terms of the Lesser GNU General Public License as *
9 * published by the Free Software Foundation, either version 3 of *
10 * the License, or (at your option) any later version. *
11 * *
12 * DFT-EFE is distributed in the hope that it will be useful, but *
13 * WITHOUT ANY WARRANTY; without even the implied warranty *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
15 * See the Lesser GNU General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU Lesser General Public *
18 * License at the top level of DFT-EFE distribution. If not, see *
19 * <https://www.gnu.org/licenses/>. *
20 ******************************************************************************/
21
22/*
23 * @author Bikash Kanungo
24 */
25#ifndef dftefeConditionalOstream_h
26#define dftefeConditionalOstream_h
27
28#include <ostream>
29
30//
31// ACKNOWLEDGEMENT: The implementation of this class is borrowed from deal.II
32//
33namespace dftefe
34{
35 namespace utils
36 {
45 {
46 public:
55 ConditionalOStream(std::ostream &stream, const bool active = true);
56
64 void
65 setCondition(const bool active);
66
74 bool
75 isActive() const;
76
82 std::ostream &
83 getOStream() const;
84
92 template <typename T>
93 const ConditionalOStream &
94 operator<<(const T &t) const;
95
106 const ConditionalOStream &
107 operator<<(std::ostream &(*p)(std::ostream &)) const;
108
109 private:
110 std::ostream &d_outputStream;
112 }; // end of class ConditionalOStream
113
114 } // end of namespace utils
115} // end of namespace dftefe
116
118#endif // dftefeConditionalOstream_h
Provides an interface to print based on whether a certain condition is met or not....
Definition: ConditionalOStream.h:45
const ConditionalOStream & operator<<(const T &t) const
Overload the insertion or << operator.
Definition: ConditionalOStream.t.cpp:35
void setCondition(const bool active)
Function to set the condition for printing to the output stream associated with this object.
Definition: ConditionalOStream.cpp:41
bool d_activeFlag
Definition: ConditionalOStream.h:111
std::ostream & getOStream() const
Function that returns the underlying ostream object associated with this object.
Definition: ConditionalOStream.cpp:53
bool isActive() const
Function that returns true if printing to the output stream associated with this object is allowed.
Definition: ConditionalOStream.cpp:47
std::ostream & d_outputStream
Definition: ConditionalOStream.h:110
dealii includes
Definition: AtomFieldDataSpherical.cpp:31