GTimeSeries Class Reference

[libgfc Index] [libgfc Hierarchy] [Headers]


GTimeSeries manages a time series. More...

#include <src/gtseries.h>

Public Members


Detailed Description

A time series is simply a list of episodes of (TIMESTAMP, EVENT_DESC),

where the TIMESTAMP is the time an event of interest happened.

The event here is a rather broad concept, it can be virtualy

anything worthing recording. THe EVENT_DESC is a pointer (not the actual

entity) to a record of the associated event. One

use of the EVENT_DESC is to store an record ID of an externaly stored

event. But it is really an opaque data structure as far as time series

is concerned.

When the list of episodes are sorted (as they always are), the order

is that the older (earlier) the episode, the smaller the value.

The main methods for GTimeSeries includes: inserting/deleting,

iterating and generalizing the timestamps etc.

When iterating the series, first call firstEpisode() or lastEpisode(),

depending on which direction you want to scan the episodes, which

will return a pointer to the correct episode; then call that episode's

nextEpisode() or prevEpisode() correspondingly.

Note: the time series stores only the pointer to episodes! So if you

want to store two episodes, they must be physically different

objects (allocated using two new() opeations). If you just

allocate one episode, and try to add two episodes to the series

by assigning two different timestamp to the same episode object,

it won't work! The doubly-linked list will be messed up if you

add the same objects twice!

Also note that it uses the GTimestamp class extensively, but

GTimeSeries isn't an ADT per se., aka, it can't be stored in a

database.


void setTimeUnit(TimeUnit u) [public]

set the unit time for the series

TimeUnit timeUnit(void) const [public]

return the current time unit for the series

Result addEpisode(GEpisode* r) [public]

add an episode into the series (in sorted order)

Result delEpisode(GEpisode* r) [public]

delete an episode from the series (and put back to the pool)

Result addRange(const GDate.html">GDate& from, const GDate.html">GDate& to, int delta=1) [public]

For every 'delta' time unit between 'from' (included) and 'to', generate an episode and add the episode to the series. The newly added episodes will be in sorted order.

Result addRange(const GTimestamp.html">GTimestamp& begin, const GTimestamp.html">GTimestamp& end, int delta=1) [public]

same as above, except it accepts GTimestamps

Result reset(TimeUnit u=_INVALID) [public]

delete all the episodes and reset to the new time unit if different

int numEpisodes(void) const [public]

return number of episodes in the series

GEpisode* firstEpisode(void) const [public]

return the first episodes in the series

GEpisode* lastEpisode(void) [public]

return the last episode (most recent one)

Result generalize(TimeUnit new_unit) [public]

generalize the series to a larger unit (eg, hours -> days)

bool isEmpty(void) [public]

return true if the series is empty


Documentation generated by lqian@lqian-sun on Wed Jul 14 09:36:10 EDT 1999
Kdoc