Public Member Functions

dbTimeSeriesProcessor< T > Class Template Reference

#include <timeseries.h>

List of all members.

Public Member Functions

virtual void process (T const &data)
void add (oid_t oid, T const &data)
void select (oid_t oid, time_t from, time_t till)
time_t getFirstTime (oid_t oid)
time_t getLastTime (oid_t oid)
size_t getNumberOfElements (oid_t oid)
size_t getInterval (oid_t oid, time_t from, time_t till, T *buf, size_t bufSize)
bool getElement (oid_t oid, T &elem, time_t t)
size_t getFirstInterval (oid_t oid, time_t till, T *buf, size_t bufSize)
size_t getLastInterval (oid_t oid, time_t from, T *buf, size_t bufSize)
bool hasElement (oid_t oid, time_t t)
 dbTimeSeriesProcessor (dbDatabase &database, int minElementsInBlock=100, int maxElementsInBlock=100, time_t maxBlockTimeInterval=0)
int remove (oid_t oid, time_t from, time_t till)
int _openIteratorCursor (dbCursor< dbTimeSeriesBlock< T > > &cursor, oid_t oid, time_t from, time_t till)

Detailed Description

template<class T>
class dbTimeSeriesProcessor< T >

Time series processor.
Element of time series can be arbitrary type with declared TYPE_DESCRIPTOR and defined time_t time() method


Constructor & Destructor Documentation

template<class T>
dbTimeSeriesProcessor< T >::dbTimeSeriesProcessor ( dbDatabase database,
int  minElementsInBlock = 100,
int  maxElementsInBlock = 100,
time_t  maxBlockTimeInterval = 0 
) [inline]

TimeSeries processor constructor

Parameters:
database reference to the database
minElementsInBlock preallocated number of the elements in the block: array with specified number of elements will be allocated for new block
maxElementsInBlock maximal number of the elements in the block: block will be splitten if it has maxElementsInBlock elements and new is added to the block
maxBlockTimeInterval maximal interval between first and last element in the block, new block will be created if adding new element to the block cause violation of this assumption. If maxBlockTimeInterval is 0, then it is assigned to doubled number of seconds in day multipied on maxElementsInBlock

Member Function Documentation

template<class T>
int dbTimeSeriesProcessor< T >::_openIteratorCursor ( dbCursor< dbTimeSeriesBlock< T > > &  cursor,
oid_t  oid,
time_t  from,
time_t  till 
) [inline]

This method should be actually private but since there is no portable way of declaration of friend templates classes recognized by all C++ compiler, it is made public. Do not use this method yourself.

Referenced by dbTimeSeriesReverseIterator< T >::start(), and dbTimeSeriesIterator< T >::start().

template<class T>
void dbTimeSeriesProcessor< T >::add ( oid_t  oid,
T const &  data 
) [inline]

Add new element

Parameters:
oid time series identifer (OID of the object associated with this time series)
data reference to the inserted element
template<class T>
bool dbTimeSeriesProcessor< T >::getElement ( oid_t  oid,
T &  elem,
time_t  t 
) [inline]

Get time series element with specified time

Parameters:
oid time series identifer (OID of the object associated with this time series)
elem reference to the extracted element
t timestamp of extracted element
Returns:
true if element with specifed times exists in time series

References dbTimeSeriesProcessor< T >::getInterval().

Referenced by dbTimeSeriesProcessor< T >::hasElement().

template<class T>
size_t dbTimeSeriesProcessor< T >::getFirstInterval ( oid_t  oid,
time_t  till,
T *  buf,
size_t  bufSize 
) [inline]

Select first N elements of times series with timestamp less than or equal to specified

Parameters:
oid time series identifer (OID of the object associated with this time series)
till inclusive high bound for element timestamp (set INFINITE_TIME to disable this criteria)
buf destination buffer for selected elements
bufSize size of buffer: up to bufSize elements will be placed in buffer
Returns:
number of selected elements (can be less than bufSize if there are less elements in time series with timestamp less or equal than specified, but can not be greater than bufSize)

References dbCursor< T >::get(), dbCursor< T >::next(), and dbAnyCursor::select().

template<class T>
time_t dbTimeSeriesProcessor< T >::getFirstTime ( oid_t  oid  )  [inline]

Get the time of the first element in time series

