GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/smt/dump.h Lines: 10 10 100.0 %
Date: 2021-03-22 Branches: 16 28 57.1 %

Line Exec Source
1
/*********************                                                        */
2
/*! \file dump.h
3
 ** \verbatim
4
 ** Top contributors (to current version):
5
 **   Morgan Deters, Andres Noetzli, Abdalrhman Mohamed
6
 ** This file is part of the CVC4 project.
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.\endverbatim
11
 **
12
 ** \brief Dump utility classes and functions
13
 **
14
 ** Dump utility classes and functions.
15
 **/
16
17
#include "cvc4_private.h"
18
19
#ifndef CVC4__DUMP_H
20
#define CVC4__DUMP_H
21
22
#include "base/output.h"
23
24
namespace CVC4 {
25
26
class Command;
27
class NodeCommand;
28
29
#if defined(CVC4_DUMPING) && !defined(CVC4_MUZZLE)
30
31
class CVC4dumpstream
32
{
33
 public:
34
671
  CVC4dumpstream() : d_os(nullptr) {}
35
12
  CVC4dumpstream(std::ostream& os) : d_os(&os) {}
36
37
  CVC4dumpstream& operator<<(const Command& c);
38
39
  /** A convenience function for dumping internal commands.
40
   *
41
   * Since Commands are now part of the public API, internal code should use
42
   * NodeCommands and this function (instead of the one above) to dump them.
43
   */
44
  CVC4dumpstream& operator<<(const NodeCommand& nc);
45
46
 private:
47
  std::ostream* d_os;
48
}; /* class CVC4dumpstream */
49
50
#else
51
52
/**
53
 * Dummy implementation of the dump stream when dumping is disabled or the
54
 * build is muzzled.
55
 */
56
class CVC4dumpstream
57
{
58
 public:
59
  CVC4dumpstream() {}
60
  CVC4dumpstream(std::ostream& os) {}
61
  CVC4dumpstream& operator<<(const Command& c);
62
  CVC4dumpstream& operator<<(const NodeCommand& nc);
63
}; /* class CVC4dumpstream */
64
65
#endif /* CVC4_DUMPING && !CVC4_MUZZLE */
66
67
/** The dump class */
68
17784
class DumpC
69
{
70
 public:
71
683
  CVC4dumpstream operator()(const char* tag) {
72
683
    if(!d_tags.empty() && d_tags.find(std::string(tag)) != d_tags.end()) {
73
12
      return CVC4dumpstream(getStream());
74
    } else {
75
671
      return CVC4dumpstream();
76
    }
77
  }
78
79
  CVC4dumpstream operator()(std::string tag) {
80
    if(!d_tags.empty() && d_tags.find(tag) != d_tags.end()) {
81
      return CVC4dumpstream(getStream());
82
    } else {
83
      return CVC4dumpstream();
84
    }
85
  }
86
87
8
  bool on (const char* tag) { d_tags.insert(std::string(tag)); return true; }
88
  bool on (std::string tag) { d_tags.insert(tag); return true; }
89
  bool off(const char* tag) { d_tags.erase (std::string(tag)); return false; }
90
  bool off(std::string tag) { d_tags.erase (tag); return false; }
91
  bool off()                { d_tags.clear(); return false; }
92
93
16554915
  bool isOn(const char* tag) { return d_tags.find(std::string(tag)) != d_tags.end(); }
94
25
  bool isOn(std::string tag) { return d_tags.find(tag) != d_tags.end(); }
95
96
  std::ostream& setStream(std::ostream* os);
97
  std::ostream& getStream();
98
  std::ostream* getStreamPointer();
99
100
  void setDumpFromString(const std::string& optarg);
101
102
 private:
103
  /** Set of dumping tags that are currently active. */
104
  std::set<std::string> d_tags;
105
106
  /** The message printed on `--dump help`. */
107
  static const std::string s_dumpHelp;
108
};/* class DumpC */
109
110
/** The dump singleton */
111
extern DumpC DumpChannel;
112
113
#define Dump ::CVC4::DumpChannel
114
115
}/* CVC4 namespace */
116
117
#endif /* CVC4__DUMP_H */