Update copyright header script to support CMake and Python files (#5067)
[cvc5.git] / src / smt / update_ostream.h
1 /********************* */
2 /*! \file update_ostream.h
3 ** \verbatim
4 ** Top contributors (to current version):
5 ** Tim King, Mathias Preiner
6 ** This file is part of the CVC4 project.
7 ** Copyright (c) 2009-2020 by the authors listed in the file AUTHORS
8 ** in the top-level source directory and their institutional affiliations.
9 ** All rights reserved. See the file COPYING in the top-level source
10 ** directory for licensing information.\endverbatim
11 **
12 ** \brief [[ Add one-line brief description here ]]
13 **
14 ** [[ Add lengthier description here ]]
15 ** \todo document this file
16 **/
17
18 #include "cvc4_private.h"
19
20 #ifndef CVC4__UPDATE_OSTREAM_H
21 #define CVC4__UPDATE_OSTREAM_H
22
23 #include <ostream>
24
25 #include "base/check.h"
26 #include "base/output.h"
27 #include "expr/expr_iomanip.h"
28 #include "options/base_options.h"
29 #include "options/language.h"
30 #include "options/set_language.h"
31 #include "smt/dump.h"
32
33 namespace CVC4 {
34
35 class ChannelSettings {
36 public:
37 ChannelSettings(std::ostream& out)
38 : d_dagSetting(expr::ExprDag::getDag(out)),
39 d_exprDepthSetting(expr::ExprSetDepth::getDepth(out)),
40 d_printtypesSetting(expr::ExprPrintTypes::getPrintTypes(out)),
41 d_languageSetting(language::SetLanguage::getLanguage(out))
42 {}
43
44 void apply(std::ostream& out) {
45 out << expr::ExprDag(d_dagSetting);
46 out << expr::ExprSetDepth(d_exprDepthSetting);
47 out << expr::ExprPrintTypes(d_printtypesSetting);
48 out << language::SetLanguage(d_languageSetting);
49 }
50
51 private:
52 const int d_dagSetting;
53 const size_t d_exprDepthSetting;
54 const bool d_printtypesSetting;
55 const OutputLanguage d_languageSetting;
56 }; /* class ChannelSettings */
57
58 class OstreamUpdate {
59 public:
60 virtual ~OstreamUpdate(){}
61
62 virtual std::ostream& get() = 0;
63 virtual void set(std::ostream* setTo) = 0;
64
65 void apply(std::ostream* setTo) {
66 PrettyCheckArgument(setTo != NULL, setTo);
67
68 ChannelSettings initialSettings(get());
69 set(setTo);
70 initialSettings.apply(get());
71 }
72 }; /* class OstreamUpdate */
73
74 class OptionsErrOstreamUpdate : public OstreamUpdate {
75 public:
76 std::ostream& get() override { return *(options::err()); }
77 void set(std::ostream* setTo) override { return options::err.set(setTo); }
78 }; /* class OptionsErrOstreamUpdate */
79
80 class DumpOstreamUpdate : public OstreamUpdate {
81 public:
82 std::ostream& get() override { return Dump.getStream(); }
83 void set(std::ostream* setTo) override { Dump.setStream(setTo); }
84 }; /* class DumpOstreamUpdate */
85
86 class DebugOstreamUpdate : public OstreamUpdate {
87 public:
88 std::ostream& get() override { return Debug.getStream(); }
89 void set(std::ostream* setTo) override { Debug.setStream(setTo); }
90 }; /* class DebugOstreamUpdate */
91
92 class WarningOstreamUpdate : public OstreamUpdate {
93 public:
94 std::ostream& get() override { return Warning.getStream(); }
95 void set(std::ostream* setTo) override { Warning.setStream(setTo); }
96 }; /* class WarningOstreamUpdate */
97
98 class MessageOstreamUpdate : public OstreamUpdate {
99 public:
100 std::ostream& get() override { return Message.getStream(); }
101 void set(std::ostream* setTo) override { Message.setStream(setTo); }
102 }; /* class MessageOstreamUpdate */
103
104 class NoticeOstreamUpdate : public OstreamUpdate {
105 public:
106 std::ostream& get() override { return Notice.getStream(); }
107 void set(std::ostream* setTo) override { Notice.setStream(setTo); }
108 }; /* class NoticeOstreamUpdate */
109
110 class ChatOstreamUpdate : public OstreamUpdate {
111 public:
112 std::ostream& get() override { return Chat.getStream(); }
113 void set(std::ostream* setTo) override { Chat.setStream(setTo); }
114 }; /* class ChatOstreamUpdate */
115
116 class TraceOstreamUpdate : public OstreamUpdate {
117 public:
118 std::ostream& get() override { return Trace.getStream(); }
119 void set(std::ostream* setTo) override { Trace.setStream(setTo); }
120 }; /* class TraceOstreamUpdate */
121
122 }/* CVC4 namespace */
123
124 #endif /* CVC4__UPDATE_OSTREAM_H */