printer.h

00001 
00002 //  Math Type Library
00003 //  $Id: printer.h,v 1.5 2002/04/20 06:31:21 cparpart Exp $
00004 //  (This file contains the expression stream printer specific interface)
00005 //
00006 //  Copyright (c) 2002 by Christian Parpart <cparpart@surakware.net>
00007 //
00008 //  This library is free software; you can redistribute it and/or
00009 //  modify it under the terms of the GNU Library General Public
00010 //  License as published by the Free Software Foundation; either
00011 //  version 2 of the License, or (at your option) any later version.
00012 //
00013 //  This library is distributed in the hope that it will be useful,
00014 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016 //  Library General Public License for more details.
00017 // 
00018 //  You should have received a copy of the GNU Library General Public License
00019 //  along with this library; see the file COPYING.LIB.  If not, write to
00020 //  the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00021 //  Boston, MA 02111-1307, USA.
00023 #ifndef libmath_printer_h
00024 #define libmath_printer_h
00025 
00026 #include <math++/visitor.h>
00027 
00028 #include <iosfwd>
00029 
00030 namespace math {
00031 
00036 template<class T>
00037 class TPrinter : public TNodeVisitor<T> {
00038 private:
00039     std::ostream& FStream;
00040     TPrinter(std::ostream& AOutput);
00041 
00043     void savePrint(const TNode<T> *ANode, const TNode<T> *AParent);
00044 
00045     virtual void visit(TNumberNode<T> *);
00046     virtual void visit(TSymbolNode<T> *);
00047     virtual void visit(TParamNode<T> *);
00048 
00049     virtual void visit(TPlusNode<T> *);
00050     virtual void visit(TNegNode<T> *);
00051 
00052     virtual void visit(TMulNode<T> *);
00053     virtual void visit(TDivNode<T> *);
00054 
00055     virtual void visit(TPowNode<T> *);
00056     virtual void visit(TSqrtNode<T> *);
00057     
00058     virtual void visit(TSinNode<T> *);
00059     virtual void visit(TCosNode<T> *);
00060     virtual void visit(TTanNode<T> *);
00061     virtual void visit(TLnNode<T> *);
00062 
00063     virtual void visit(TFuncNode<T> *);
00064     virtual void visit(TIfNode<T> *);
00065 
00066     virtual void visit(TEquNode<T> *);
00067     virtual void visit(TUnEquNode<T> *);
00068     virtual void visit(TGreaterNode<T> *);
00069     virtual void visit(TLessNode<T> *);
00070     virtual void visit(TGreaterEquNode<T> *);
00071     virtual void visit(TLessEquNode<T> *);
00072 
00073 public:
00077     static void printOn(std::ostream& AOutput, const TNode<T> *AExpr);
00078     
00085     static std::string print(const TNode<T> *AExpr);
00086 };
00087 
00088 } // namespace math
00089 
00090 #include <math++/printer.tcc>
00091 
00092 #endif

Generated on Mon Nov 28 20:08:59 2005 for MathTypeLibrary(libmath++) by  doxygen 1.4.5