Model output is now const; this related to bug 519
[cvc5.git] / src / printer / printer.h
1 /********************* */
2 /*! \file printer.h
3 ** \verbatim
4 ** Original author: Morgan Deters
5 ** Major contributors: none
6 ** Minor contributors (to current version): Clark Barrett, Andrew Reynolds
7 ** This file is part of the CVC4 project.
8 ** Copyright (c) 2009-2013 New York University and The University of Iowa
9 ** See the file COPYING in the top-level source directory for licensing
10 ** information.\endverbatim
11 **
12 ** \brief Base of the pretty-printer interface
13 **
14 ** Base of the pretty-printer interface.
15 **/
16
17 #include "cvc4_private.h"
18
19 #ifndef __CVC4__PRINTER__PRINTER_H
20 #define __CVC4__PRINTER__PRINTER_H
21
22 #include "util/language.h"
23 #include "util/sexpr.h"
24 #include "util/util_model.h"
25 #include "expr/node.h"
26 #include "expr/command.h"
27
28 namespace CVC4 {
29
30 class Printer {
31 /** Printers for each OutputLanguage */
32 static Printer* d_printers[language::output::LANG_MAX];
33
34 /** Make a Printer for a given OutputLanguage */
35 static Printer* makePrinter(OutputLanguage lang) throw();
36
37 // disallow copy, assignment
38 Printer(const Printer&) CVC4_UNUSED;
39 Printer& operator=(const Printer&) CVC4_UNUSED;
40
41 protected:
42 // derived classes can construct, but no one else.
43 Printer() throw() {}
44
45 /** write model response to command */
46 virtual void toStream(std::ostream& out, const Model& m, const Command* c) const throw() = 0;
47
48 public:
49 /** Get the Printer for a given OutputLanguage */
50 static Printer* getPrinter(OutputLanguage lang) throw() {
51 if(d_printers[lang] == NULL) {
52 d_printers[lang] = makePrinter(lang);
53 }
54 return d_printers[lang];
55 }
56
57 /** Write a Node out to a stream with this Printer. */
58 virtual void toStream(std::ostream& out, TNode n,
59 int toDepth, bool types, size_t dag) const throw() = 0;
60
61 /** Write a Command out to a stream with this Printer. */
62 virtual void toStream(std::ostream& out, const Command* c,
63 int toDepth, bool types, size_t dag) const throw() = 0;
64
65 /** Write a CommandStatus out to a stream with this Printer. */
66 virtual void toStream(std::ostream& out, const CommandStatus* s) const throw() = 0;
67
68 /** Write an SExpr out to a stream with this Printer. */
69 virtual void toStream(std::ostream& out, const SExpr& sexpr) const throw();
70
71 /**
72 * Write a Result out to a stream with this Printer.
73 *
74 * The default implementation writes a reasonable string in lowercase
75 * for sat, unsat, valid, invalid, or unknown results. This behavior
76 * is overridable by each Printer, since sometimes an output language
77 * has a particular preference for how results should appear.
78 */
79 virtual void toStream(std::ostream& out, const Result& r) const throw();
80
81 /** Write a Model out to a stream with this Printer. */
82 virtual void toStream(std::ostream& out, const Model& m) const throw();
83
84 };/* class Printer */
85
86 }/* CVC4 namespace */
87
88 #endif /* __CVC4__PRINTER__PRINTER_H */
89