00001 /*************************************************************************** 00002 * Copyright (C) 2004-2006 by Radko Mihal * 00003 * rmihal@pobox.sk * 00004 * * 00005 * This program is free software; you can redistribute it and/or modify * 00006 * it under the terms of the GNU General Public License as published by * 00007 * the Free Software Foundation; either version 2 of the License, or * 00008 * (at your option) any later version. * 00009 * * 00010 * This program is distributed in the hope that it will be useful, * 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00013 * GNU General Public License for more details. * 00014 * * 00015 * You should have received a copy of the GNU General Public License * 00016 * along with this program; if not, write to the * 00017 * Free Software Foundation, Inc., * 00018 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * 00019 ***************************************************************************/ 00020 #ifndef FUNCTIONS_H 00021 #define FUNCTIONS_H 00022 00023 #include "acos.h" 00024 #include "asin.h" 00025 #include "atan.h" 00026 #include "ceil.h" 00027 #include "cos.h" 00028 #include "cosh.h" 00029 #include "exp.h" 00030 #include "fabs.h" 00031 #include "floor.h" 00032 #include "fmod.h" 00033 #include "ldexp.h" 00034 #include "log.h" 00035 #include "sin.h" 00036 #include "sinh.h" 00037 #include "sqrt.h" 00038 #include "tan.h" 00039 #include "tanh.h" 00040 #include "pow_class.h" 00041 00042 template< class Type > class expression; 00043 00044 template< class Type > 00045 class functions 00046 { 00047 grammar_to_parser::non_terminal< acos_class< Type > > m_acos; 00048 grammar_to_parser::non_terminal< asin_class< Type > > m_asin; 00049 grammar_to_parser::non_terminal< atan_class< Type > > m_atan; 00050 grammar_to_parser::non_terminal< ceil_class< Type > > m_ceil; 00051 grammar_to_parser::non_terminal< cos_class< Type > > m_cos; 00052 grammar_to_parser::non_terminal< cosh_class< Type > > m_cosh; 00053 grammar_to_parser::non_terminal< exp_class< Type > > m_exp; 00054 grammar_to_parser::non_terminal< fabs_class< Type > > m_fabs; 00055 grammar_to_parser::non_terminal< floor_class< Type > > m_floor; 00056 grammar_to_parser::non_terminal< fmod_class< Type > > m_fmod; 00057 grammar_to_parser::non_terminal< ldexp_class< Type > > m_ldexp; 00058 grammar_to_parser::non_terminal< log_class< Type > > m_log; 00059 grammar_to_parser::non_terminal< sin_class< Type > > m_sin; 00060 grammar_to_parser::non_terminal< sinh_class< Type > > m_sinh; 00061 grammar_to_parser::non_terminal< sqrt_class< Type > > m_sqrt; 00062 grammar_to_parser::non_terminal< tan_class< Type > > m_tan; 00063 grammar_to_parser::non_terminal< tanh_class< Type > > m_tanh; 00064 grammar_to_parser::non_terminal< pow_class< Type > > m_pow; 00065 00066 public: 00067 00068 functions() {}; 00069 ~functions() {}; 00070 00071 void push_parsers( grammar_to_parser::parsers &l ) 00072 { 00073 l.push_back( &m_pow ); 00074 l.push_back( &m_acos ); 00075 l.push_back( &m_asin ); 00076 l.push_back( &m_atan ); 00077 l.push_back( &m_ceil ); 00078 l.push_back( &m_cos ); 00079 l.push_back( &m_cosh ); 00080 l.push_back( &m_exp ); 00081 l.push_back( &m_fabs ); 00082 l.push_back( &m_floor ); 00083 l.push_back( &m_fmod ); 00084 l.push_back( &m_ldexp ); 00085 l.push_back( &m_log ); 00086 l.push_back( &m_sin ); 00087 l.push_back( &m_sinh ); 00088 l.push_back( &m_sqrt ); 00089 l.push_back( &m_tan ); 00090 l.push_back( &m_tanh ); 00091 } 00092 Type evaluate() 00093 { 00094 if( m_pow.is_parsed() ) return m_pow->evaluate(); 00095 if( m_acos.is_parsed() ) return m_acos->evaluate(); 00096 if( m_asin.is_parsed() ) return m_asin->evaluate(); 00097 if( m_atan.is_parsed() ) return m_atan->evaluate(); 00098 if( m_ceil.is_parsed() ) return m_ceil->evaluate(); 00099 if( m_cos.is_parsed() ) return m_cos->evaluate(); 00100 if( m_cosh.is_parsed() ) return m_cosh->evaluate(); 00101 if( m_exp.is_parsed() ) return m_exp->evaluate(); 00102 if( m_fabs.is_parsed() ) return m_fabs->evaluate(); 00103 if( m_floor.is_parsed() ) return m_floor->evaluate(); 00104 if( m_fmod.is_parsed() ) return m_fmod->evaluate(); 00105 if( m_ldexp.is_parsed() ) return m_ldexp->evaluate(); 00106 if( m_log.is_parsed() ) return m_log->evaluate(); 00107 if( m_sin.is_parsed() ) return m_sin->evaluate(); 00108 if( m_sinh.is_parsed() ) return m_sinh->evaluate(); 00109 if( m_sqrt.is_parsed() ) return m_sqrt->evaluate(); 00110 if( m_tan.is_parsed() ) return m_tan->evaluate(); 00111 if( m_tanh.is_parsed() ) return m_tanh->evaluate(); 00112 return 0; 00113 } 00114 00115 int get_priority() { return 1; } 00116 00117 }; 00118 00119 #endif