Adding an virtual destructor to OstreamUpdate.
[cvc5.git] / src / smt / update_ostream.h
1 /********************* */
2 /*! \file update_ostream.h
3 ** \verbatim
4 ** Original author: Tim King
5 ** Major contributors: none
6 ** Minor contributors (to current version): none
7 ** This file is part of the CVC4 project.
8 ** Copyright (c) 2009-2016 New York University and The University of Iowa
9 ** See the file COPYING in the top-level source directory for licensing
10 ** 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/cvc4_assert.h"
26 #include "base/output.h"
27 #include "expr/expr_iomanip.h"
28 #include "options/language.h"
29 #include "options/set_language.h"
30 #include "options/base_options.h"
31 #include "smt_util/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 virtual std::ostream& get() { return *(options::err()); }
77 virtual void set(std::ostream* setTo) { return options::err.set(setTo); }
78 }; /* class OptionsErrOstreamUpdate */
79
80 class DumpOstreamUpdate : public OstreamUpdate {
81 public:
82 virtual std::ostream& get() { return Dump.getStream(); }
83 virtual void set(std::ostream* setTo) { Dump.setStream(setTo); }
84 }; /* class DumpOstreamUpdate */
85
86 class DebugOstreamUpdate : public OstreamUpdate {
87 public:
88 virtual std::ostream& get() { return Debug.getStream(); }
89 virtual void set(std::ostream* setTo) { Debug.setStream(setTo); }
90 }; /* class DebugOstreamUpdate */
91
92 class WarningOstreamUpdate : public OstreamUpdate {
93 public:
94 virtual std::ostream& get() { return Warning.getStream(); }
95 virtual void set(std::ostream* setTo) { Warning.setStream(setTo); }
96 }; /* class WarningOstreamUpdate */
97
98 class MessageOstreamUpdate : public OstreamUpdate {
99 public:
100 virtual std::ostream& get() { return Message.getStream(); }
101 virtual void set(std::ostream* setTo) { Message.setStream(setTo); }
102 }; /* class MessageOstreamUpdate */
103
104 class NoticeOstreamUpdate : public OstreamUpdate {
105 public:
106 virtual std::ostream& get() { return Notice.getStream(); }
107 virtual void set(std::ostream* setTo) { Notice.setStream(setTo); }
108 }; /* class NoticeOstreamUpdate */
109
110 class ChatOstreamUpdate : public OstreamUpdate {
111 public:
112 virtual std::ostream& get() { return Chat.getStream(); }
113 virtual void set(std::ostream* setTo) { Chat.setStream(setTo); }
114 }; /* class ChatOstreamUpdate */
115
116 class TraceOstreamUpdate : public OstreamUpdate {
117 public:
118 virtual std::ostream& get() { return Trace.getStream(); }
119 virtual void set(std::ostream* setTo) { Trace.setStream(setTo); }
120 }; /* class TraceOstreamUpdate */
121
122 }/* CVC4 namespace */
123
124 #endif /* __CVC4__UPDATE_OSTREAM_H */