GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/smt/update_ostream.h Lines: 1 41 2.4 %
Date: 2021-05-22 Branches: 0 38 0.0 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Tim King, Mathias Preiner, Aina Niemetz
4
 *
5
 * This file is part of the cvc5 project.
6
 *
7
 * Copyright (c) 2009-2021 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.
11
 * ****************************************************************************
12
 *
13
 * [[ Add one-line brief description here ]]
14
 *
15
 * [[ Add lengthier description here ]]
16
 * \todo document this file
17
 */
18
19
#include "cvc5_private.h"
20
21
#ifndef CVC5__UPDATE_OSTREAM_H
22
#define CVC5__UPDATE_OSTREAM_H
23
24
#include <ostream>
25
26
#include "base/check.h"
27
#include "base/output.h"
28
#include "expr/expr_iomanip.h"
29
#include "options/base_options.h"
30
#include "options/language.h"
31
#include "options/set_language.h"
32
#include "smt/dump.h"
33
34
namespace cvc5 {
35
36
class ChannelSettings {
37
 public:
38
  ChannelSettings(std::ostream& out)
39
      : d_dagSetting(expr::ExprDag::getDag(out)),
40
        d_exprDepthSetting(expr::ExprSetDepth::getDepth(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 << language::SetLanguage(d_languageSetting);
48
  }
49
50
 private:
51
  const int d_dagSetting;
52
  const size_t d_exprDepthSetting;
53
  const OutputLanguage d_languageSetting;
54
}; /* class ChannelSettings */
55
56
class OstreamUpdate {
57
public:
58
  virtual ~OstreamUpdate(){}
59
60
  virtual std::ostream& get() = 0;
61
  virtual void set(std::ostream* setTo) = 0;
62
63
  void apply(std::ostream* setTo) {
64
    PrettyCheckArgument(setTo != NULL, setTo);
65
66
    ChannelSettings initialSettings(get());
67
    set(setTo);
68
    initialSettings.apply(get());
69
  }
70
}; /* class OstreamUpdate */
71
72
class OptionsErrOstreamUpdate : public OstreamUpdate {
73
 public:
74
37761
  std::ostream& get() override { return *(options::err()); }
75
  void set(std::ostream* setTo) override { return Options::current().set(options::err, setTo); }
76
};  /* class OptionsErrOstreamUpdate */
77
78
class DumpOstreamUpdate : public OstreamUpdate {
79
 public:
80
  std::ostream& get() override { return Dump.getStream(); }
81
  void set(std::ostream* setTo) override { Dump.setStream(setTo); }
82
};  /* class DumpOstreamUpdate */
83
84
class DebugOstreamUpdate : public OstreamUpdate {
85
 public:
86
  std::ostream& get() override { return Debug.getStream(); }
87
  void set(std::ostream* setTo) override { Debug.setStream(setTo); }
88
};  /* class DebugOstreamUpdate */
89
90
class WarningOstreamUpdate : public OstreamUpdate {
91
 public:
92
  std::ostream& get() override { return Warning.getStream(); }
93
  void set(std::ostream* setTo) override { Warning.setStream(setTo); }
94
};  /* class WarningOstreamUpdate */
95
96
class MessageOstreamUpdate : public OstreamUpdate {
97
 public:
98
  std::ostream& get() override { return CVC5Message.getStream(); }
99
  void set(std::ostream* setTo) override { CVC5Message.setStream(setTo); }
100
};  /* class MessageOstreamUpdate */
101
102
class NoticeOstreamUpdate : public OstreamUpdate {
103
 public:
104
  std::ostream& get() override { return Notice.getStream(); }
105
  void set(std::ostream* setTo) override { Notice.setStream(setTo); }
106
};  /* class NoticeOstreamUpdate */
107
108
class ChatOstreamUpdate : public OstreamUpdate {
109
 public:
110
  std::ostream& get() override { return Chat.getStream(); }
111
  void set(std::ostream* setTo) override { Chat.setStream(setTo); }
112
};  /* class ChatOstreamUpdate */
113
114
class TraceOstreamUpdate : public OstreamUpdate {
115
 public:
116
  std::ostream& get() override { return Trace.getStream(); }
117
  void set(std::ostream* setTo) override { Trace.setStream(setTo); }
118
};  /* class TraceOstreamUpdate */
119
120
}  // namespace cvc5
121
122
#endif /* CVC5__UPDATE_OSTREAM_H */