00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
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
00047
00048
00049
00050
00051
00052
00053 class PhysicalLogger
00054 {
00055
00056
00057
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 );
00069 }
00070
00071 virtual ~PhysicalLogger()
00072 {
00073 ;
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
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
00192 mutable Vector theVector;
00193
00194 size_type theMaxSize;
00195
00196 };
00197
00198
00199
00200
00201 }
00202
00203
00204 #endif