1 /********************* */
2 /*! \file update_ostream.h
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
12 ** \brief [[ Add one-line brief description here ]]
14 ** [[ Add lengthier description here ]]
15 ** \todo document this file
18 #include "cvc4_private.h"
20 #ifndef CVC4__UPDATE_OSTREAM_H
21 #define CVC4__UPDATE_OSTREAM_H
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"
35 class ChannelSettings
{
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
))
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
);
52 const int d_dagSetting
;
53 const size_t d_exprDepthSetting
;
54 const bool d_printtypesSetting
;
55 const OutputLanguage d_languageSetting
;
56 }; /* class ChannelSettings */
60 virtual ~OstreamUpdate(){}
62 virtual std::ostream
& get() = 0;
63 virtual void set(std::ostream
* setTo
) = 0;
65 void apply(std::ostream
* setTo
) {
66 PrettyCheckArgument(setTo
!= NULL
, setTo
);
68 ChannelSettings
initialSettings(get());
70 initialSettings
.apply(get());
72 }; /* class OstreamUpdate */
74 class OptionsErrOstreamUpdate
: public OstreamUpdate
{
76 std::ostream
& get() override
{ return *(options::err()); }
77 void set(std::ostream
* setTo
) override
{ return options::err
.set(setTo
); }
78 }; /* class OptionsErrOstreamUpdate */
80 class DumpOstreamUpdate
: public OstreamUpdate
{
82 std::ostream
& get() override
{ return Dump
.getStream(); }
83 void set(std::ostream
* setTo
) override
{ Dump
.setStream(setTo
); }
84 }; /* class DumpOstreamUpdate */
86 class DebugOstreamUpdate
: public OstreamUpdate
{
88 std::ostream
& get() override
{ return Debug
.getStream(); }
89 void set(std::ostream
* setTo
) override
{ Debug
.setStream(setTo
); }
90 }; /* class DebugOstreamUpdate */
92 class WarningOstreamUpdate
: public OstreamUpdate
{
94 std::ostream
& get() override
{ return Warning
.getStream(); }
95 void set(std::ostream
* setTo
) override
{ Warning
.setStream(setTo
); }
96 }; /* class WarningOstreamUpdate */
98 class MessageOstreamUpdate
: public OstreamUpdate
{
100 std::ostream
& get() override
{ return Message
.getStream(); }
101 void set(std::ostream
* setTo
) override
{ Message
.setStream(setTo
); }
102 }; /* class MessageOstreamUpdate */
104 class NoticeOstreamUpdate
: public OstreamUpdate
{
106 std::ostream
& get() override
{ return Notice
.getStream(); }
107 void set(std::ostream
* setTo
) override
{ Notice
.setStream(setTo
); }
108 }; /* class NoticeOstreamUpdate */
110 class ChatOstreamUpdate
: public OstreamUpdate
{
112 std::ostream
& get() override
{ return Chat
.getStream(); }
113 void set(std::ostream
* setTo
) override
{ Chat
.setStream(setTo
); }
114 }; /* class ChatOstreamUpdate */
116 class TraceOstreamUpdate
: public OstreamUpdate
{
118 std::ostream
& get() override
{ return Trace
.getStream(); }
119 void set(std::ostream
* setTo
) override
{ Trace
.setStream(setTo
); }
120 }; /* class TraceOstreamUpdate */
122 }/* CVC4 namespace */
124 #endif /* CVC4__UPDATE_OSTREAM_H */