Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

c:/home/kevn/src/animaniac/ani/Dynamics/SolverFactory.h

Go to the documentation of this file.
00001 
00003 //
00004 //                         -=     SolverFactory     =-
00005 //
00006 // Definition: "a class that creates ODE solvers from a given text string"
00007 //
00009 //
00010 //    $RCSfile: SolverFactory.h,v $
00011 //    $Date: 2002/06/07 03:22:37 $
00012 //    $Revision: 1.5 $
00013 //    Copyright (C) 1998, 1999, 2000  Kevin Meinert, kevin@vrsource.org
00014 //
00015 //    This library is free software; you can redistribute it and/or
00016 //    modify it under the terms of the GNU Library General Public
00017 //    License as published by the Free Software Foundation; either
00018 //    version 2 of the License, or (at your option) any later version.
00019 //
00020 //    This library is distributed in the hope that it will be useful,
00021 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00023 //    Library General Public License for more details.
00024 //
00025 //    You should have received a copy of the GNU Library General Public
00026 //    License along with this library; if not, write to the Free
00027 //    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00028 //
00030 #ifndef SOLVER_FACTORY
00031 #define SOLVER_FACTORY
00032 
00033 #include <string>
00034 #include "ani/Dynamics/ODEsolver.h"
00035 #include "ani/Dynamics/solvers/EulerODEsolver.h"
00036 #include "ani/Dynamics/solvers/ModifiedEulerODEsolver.h"
00037 #include "ani/Dynamics/solvers/HeunODEsolver.h"
00038 #include "ani/Dynamics/solvers/RungeKuttaODEsolver.h"
00039 
00040 
00041 namespace ani
00042 {
00043 
00044    template <class _item>
00045    class SolverFactory
00046    {
00047    public:
00048       // request a solver
00049       static bool create( const std::string& solverName, ODEsolver<_item>* &newSolver )
00050       {
00051          if (solverName == "euler")
00052          {
00053             newSolver = new EulerODEsolver<_item>;
00054          }
00055          else if (solverName == "modified euler")
00056          {
00057             newSolver = new ModifiedEulerODEsolver<_item>;
00058          }
00059          else if (solverName == "heun") // midpoint
00060          {
00061             newSolver = new HeunODEsolver<_item>;
00062          }
00063          else if (solverName == "runge kutta")
00064          {
00065             newSolver = new RungeKuttaODEsolver<_item>;
00066          }
00067          else 
00068          {
00069             // default, most simple, fast
00070             newSolver = new EulerODEsolver<_item>;
00071          }      
00072          return true;
00073       } 
00074    };
00075 
00076 }
00077 
00078 #endif

Generated on Wed Jun 12 01:54:01 2002 for Animaniac by doxygen1.2.15