Version: 0.6.0
dataset.h
1 // Name: dataset.h
3 // Purpose: dataset base class declarations
4 // Author: Moskvichev Andrey V.
5 // Created: 2008/11/07
6 // Copyright: (c) 2008-2010 Moskvichev Andrey V.
7 // Licence: wxWidgets licence
9 
10 #ifndef DATASET_H_
11 #define DATASET_H_
12 
13 #include <wx/wxfreechartdefs.h>
14 
15 #include <time.h>
16 
17 #include <wx/refobject.h>
18 
19 #include <wx/observable.h>
20 #include <wx/chartrenderer.h>
21 #include <wx/marker.h>
22 
23 #include <wx/dynarray.h>
24 
25 class Dataset;
26 class DateTimeDataset;
27 
28 #define FOREACH_SERIE(index, dataset) \
29  for (size_t index = 0; index < dataset->GetSerieCount(); index++)
30 
31 #define FOREACH_DATAITEM(index, serie, dataset) \
32  for (size_t index = 0; index < dataset->GetCount(serie); index++)
33 
37 class WXDLLIMPEXP_FREECHART DatasetObserver
38 {
39 public:
41  virtual ~DatasetObserver();
42 
43  virtual void DatasetChanged(Dataset *dataset) = 0;
44 };
45 
50 class WXDLLIMPEXP_FREECHART Dataset : public wxObject,
51  public RefObject, public Observable<DatasetObserver>, public DrawObserver
52 {
53  DECLARE_CLASS(Dataset)
54 public:
55  Dataset();
56  virtual ~Dataset();
57 
62  void SetRenderer(Renderer *renderer);
63 
64  Renderer *GetBaseRenderer();
65 
71  void BeginUpdate();
72 
78  void EndUpdate();
79 
84  virtual size_t GetSerieCount() = 0;
85 
91  virtual size_t GetCount(size_t serie) = 0;
92 
98  virtual wxString GetSerieName(size_t serie) = 0;
99 
105  virtual double GetMinValue(bool vertical) = 0;
106 
112  virtual double GetMaxValue(bool vertical) = 0;
113 
114  virtual DateTimeDataset *AsDateTimeDataset();
115 
120  void AddMarker(Marker *marker);
121 
126  size_t GetMarkersCount();
127 
133  Marker *GetMarker(size_t index);
134 
135  //
136  // DrawObjectObserver
137  //
138  // Received from renderer, or marker
139  virtual void NeedRedraw(DrawObject *obj);
140 
141 protected:
146  virtual bool AcceptRenderer(Renderer *r) = 0;
147 
152  void DatasetChanged();
153 
154  Renderer *m_renderer;
155 private:
156  bool m_updating;
157  bool m_changed;
158 
159  MarkerArray m_markers;
160 
161  FIRE_WITH_THIS(DatasetChanged);
162 };
163 
167 class WXDLLIMPEXP_FREECHART DateTimeDataset
168 {
169 public:
170  DateTimeDataset();
171  virtual ~DateTimeDataset();
172 
178  virtual time_t GetDate(size_t index) = 0;
179 
184  virtual size_t GetCount() = 0;
185 };
186 
187 WX_DECLARE_USER_EXPORTED_OBJARRAY(Dataset *, DatasetArrayBase, WXDLLIMPEXP_FREECHART);
188 
189 class WXDLLIMPEXP_FREECHART DatasetArray : public DatasetArrayBase
190 {
191 public:
192  DatasetArray();
193  virtual ~DatasetArray();
194 
195  void Add(Dataset *dataset);
196 
197  void Remove(Dataset *dataset);
198 
199  void RemoveAt(size_t index, size_t count = 1);
200 };
201 
202 #endif /*DATASET_H_*/
Definition: chartrenderer.h:21
Definition: dataset.h:189
Definition: observable.h:14
Definition: drawobject.h:23
Definition: refobject.h:8
Definition: drawobject.h:45
Definition: dataset.h:167
virtual void NeedRedraw(DrawObject *obj)=0
Definition: marker.h:24
Definition: dataset.h:50
Definition: dataset.h:37