]> www.ginac.de Git - ginac.git/blobdiff - ginac/constant.cpp
* Added resultant() function (by Ralf Stephan <ralf@ark.in-berlin.de>).
[ginac.git] / ginac / constant.cpp
index d3c91588c186be4bfe64354fb553cdc4fd3bb405..32ceb61e3a9589dd4433dd8b04072993f2ebe7ff 100644 (file)
@@ -3,7 +3,7 @@
  *  Implementation of GiNaC's constant types and some special constants. */
 
 /*
- *  GiNaC Copyright (C) 1999-2003 Johannes Gutenberg University Mainz, Germany
+ *  GiNaC Copyright (C) 1999-2004 Johannes Gutenberg University Mainz, Germany
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
 #include "constant.h"
 #include "numeric.h"
 #include "ex.h"
-#include "print.h"
 #include "archive.h"
 #include "utils.h"
 
 namespace GiNaC {
 
-GINAC_IMPLEMENT_REGISTERED_CLASS(constant, basic)
+GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(constant, basic,
+  print_func<print_context>(&constant::do_print).
+  print_func<print_latex>(&constant::do_print_latex).
+  print_func<print_tree>(&constant::do_print_tree).
+  print_func<print_python_repr>(&constant::do_print_python_repr))
 
 //////////
 // default constructor
@@ -108,21 +111,29 @@ void constant::archive(archive_node &n) const
 
 // public
 
-void constant::print(const print_context & c, unsigned level) const
+void constant::do_print(const print_context & c, unsigned level) const
 {
-       if (is_a<print_tree>(c)) {
-               c.s << std::string(level, ' ') << name << " (" << class_name() << ")"
-                   << std::hex << ", hash=0x" << hashvalue << ", flags=0x" << flags << std::dec
-                   << std::endl;
-       } else if (is_a<print_latex>(c)) {
-               c.s << TeX_name;
-       } else if (is_a<print_python_repr>(c)) {
-               c.s << class_name() << "('" << name << "'";
-               if (TeX_name != "\\mbox{" + name + "}")
-                       c.s << ",TeX_name='" << TeX_name << "'";
-               c.s << ')';
-       } else
-               c.s << name;
+       c.s << name;
+}
+
+void constant::do_print_tree(const print_tree & c, unsigned level) const
+{
+       c.s << std::string(level, ' ') << name << " (" << class_name() << ")" << " @" << this
+           << std::hex << ", hash=0x" << hashvalue << ", flags=0x" << flags << std::dec
+           << std::endl;
+}
+
+void constant::do_print_latex(const print_latex & c, unsigned level) const
+{
+       c.s << TeX_name;
+}
+
+void constant::do_print_python_repr(const print_python_repr & c, unsigned level) const
+{
+       c.s << class_name() << "('" << name << "'";
+       if (TeX_name != "\\mbox{" + name + "}")
+               c.s << ",TeX_name='" << TeX_name << "'";
+       c.s << ')';
 }
 
 ex constant::evalf(int level) const