Main Page   Class Hierarchy   Compound List   File List   Compound Members  

dbTimeSeriesBlock< T > Class Template Reference

#include <timeseries.h>

List of all members.


Detailed Description

template<class T>
class dbTimeSeriesBlock< T >

Time series block contaning array of elements. Grouping several elements in one block (record) reduce space overhead and increase processing speed.
Attention! This class is not serialized, so it is can be accessed only by one thread

You are defining your own time series class, for example:

 class Stock {
   public:
     char const* name;
     TYPE_DESCRIPTOR((KEY(name, INDEXED)));
 };
 
 
 class Quote {
   public:
     int4        tickerDate;
     real4       bid;
     int4        bidSize;
     real4       ask;
     int4        askSize;
 
     time_t time() const { return tickerDate; } // this method should be defined 
 
     TYPE_DESCRIPTOR((FIELD(tickerDate), FIELD(bid), FIELD(bidSize), FIELD(ask), FIELD(askSize)));
 };
 typedef dbTimeSeriesBlock<Daily>  DailyBlock;
 REGISTER(DailyBlock);
 
Now you can work with time series objects in the followin way:
 dbDatabase db;
 if (db.open("mydatabase.dbs")) {
     dbTimeSeriesProcessor<Quote> proc(db, MIN_ELEMENTS_IN_BLOCK,MAX_ELEMENTS_IN_BLOCK);
     Quote quote;
     // initialize quote
     Stock stock;
     stock.name = "AAD";
     oid_t stockId = insert(oid).getOid();
     proc.add(stockId, quote); // add new element in time series
 
     Quote quoteBuf[MAX_QUOTES];
     // select quotes for the specified interval
     int n = proc.getInterval(stockId, fromDate, tillDate, quoteBuf, MAX_QUOTES);
     for (int i = 0; i < n; i++) {
         printf("bid=d ask=d
", quoteBuf[i].bid, quoteBuf[i].ask); } }


The documentation for this class was generated from the following file:
Generated on Mon Oct 23 13:23:59 2006 for FastDB by doxygen1.2.18