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-2019 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/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/dump.h" 32 33 namespace CVC4 { 34 35 class ChannelSettings { 36 public: ChannelSettings(std::ostream & out)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 apply(std::ostream & 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); 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: ~OstreamUpdate()60 virtual ~OstreamUpdate(){} 61 62 virtual std::ostream& get() = 0; 63 virtual void set(std::ostream* setTo) = 0; 64 apply(std::ostream * setTo)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: get()76 std::ostream& get() override { return *(options::err()); } set(std::ostream * setTo)77 void set(std::ostream* setTo) override { return options::err.set(setTo); } 78 }; /* class OptionsErrOstreamUpdate */ 79 80 class DumpOstreamUpdate : public OstreamUpdate { 81 public: get()82 std::ostream& get() override { return Dump.getStream(); } set(std::ostream * setTo)83 void set(std::ostream* setTo) override { Dump.setStream(setTo); } 84 }; /* class DumpOstreamUpdate */ 85 86 class DebugOstreamUpdate : public OstreamUpdate { 87 public: get()88 std::ostream& get() override { return Debug.getStream(); } set(std::ostream * setTo)89 void set(std::ostream* setTo) override { Debug.setStream(setTo); } 90 }; /* class DebugOstreamUpdate */ 91 92 class WarningOstreamUpdate : public OstreamUpdate { 93 public: get()94 std::ostream& get() override { return Warning.getStream(); } set(std::ostream * setTo)95 void set(std::ostream* setTo) override { Warning.setStream(setTo); } 96 }; /* class WarningOstreamUpdate */ 97 98 class MessageOstreamUpdate : public OstreamUpdate { 99 public: get()100 std::ostream& get() override { return Message.getStream(); } set(std::ostream * setTo)101 void set(std::ostream* setTo) override { Message.setStream(setTo); } 102 }; /* class MessageOstreamUpdate */ 103 104 class NoticeOstreamUpdate : public OstreamUpdate { 105 public: get()106 std::ostream& get() override { return Notice.getStream(); } set(std::ostream * setTo)107 void set(std::ostream* setTo) override { Notice.setStream(setTo); } 108 }; /* class NoticeOstreamUpdate */ 109 110 class ChatOstreamUpdate : public OstreamUpdate { 111 public: get()112 std::ostream& get() override { return Chat.getStream(); } set(std::ostream * setTo)113 void set(std::ostream* setTo) override { Chat.setStream(setTo); } 114 }; /* class ChatOstreamUpdate */ 115 116 class TraceOstreamUpdate : public OstreamUpdate { 117 public: get()118 std::ostream& get() override { return Trace.getStream(); } set(std::ostream * setTo)119 void set(std::ostream* setTo) override { Trace.setStream(setTo); } 120 }; /* class TraceOstreamUpdate */ 121 122 }/* CVC4 namespace */ 123 124 #endif /* __CVC4__UPDATE_OSTREAM_H */ 125