Jpp 19.3.0-rc.1
the software that should make you happy
Loading...
Searching...
No Matches
JCommunicator.hh
Go to the documentation of this file.
1#ifndef __JEEP__JCOMMUNICATOR__
2#define __JEEP__JCOMMUNICATOR__
3
4#include <iostream>
5
7
8
9/**
10 * \file
11 * Switching on/off of standard and error output streams.
12 * \author mdejong
13 */
14namespace JEEP {}
15namespace JPP { using namespace JEEP; }
16
17namespace JEEP {
18
19
20 /**
21 * Auxiliary class to control standard input and output.
22 */
24 public:
25 /**
26 * Default constructor.
27 */
29 verbose_(true)
30 {}
31
32
33 /**
34 * Constructor.
35 *
36 * \param verbose disable I/O if false; else enable
37 */
38 JCommunicator(const bool verbose) :
40 {}
41
42
43 /**
44 * Get verbose mode.
45 *
46 * \return if true I/O enabled; else disabled
47 */
48 bool getVerbose() const
49 {
50 return verbose_;
51 }
52
53
54 /**
55 * Set verbose mode.
56 *
57 * \param verbose disable I/O if false; else enable
58 */
59 void setVerbose(const bool verbose = true)
60 {
62 }
63
64
65 /**
66 * Get current input stream.
67 * This method returns the given input stream if the verbose option is set,
68 * else a streamer that does not read any input.
69 *
70 * \param in input stream
71 * \return input stream
72 */
73 std::istream& getInputStream(std::istream& in = std::cin) const
74 {
75 return (verbose_ ? in : JLANG::null);
76 }
77
78
79 /**
80 * Get current output stream.
81 * This method returns the given output stream if the verbose option is set,
82 * else a streamer that does not write any output.
83 *
84 * \param out output stream
85 * \return output stream
86 */
87 std::ostream& getOutputStream(std::ostream& out = std::cout) const
88 {
89 return (verbose_ ? out : JLANG::null);
90 }
91
92
93 /**
94 * Get current error stream.
95 * This method returns the given error stream if the verbose option is set,
96 * else a streamer that does not write any output.
97 *
98 * \param out error stream
99 * \return error stream
100 */
101 std::ostream& getErrorStream(std::ostream& out = std::cerr) const
102 {
103 //return (verbose_ ? out : JLANG::null);
104 return out;
105 }
106
107
108 protected:
110 };
111
112}
113
114#endif
Auxiliary class to control standard input and output.
void setVerbose(const bool verbose=true)
Set verbose mode.
std::ostream & getOutputStream(std::ostream &out=std::cout) const
Get current output stream.
std::istream & getInputStream(std::istream &in=std::cin) const
Get current input stream.
JCommunicator()
Default constructor.
std::ostream & getErrorStream(std::ostream &out=std::cerr) const
Get current error stream.
JCommunicator(const bool verbose)
Constructor.
bool getVerbose() const
Get verbose mode.
int verbose
Definition elog.cc:70
General puprpose classes and methods.
static JNullStream null
Null I/O stream.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).