Interpolant.hpp

00001 //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
00002 //
00003 //        This file is part of E-Cell Simulation Environment package
00004 //
00005 //                Copyright (C) 1996-2002 Keio University
00006 //
00007 //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
00008 //
00009 //
00010 // E-Cell is free software; you can redistribute it and/or
00011 // modify it under the terms of the GNU General Public
00012 // License as published by the Free Software Foundation; either
00013 // version 2 of the License, or (at your option) any later version.
00014 // 
00015 // E-Cell is distributed in the hope that it will be useful,
00016 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00018 // See the GNU General Public License for more details.
00019 // 
00020 // You should have received a copy of the GNU General Public
00021 // License along with E-Cell -- see the file COPYING.
00022 // If not, write to the Free Software Foundation, Inc.,
00023 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00024 // 
00025 //END_HEADER
00026 //
00027 // written by Koichi Takahashi <shafi@e-cell.org>,
00028 // E-Cell Project.
00029 //
00030 
00031 #ifndef __INTERPOLANT_HPP
00032 #define __INTERPOLANT_HPP
00033 
00034 #include "libecs.hpp"
00035 
00036 namespace libecs
00037 {
00038 
00039   class Interpolant
00040   {
00041     friend class libecs::Stepper;
00042 
00043 
00044   public:
00045 
00046     class VariablePtrCompare
00047     {
00048     public:
00049       bool operator()( InterpolantCptr const aLhs, 
00050                        InterpolantCptr const aRhs ) const
00051       {
00052         return compare( aLhs->getVariable(), aRhs->getVariable() );
00053       }
00054 
00055       bool operator()( InterpolantCptr const aLhs,
00056                        VariableCptr const aRhs ) const
00057       {
00058         return compare( aLhs->getVariable(), aRhs );
00059       }
00060 
00061       bool operator()( VariableCptr const aLhs, 
00062                        InterpolantCptr const aRhs ) const
00063       {
00064         return compare( aLhs, aRhs->getVariable() );
00065       }
00066 
00067     private:
00068 
00069       // if statement can be faster than returning an expression directly
00070       inline static bool compare( VariableCptr const aLhs, 
00071                                   VariableCptr const aRhs )
00072       {
00073         if( aLhs < aRhs )
00074           {
00075             return true;
00076           }
00077         else
00078           {
00079             return false;
00080           }
00081       }
00082 
00083 
00084     };
00085 
00086 
00087     ECELL_API Interpolant( VariablePtr const aVariable );
00088 
00089     ECELL_API virtual ~Interpolant();
00090     
00091     virtual 
00092     const Real getVelocity( RealParam aTime ) const
00093     {
00094       return 0.0;
00095     }
00096     
00097     virtual 
00098     const Real getDifference( RealParam aTime, RealParam anInterval ) const
00099     {
00100       return 0.0;
00101     }
00102      
00103    VariablePtr const getVariable() const
00104     {
00105       return theVariable;
00106     }
00107 
00108   private:
00109 
00110     VariablePtr const theVariable;
00111     
00112   };
00113 
00114 
00115   DECLARE_VECTOR( InterpolantPtr, InterpolantVector );
00116 
00117 }
00118 
00119 
00120 
00121 #endif /* __INTERPOLANT_HPP */
00122 
00123 
00124 
00125 /*
00126   Do not modify
00127   $Author: sachiboo $
00128   $Revision: 2621 $
00129   $Date: 2006-11-24 13:19:59 +0100 (Fri, 24 Nov 2006) $
00130   $Locker$
00131 */

Generated on Mon Dec 18 07:24:07 2006 for E-CELL C++ libraries (libecs and libemc) 3.1.105 by  doxygen 1.5.1