summaryrefslogtreecommitdiff
path: root/src/smt/dump.h
blob: a56529fe396f1fad67b847818319cb6d71078554 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/******************************************************************************
 * Top contributors (to current version):
 *   Morgan Deters, Andres Noetzli, Abdalrhman Mohamed
 *
 * This file is part of the cvc5 project.
 *
 * Copyright (c) 2009-2021 by the authors listed in the file AUTHORS
 * in the top-level source directory and their institutional affiliations.
 * All rights reserved.  See the file COPYING in the top-level source
 * directory for licensing information.
 * ****************************************************************************
 *
 * Dump utility classes and functions.
 */

#include "cvc4_private.h"

#ifndef CVC5__DUMP_H
#define CVC5__DUMP_H

#include "base/output.h"

namespace cvc5 {

class Command;
class NodeCommand;

#if defined(CVC5_DUMPING) && !defined(CVC5_MUZZLE)

class CVC4dumpstream
{
 public:
  CVC4dumpstream() : d_os(nullptr) {}
  CVC4dumpstream(std::ostream& os) : d_os(&os) {}

  CVC4dumpstream& operator<<(const Command& c);

  /** A convenience function for dumping internal commands.
   *
   * Since Commands are now part of the public API, internal code should use
   * NodeCommands and this function (instead of the one above) to dump them.
   */
  CVC4dumpstream& operator<<(const NodeCommand& nc);

 private:
  std::ostream* d_os;
}; /* class CVC4dumpstream */

#else

/**
 * Dummy implementation of the dump stream when dumping is disabled or the
 * build is muzzled.
 */
class CVC4dumpstream
{
 public:
  CVC4dumpstream() {}
  CVC4dumpstream(std::ostream& os) {}
  CVC4dumpstream& operator<<(const Command& c);
  CVC4dumpstream& operator<<(const NodeCommand& nc);
}; /* class CVC4dumpstream */

#endif /* CVC5_DUMPING && !CVC5_MUZZLE */

/** The dump class */
class DumpC
{
 public:
  CVC4dumpstream operator()(const char* tag) {
    if(!d_tags.empty() && d_tags.find(std::string(tag)) != d_tags.end()) {
      return CVC4dumpstream(getStream());
    } else {
      return CVC4dumpstream();
    }
  }

  CVC4dumpstream operator()(std::string tag) {
    if(!d_tags.empty() && d_tags.find(tag) != d_tags.end()) {
      return CVC4dumpstream(getStream());
    } else {
      return CVC4dumpstream();
    }
  }

  bool on (const char* tag) { d_tags.insert(std::string(tag)); return true; }
  bool on (std::string tag) { d_tags.insert(tag); return true; }
  bool off(const char* tag) { d_tags.erase (std::string(tag)); return false; }
  bool off(std::string tag) { d_tags.erase (tag); return false; }
  bool off()                { d_tags.clear(); return false; }

  bool isOn(const char* tag) { return d_tags.find(std::string(tag)) != d_tags.end(); }
  bool isOn(std::string tag) { return d_tags.find(tag) != d_tags.end(); }

  std::ostream& setStream(std::ostream* os);
  std::ostream& getStream();
  std::ostream* getStreamPointer();

  void setDumpFromString(const std::string& optarg);

 private:
  /** Set of dumping tags that are currently active. */
  std::set<std::string> d_tags;

  /** The message printed on `--dump help`. */
  static const std::string s_dumpHelp;
};/* class DumpC */

/** The dump singleton */
extern DumpC DumpChannel;

#define Dump ::cvc5::DumpChannel

}  // namespace cvc5

#endif /* CVC5__DUMP_H */
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback