ClockWork DB CoreAPI 1.0.48
Abstract Time Series and Storage/Management Library
Loading...
Searching...
No Matches
sparse_series.hpp
1#ifndef HAVE_TOM_TSDB_SPARSE_SERIES_HPP
2#define HAVE_TOM_TSDB_SPARSE_SERIES_HPP
3
4#include <tom-tsdb/time_series.hpp>
5#include <tom-util/sparse_series.hpp>
6
7namespace tom {
8
9 namespace tsdb {
10
12
13 /* Bogus inheritance structure share same ancestor...we need a slight redesign
14 * i think...
15 */
16 class TOM_UTIL_API sparse_series : public virtual tom::tsdb::time_series
17 {
18 public:
19 virtual ~sparse_series() { }
20
21 virtual
22 void
23 set_ignore_missing_values( bool b ) = 0;
24
25 virtual
26 bool
27 get_ignore_missing_values( ) const = 0;
28
29 virtual
30 void
31 set_ignore_same_values( bool b ) = 0;
32
33 virtual
34 bool
35 get_ignore_same_values() const = 0;
36
37 virtual
38 void
39 set_fill_forward( bool b ) = 0;
40
41 virtual
42 bool
43 get_fill_forward( ) const = 0;
44
45 };
46
47 namespace collections {
48
49 template <typename T, typename NATIVE_TYPE>
50 class TOM_UTIL_API sparse_series : public tom::tsdb::sparse_series
51 {
52 public:
53 typedef typename T::value_type value_type;
54
57
59 aggregation_type, const tom::calendars::date_time &created,
60 const tom::calendars::date_time &modified );
61
62 template <typename IteratorT>
64 aggregation_type agg_t, const tom::calendars::date_time &created,
65 const tom::calendars::date_time &modified,
66 IteratorT begin, IteratorT end );
67
68 virtual datastore & get_datastore() const { return m_ds; }
69 virtual const values::data_type & get_data_type() const { return NATIVE_TYPE::Instance(); }
70 virtual aggregation_type get_aggregation_type() const;
71 virtual void set_aggregation_type( aggregation_type );
72
73 virtual const tom::string &get_name() const{ return m_name; }
74
75 virtual
77 begin() const;
78
79 virtual
81 end() const;
82
83 virtual const tom::observation &get_observation( const tom::calendars::date_int_type d ) const;
84 virtual const tom::observation &get_observation( const tom::calendars::date d ) const;
85 virtual void set_observation( const tom::calendars::date_int_type d, const tom::observation & val );
86 virtual void set_observation( const tom::calendars::date d, const tom::observation & val );
87 virtual void set_observation( tom::calendars::date_int_type d, const tom::Date & );
88 virtual void set_observation( tom::calendars::date d, const tom::Date & );
89 virtual const tom::observation & operator[ ]( const tom::calendars::date_int_type d ) const;
90 virtual tom::observation & operator[ ]( const tom::calendars::date_int_type d );
91 virtual const tom::observation & operator[ ] ( const tom::calendars::date d ) const;
92 virtual tom::observation & operator[ ] ( const tom::calendars::date d );
93 virtual tom::calendars::date_int_type get_first_date_int() const;
94 virtual tom::calendars::date_int_type get_last_date_int() const;
95
96 virtual std::ostream &print( std::ostream & ) const;
97 virtual tom::calendars::calendar & get_calendar( ) const;
98
99 virtual
100 const tom::calendars::date_time &
101 get_create_date_time() const { return m_create_date_time; }
102
103 virtual
104 const tom::calendars::date_time &
105 get_modify_date_time() const { return m_modify_date_time; }
106
107 virtual
108 bool
109 is_sparse_series() const{ return true; }
110
111 virtual
112 void
113 set_ignore_missing_values( bool b )
114 { m_data.set_ignore_missing_values( b ); }
115
116 virtual
117 bool
118 get_ignore_missing_values( ) const
119 { return m_data.get_ignore_missing_values( ); }
120
121 virtual
122 void
123 set_ignore_same_values( bool b )
124 { m_data.set_ignore_same_values( b ); }
125
126 virtual
127 bool
128 get_ignore_same_values() const
129 { return m_data.get_ignore_same_values( ); }
130
131 virtual
132 void
133 set_fill_forward( bool b )
134 { m_data.set_fill_forward( b ); }
135
136 virtual
137 bool
138 get_fill_forward( ) const
139 { return m_data.get_fill_forward( ); }
140
141 virtual
142 tom::calendars::date_int_type
144 { return m_data.get_first_date_int(); }
145
146 virtual
147 tom::calendars::date_int_type
149 { return m_data.get_last_date_int(); }
150
151 // maybe this should throw because
152 // sparse series must be serialized, or accessed
153 // with an iterator
154 virtual
155 const void *
156 get_raw_data() const { return NULL; }
157
158 protected:
159 virtual
160 void
161 set_create_date_time(const tom::calendars::date_time &d)
162 {
163 m_create_date_time = d;
164 }
165 virtual
166 void
167 set_modify_date_time(const tom::calendars::date_time &d)
168 {
169 m_modify_date_time = d;
170 }
171
172 aggregation_type m_agg_type;
173 datastore & m_ds;
174 tom::string m_name;
175 tom::calendars::date_time m_create_date_time;
176 tom::calendars::date_time m_modify_date_time;
178
179 };
180
181 template <typename T, typename NATIVE_TYPE>
182 sparse_series<T,NATIVE_TYPE>::sparse_series( tom::calendars::calendar &cal, datastore &ds,
183 const observation &name, aggregation_type agg_t ) :
184 m_agg_type(agg_t), m_ds(ds), m_name( String( name ).value() ), m_data(cal)
185 {
186 //m_name.to_upper();
187 }
188 template <typename T, typename NATIVE_TYPE>
189 sparse_series<T,NATIVE_TYPE>::sparse_series( tom::calendars::calendar &cal, datastore &ds,
190 const observation &name, aggregation_type agg_t,
191 const tom::calendars::date_time &created,
192 const tom::calendars::date_time &modified ) :
193 m_agg_type(agg_t), m_ds(ds), m_name( String( name ).value() ),
194 m_create_date_time( created ), m_modify_date_time( modified ), m_data(cal)
195 {
196 //m_name.to_upper();
197 }
198 template <typename T, typename NATIVE_TYPE>
199 template <typename IteratorT>
200 sparse_series<T,NATIVE_TYPE>::sparse_series( tom::calendars::calendar &cal, datastore &ds, const observation &name,
201 aggregation_type agg_t,
202 const tom::calendars::date_time &created,
203 const tom::calendars::date_time &modified,
204 IteratorT begin, IteratorT end ) :
205 m_agg_type(agg_t), m_ds(ds), m_name( String(name).value() ), m_create_date_time( created ),
206 m_modify_date_time( modified ), m_data(cal,begin,end)
207 {
208 //m_name.to_upper();
209 }
210 template <typename T, typename NATIVE_TYPE>
211 aggregation_type
213 {
214 return m_agg_type;
215 }
216 template <typename T, typename NATIVE_TYPE>
217 void
219 {
220 m_agg_type = agg_t;
221 }
222
223 template <typename T, typename NATIVE_TYPE>
224 const tom::observation &
225 sparse_series<T,NATIVE_TYPE>::get_observation( const tom::calendars::date_int_type d ) const
226 { return m_data.get_observation( d ); }
227
228 template <typename T, typename NATIVE_TYPE>
229 const tom::observation &
231 { return m_data.get_observation( d ); }
232
233 template <typename T, typename NATIVE_TYPE>
234 void
235 sparse_series<T,NATIVE_TYPE>::set_observation( const tom::calendars::date_int_type d, const tom::observation & val )
236 {
237 m_data.set_observation( d, val );
238 }
239
240 template <typename T, typename NATIVE_TYPE>
241 void
242 sparse_series<T,NATIVE_TYPE>::set_observation( const tom::calendars::date_int_type d, const tom::Date & val )
243 {
244 m_data.set_observation( d, val );
245 }
246
247 template <typename T, typename NATIVE_TYPE>
248 void
249 sparse_series<T,NATIVE_TYPE>::set_observation( const tom::calendars::date d, const tom::Date & val )
250 {
251 m_data.set_observation( d, val );
252 }
253
254 template <typename T, typename NATIVE_TYPE>
255 void
256 sparse_series<T,NATIVE_TYPE>::set_observation( const tom::calendars::date d, const tom::observation & val )
257 {
258 m_data.set_observation( d, val );
259 }
260
261 template <typename T, typename NATIVE_TYPE>
262 const tom::observation &
263 sparse_series<T,NATIVE_TYPE>::operator[ ]( const tom::calendars::date_int_type d ) const
264 { return m_data[ d ]; }
265
266 template <typename T, typename NATIVE_TYPE>
268 sparse_series<T,NATIVE_TYPE>::operator[ ]( const tom::calendars::date_int_type d )
269 { return m_data[ d ]; }
270
271 template <typename T, typename NATIVE_TYPE>
272 const tom::observation &
273 sparse_series<T,NATIVE_TYPE>::operator[ ] ( const tom::calendars::date d ) const
274 { return m_data[ d ]; }
275
276 template <typename T, typename NATIVE_TYPE>
278 sparse_series<T,NATIVE_TYPE>::operator[ ] ( const tom::calendars::date d )
279 { return m_data[ d ]; }
280
281
282 template <typename T, typename NATIVE_TYPE>
283 std::ostream &
284 sparse_series<T,NATIVE_TYPE>::print( std::ostream &os ) const
285 { return m_data.print( os ); }
286
287 template <typename T, typename NATIVE_TYPE>
289 sparse_series<T,NATIVE_TYPE>::get_calendar( ) const
290 { return m_data.get_calendar(); }
291
292 //virtual
293 template <typename T, typename NATIVE_TYPE>
294 tom::calendars::date_int_type
295 sparse_series<T,NATIVE_TYPE>::get_first_date_int() const
296 {
297 return m_data.get_first_date_int();
298 }
299
300 //virtual
301 template <typename T, typename NATIVE_TYPE>
302 tom::calendars::date_int_type
303 sparse_series<T,NATIVE_TYPE>::get_last_date_int() const
304 {
305 return m_data.get_last_date_int();
306 }
307 //virtual
308 template <typename T, typename NATIVE_TYPE>
310 sparse_series<T,NATIVE_TYPE>::begin() const
311 {
312 return m_data.begin();
313 }
314
315 //virtual
316 template <typename T, typename NATIVE_TYPE>
318 sparse_series<T,NATIVE_TYPE>::end() const
319 {
320 return m_data.end();
321 }
322
323 } // end collections namespace
324
325 } // end tsdb namespace
326
327} // end tom namespace
328
329#endif /*HAVE_TOM_TSDB_SPARSE_SERIES_HPP*/
Definition dates.hpp:22
Definition calendar.hpp:120
Definition calendar.hpp:47
Definition sparse_series.hpp:287
Definition time_series.hpp:157
Definition observation.hpp:13
Definition time_series.hpp:22
Definition sparse_series.hpp:51
virtual const tom::calendars::date_time & get_create_date_time() const
Definition sparse_series.hpp:101
virtual datastore & get_datastore() const
Definition sparse_series.hpp:68
virtual void set_aggregation_type(aggregation_type)
Definition sparse_series.hpp:218
virtual const tom::calendars::date_time & get_modify_date_time() const
Definition sparse_series.hpp:105
virtual aggregation_type get_aggregation_type() const
Definition sparse_series.hpp:212
virtual bool is_sparse_series() const
Definition sparse_series.hpp:109
virtual const tom::string & get_name() const
Definition sparse_series.hpp:73
virtual tom::calendars::date_int_type get_first_dirty_date_int() const
Definition sparse_series.hpp:143
virtual const values::data_type & get_data_type() const
Definition sparse_series.hpp:69
virtual tom::calendars::date_int_type get_last_dirty_date_int() const
Definition sparse_series.hpp:148
Definition datastore.hpp:445
Definition sparse_series.hpp:17
Definition time_series.hpp:313
Definition value_types.hpp:96