Parameters:
oid time series identifer (OID of the object associated with this time series)
Returns:
earliest time in times series or -1 if there are no elements in time series

References dbAnyCursor::select(), and dbAnyCursor::setSelectionLimit().

template<class T>
size_t dbTimeSeriesProcessor< T >::getInterval ( oid_t  oid,
time_t  from,
time_t  till,
T *  buf,
size_t  bufSize 
) [inline]

Select elements belonging to the specified interval

Parameters:
oid time series identifer (OID of the object associated with this time series)
from inclusive low bound for element timestamp (set 0 to disable this criteria)
till inclusive high bound for element timestamp (set INFINITE_TIME to disable this criteria)
buf destination buffer for selected elements
bufSize size of buffer: up to bufSize elements will be placed in buffer
Returns:
number of elements belonging to the specified interval (can be greater than bufSize)

References dbCursor< T >::get(), dbCursor< T >::next(), and dbAnyCursor::select().

Referenced by dbTimeSeriesProcessor< T >::getElement().

template<class T>
size_t dbTimeSeriesProcessor< T >::getLastInterval ( oid_t  oid,
time_t  from,
T *  buf,
size_t  bufSize 
) [inline]

Select last N elements of times series with timestamp greater than or equal to specified

Parameters:
oid time series identifer (OID of the object associated with this time series)
from inclusive low bound for element timestamp (set 0 to disable this criteria)
buf destination buffer for selected elements
bufSize size of buffer: up to bufSize elements will be placed in buffer
Returns:
number of selected elements (can be less than bufSize if there are less elements in time series with timestamp greater or equal than specified, but can not be greater than bufSize)

References dbCursor< T >::get(), dbCursor< T >::last(), dbCursor< T >::prev(), and dbAnyCursor::select().

template<class T>
time_t dbTimeSeriesProcessor< T >::getLastTime ( oid_t  oid  )  [inline]

Get the time of the last element in time series

Parameters:
oid time series identifer (OID of the object associated with this time series)
Returns:
latest time in times series or -1 if there are no elements in time series

References dbAnyCursor::select(), and dbAnyCursor::setSelectionLimit().

template<class T>
size_t dbTimeSeriesProcessor< T >::getNumberOfElements ( oid_t  oid  )  [inline]

Get number of elements in time series.

Parameters:
oid time series identifer (OID of the object associated with this time series)
Returns:
number of elements in time series.

References dbCursor< T >::next(), and dbAnyCursor::select().

template<class T>
bool dbTimeSeriesProcessor< T >::hasElement ( oid_t  oid,
time_t  t 
) [inline]

Check if there is element for specified data in time series

Parameters:
oid time series identifer (OID of the object associated with this time series)
t timestamp of checked element
Returns:
true if element with specifed times exists in time series

References dbTimeSeriesProcessor< T >::getElement().

template<class T>
virtual void dbTimeSeriesProcessor< T >::process ( T const &  data  )  [inline, virtual]

Virtual method for processing elements, Should be redefinedin derived class.

Parameters:
data reference to the processed data element

Referenced by dbTimeSeriesProcessor< T >::select().

template<class T>
int dbTimeSeriesProcessor< T >::remove ( oid_t  oid,
time_t  from,
time_t  till 
) [inline]

Remove elements for the sepcified period

Parameters:
oid time series identifer (OID of the object associated with this time series)
from inclusive low bound for element timestamp (set 0 to disable this criteria)
till inclusive high bound for element timestamp (set INFINITE_TIME to disable this criteria)
Returns:
number of removed elements

References dbCursor< T >::get(), dbCursor< T >::next(), dbAnyCursor::remove(), dbAnyCursor::select(), and dbAnyCursor::update().

template<class T>
void dbTimeSeriesProcessor< T >::select ( oid_t  oid,
time_t  from,
time_t  till 
) [inline]

Process elements in the block belonging to the specified range

Parameters:
oid time series identifer (OID of the object associated with this time series)
from inclusive low bound for element timestamp (set 0 to disable this criteria)
till inclusive high bound for element timestamp (set INFINITE_TIME to disable this criteria)

References dbCursor< T >::get(), dbCursor< T >::next(), dbTimeSeriesProcessor< T >::process(), and dbAnyCursor::select().


The documentation for this class was generated from the following file: