PhysicalLogger.hpp

Go to the documentation of this file.
00001 //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
00002 //
00003 //        This file is part of E-Cell Simulation Environment package
00004 //
00005 //                Copyright (C) 2000-2001 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 Gabor Bereczki <gabor.bereczki@talk21.com>
00028 //
00029 
00030 
00031 #if !defined(__PHYSICALLOGGER_HPP)
00032 #define __PHYSICALLOGGER_HPP
00033 
00034 #include "libecs.hpp"
00035 
00036 #include "VVector.h"
00037 
00038 #include "Exceptions.hpp"
00039 #include "DataPoint.hpp"
00040 #include "DataPointVector.hpp"
00041 
00042 namespace libecs
00043 {
00044 
00045 
00046   /** @addtogroup logging
00047    *@{
00048    */
00049 
00050   /** @file */
00051 
00052 
00053   class PhysicalLogger
00054   {
00055 
00056     //    DECLARE_TYPE( _DATAPOINT, DATAPOINT );
00057     //    typedef vvector<DATAPOINT> Vector;
00058 
00059     typedef vvector<DataPoint> Vector;
00060     
00061   public:
00062 
00063     DECLARE_TYPE( Vector::size_type, VectorIterator );
00064     DECLARE_TYPE( Vector::size_type, size_type );
00065 
00066     PhysicalLogger()
00067     {
00068       setMaxSize( 0 ); // no limit
00069     }
00070 
00071     virtual ~PhysicalLogger()
00072     {
00073       ; // do nothing
00074     }
00075         
00076     void push( DataPointCref aDataPoint )
00077     {
00078       theVector.push_back( aDataPoint );
00079     }
00080 
00081     void setEndPolicy( Integer anEndPolicy )
00082     {
00083       theVector.setEndPolicy ( anEndPolicy );
00084     }
00085 
00086     int getEndPolicy() const
00087     {
00088       return theVector.getEndPolicy();
00089     }
00090 
00091     /// set max storage size in Kbytes.
00092 
00093     void setMaxSize( size_type aMaxSize )
00094     {
00095       theMaxSize = aMaxSize;
00096       theVector.setMaxSize( ( theMaxSize * 1024 ) / 
00097                             sizeof( DataPoint ) );
00098     }
00099 
00100     size_type getMaxSize() const
00101     {
00102       return theMaxSize;
00103     }
00104 
00105     size_type lower_bound( const size_type start,
00106                            const size_type end,
00107                            const Real time ) const;
00108 
00109     size_type upper_bound( const size_type start,
00110                            const size_type end,
00111                            const Real time ) const;
00112 
00113     size_type lower_bound_linear( const size_type start,
00114                                   const size_type end,
00115                                   const Real time ) const;
00116 
00117     size_type upper_bound_linear( const size_type start,
00118                                   const size_type end,
00119                                   const Real time ) const;
00120 
00121     size_type lower_bound_linear_backwards( const size_type start,
00122                                             const size_type end,
00123                                             const Real time ) const;
00124 
00125     size_type lower_bound_linear_estimate( const size_type start,
00126                                            const size_type end,
00127                                            const Real time,
00128                                            const Real time_per_step ) const;
00129 
00130     size_type upper_bound_linear_estimate( const size_type start,
00131                                            const size_type end,
00132                                            const Real time,
00133                                            const Real time_per_step ) const;
00134     
00135     DataPointVectorSharedPtr getVector( const size_type start,
00136                                         const size_type end ) const;
00137 
00138     ECELL_API size_type size() const;
00139 
00140     bool empty() const;
00141 
00142 
00143     LongDataPoint at( size_type index) const
00144     {
00145       return theVector[ index ];
00146     }
00147     
00148     size_type begin() const
00149     {
00150       return 0;
00151     }
00152     
00153     
00154     size_type end() const
00155     {
00156       if ( size() > 0 )
00157         {
00158           return size() - 1;
00159         }
00160       else
00161         {
00162           return 0;
00163         }
00164     }
00165 
00166 
00167     LongDataPoint front() const
00168     {
00169       if ( empty() )
00170         {
00171           return DataPoint();
00172         }
00173       
00174       return at( begin() );
00175     }
00176     
00177     LongDataPoint back() const
00178     {
00179       if ( empty() )
00180         {
00181           return DataPoint();
00182         }
00183       
00184       return at( end() );
00185     }
00186   
00187     Real getAverageInterval() const;
00188 
00189   private:
00190 
00191     // this mutable can be removed if vvector supports const operations
00192     mutable Vector      theVector;
00193 
00194     size_type      theMaxSize;
00195 
00196   };
00197 
00198 
00199   //@}
00200 
00201 } // namespace libecs
00202 
00203 
00204 #endif /* __PHYSICALLOGGER_HPP */

Generated on Fri Aug 31 18:32:07 2007 for E-CELL C++ libraries (libecs and libemc) 3.1.105 by  doxygen 1.5.3