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