PSCF v1.1
ParamComponent.cpp
1/*
2* Util Package - C++ Utilities for Scientific Computation
3*
4* Copyright 2010 - 2017, The Regents of the University of Minnesota
5* Distributed under the terms of the GNU General Public License.
6*/
7
8#include "ParamComponent.h"
9
10namespace Util
11{
12
13 bool ParamComponent::echo_ = false;
14
15 /*
16 * Constructor.
17 *
18 * Note: Default constructor for _indent string creates an empty string.
19 */
21 : MpiFileIo(),
22 indent_()
23 {}
24
25 /*
26 * Copy constructor.
27 */
29 : MpiFileIo(other),
30 indent_(other.indent_)
31 {}
32
33 /*
34 * Destructor.
35 */
37 {}
38
39 /*
40 * Return indent string for this object (string of spaces).
41 */
42 std::string ParamComponent::indent() const
43 { return indent_; }
44
45 /*
46 * Set indent level to be one higher than that of parent.
47 */
48 void ParamComponent::setIndent(const ParamComponent& parent, bool next)
49 {
50 indent_ = parent.indent();
51 if (next) {
52 std::string space(" ");
53 indent_ += space;
54 }
55 }
56
57 // Static functions
58
59 /*
60 * Set echo to true (default) or false.
61 */
63 { echo_ = echo; }
64
65 /*
66 * Get value of echo. true = echoing is on, false = off.
67 */
69 { return echo_; }
70
71 /*
72 * This static method exists to guarantee initialization of a static
73 * constant echo_ that is defined in the same file. Call it somewhere
74 * in the program to guarantee that the contents of this file will
75 * be linked, rather than optimized away. It may only be called once.
76 */
78 {
79 // This function can only be called once.
80 static int nCall = 0;
81 if (nCall == 0) {
82 echo_ = false;
83 }
84 ++nCall;
85 }
86
87}
Identifies whether this processor may do file I/O.
Definition: MpiFileIo.h:34
Abstract base class for classes that input and ouput parameters to file.
std::string indent() const
Return indent string for this object (string of spaces).
virtual ~ParamComponent()
Destructor.
static void initStatic()
Initialize static echo member to false.
ParamComponent()
Constructor.
void setIndent(const ParamComponent &parent, bool next=true)
Set indent level.
static bool echo()
Get echo parameter.
static void setEcho(bool echo=true)
Enable or disable echoing for all subclasses of ParamComponent.
Utility classes for scientific computation.
Definition: accumulators.mod:1