#include <timeseries.h>
Public Member Functions | |
TYPE_DESCRIPTOR ((KEY(blockId, INDEXED), FIELD(used), FIELD(elements))) | |
Public Attributes | |
db_int8 | blockId |
db_int4 | used |
dbArray< T > | elements |
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\n", quoteBuf[i].bid, quoteBuf[i].ask); } }
The documentation for this class was generated from the following file: