Mass++ Common Libraries v2.7.5
 All Classes Namespaces Files Functions Variables Enumerations Macros
XYData.h
Go to the documentation of this file.
1 
14 #ifndef __KOME_CORE_XY_DATA_H__
15 #define __KOME_CORE_XY_DATA_H__
16 
17 
18 #include "Point.h"
19 #include "Timer.h"
20 
21 #include <vector>
22 #include <list>
23 #include <boost/function.hpp>
24 #include <boost/optional.hpp>
25 
26 
27 namespace kome {
28  namespace core {
29 
34  class CORE_TOOLKITS_CLASS XYData {
35  public:
40  XYData();
41 
46  virtual ~XYData();
47 
48  protected:
50  bool m_updated;
51 
53  double m_minX;
54 
56  double m_maxX;
57 
59  double m_minY;
60 
62  double m_maxY;
63 
65  unsigned long m_version;
66 
67  private:
69  std::string m_tmpDataFile;
70 
72  bool m_released;
73 
74  private:
76  static const unsigned int m_cacheSize;
77 
78  protected:
80  static unsigned long m_currentVersion;
81 
82  public:
88  double getMinX();
89 
95  double getMaxX();
96 
102  double getMinY();
103 
109  double getMaxY();
110 
111  public:
116  void clearPoints();
117 
124  void addPoint( const double x, const double y );
125 
133  void insertPoint( const unsigned int index, const double x, const double y );
134 
142  void updatePoint( const unsigned int index, const double x, const double y );
143 
149  void deletePoint( const unsigned int index );
150 
156  unsigned int getLength();
157 
164  double getX( const unsigned int index );
165 
172  double getY( const unsigned int index );
173 
179  void reserve( const unsigned int num );
180 
181  public:
187  unsigned long getVersion();
188 
189  public:
196  int searchIndex( const double x );
197 
203  int getNearestIndex( const double x );
204 
211  void filter( const double absY = 0.0, const double relY = 0.0 );
212 
222  void getPoints( std::vector< Point< double > >& points, const bool ySort, const bool desc );
223 
224  public:
230  bool importData( boost::function< int ( void*, int ) > readFun );
231 
237  bool exportData( boost::function< int ( void*, int ) > writeFun );
238 
239  protected:
244  void updateRange();
245 
246  protected:
253  virtual bool onLoadData( boost::function< int ( void*, int ) > readFun );
254 
261  virtual bool onSaveData( boost::function< int ( void*, int ) > writeFun );
262 
263  protected:
268  virtual void onClearPoints() = 0;
269 
276  virtual void onAddPoint( const double x, const double y ) = 0;
277 
285  virtual void onInsertPoint( const unsigned int index, const double x, const double y ) = 0;
286 
292  virtual void onDeletePoint( const unsigned int index ) = 0;
293 
299  virtual unsigned int onGetLength() = 0;
300 
307  virtual double onGetX( const unsigned int index ) = 0;
308 
315  virtual double onGetY( const unsigned int index ) = 0;
316 
322  virtual void onReserve( const unsigned int num ) = 0;
323 
324  private:
329  void releaseData();
330 
335  void recoverData();
336 
337  private:
343  static std::list< XYData* >& getCacheList();
344  };
345  }
346 }
347 
348 #endif // __KOME_CORE_XY_DATA_H__
abstraction class of two dimention coordinate data
Definition: XYData.h:34
definition of Point class
interfaces of Timer class
double m_maxY
Definition: XYData.h:62
double m_maxX
Definition: XYData.h:56
static unsigned long m_currentVersion
version
Definition: XYData.h:80
unsigned long m_version
Definition: XYData.h:65
double m_minY
Definition: XYData.h:59
double m_minX
Definition: XYData.h:53