sends::seg_db Class Reference
[Sends Data Classes]

Segment database class. More...

#include <segdb.hh>

List of all members.

Public Types

typedef unsigned long seg_index
typedef unsigned long gps_type
typedef unsigned long chan_index
typedef std::vector< segmentseg_vect
typedef std::vector< qbasebase_vect

Public Member Functions

 seg_db (seg_index nSeg, seg_index nChan)
 construct a segment database.
 ~seg_db (void)
 seg_db destructor
bool chan_valid (chan_index chan) const
 Channel index test.
void clear (void)
std::ostream & dump (std::ostream &out) const
 Dump out the segment list.
seg_index end (void) const
 Null index.
seg_index find (chan_index chan, gps_type start, gps_type stop) const
 find a segment.
seg_index first_gt (chan_index chan, gps_type gps) const
 find a segment.
void free (seg_index iseg)
 Free a segment.
seg_index get_buffer (pool_mgr &pmgr, chan_index chan, double rate, int len, gps_type start, gps_type stop)
 Find a segment to containing the data.
seg_index get_segment (pool_mgr &pmgr, int buf_class)
 Find and unlink a free segment.
seg_index getOldest (int buf_class)
 Find and unlink a free segment.
void insert (seg_index inx)
 Insert a segment.
bool is_null (seg_index seg) const
 Test for null pointer.
seg_index last_leq (chan_index ichn, gps_type gps) const
 Find position in list for segment with gps t.
void make_new (seg_index inx)
 Move segment to end of age queue.
segmentoperator[] (seg_index seg)
 Get a segment reference.
const segmentoperator[] (seg_index seg) const
 Get a segment reference.
seg_index reserve (chan_index chan, gps_type start)
 Reserve a segment.

Classes

class  linkage
 Segment linkage class. More...
class  qbase
 Linked list anchor. More...


Detailed Description

Segment database class.

The segment database class contains a list of all memory-resident channel data segments. Each data-segment is represented by a segment object in the the pre-allocated vector. The segments objects are linked in two lists; a listof segments from each channel and a list of all segments in least recently used order. The linkage information for the two lists is maintained in separate vectors in the database.

Author:
J. Zweizig
Version:
1.1; Last Modified January 14, 2008

Member Typedef Documentation

typedef unsigned long sends::seg_db::seg_index

Data type to represent index into segment list.

typedef unsigned long sends::seg_db::gps_type

Data type for gps time.

typedef unsigned long sends::seg_db::chan_index

Data type for index into master channel list.

typedef std::vector<segment> sends::seg_db::seg_vect

Segment vector data type.

typedef std::vector<qbase> sends::seg_db::base_vect

Channel queue anchors.


Constructor & Destructor Documentation

sends::seg_db::seg_db ( seg_index  nSeg,
seg_index  nChan 
)

construct a segment database.

Construct a segment database with space for the specified number of segments and number of channels.

Parameters:
nSeg Number of segments to pre-allocate.
nChan Number of channel slots (lists) to pre-allocate.

sends::seg_db::~seg_db ( void   ) 

seg_db destructor

Destroy the segment database


Member Function Documentation

bool sends::seg_db::chan_valid ( chan_index  chan  )  const [inline]

Channel index test.

Test whether the channel index is valid

Parameters:
chan Channel index to test
Returns:
true if index is in valid range.

void sends::seg_db::clear ( void   ) 

Clear the segments database by looping over all channel queues and releasing the associated segments.

std::ostream& sends::seg_db::dump ( std::ostream &  out  )  const

Dump out the segment list.

Dump out the segments list.

Parameters:
out Output stream reference
Returns:
Output stream reference

seg_db::seg_index sends::seg_db::end ( void   )  const [inline]

Null index.

Return the segment list null index.

Returns:
Null index.

seg_index sends::seg_db::find ( chan_index  chan,
gps_type  start,
gps_type  stop 
) const

find a segment.

Find the first segment containing the specified times for the specified channel. If no segments are found in the specified channel and times, the null index is returned.

Parameters:
chan Channel index
start Start time.
stop End time.
Returns:
Index of first segment in the specified range.

seg_index sends::seg_db::first_gt ( chan_index  chan,
gps_type  gps 
) const

find a segment.

Find the first segment for the specified channel havning a start time greater than the specified gps.

Parameters:
chan Channel index
gps Compare time.
Returns:
Index of first segment after the specified time.

void sends::seg_db::free ( seg_index  iseg  ) 

Free a segment.

Insert the specified index into the front of the age queue.

Parameters:
iseg Index of segment to be freed.

seg_index sends::seg_db::get_buffer ( pool_mgr pmgr,
chan_index  chan,
double  rate,
int  len,
gps_type  start,
gps_type  stop 
)

Find a segment to containing the data.

Get a segment descriptor, that has, or will accomodate, the specified data. The reserve pointer is set to the stop time or the end of the buffer, as appropriate.

Parameters:
pmgr Buffer pool manager.
chan ID of channel for which the buffer with be allocated.
rate Channel sample rate.
len Channel data word length.
start Start time for which the buffer will be reserved.
stop End time for which the data will be reserved.
Returns:
Segment index.

seg_index sends::seg_db::get_segment ( pool_mgr pmgr,
int  buf_class 
)

Find and unlink a free segment.

Get a free segment descriptor. If an unused buffer is available, an unused segment is allocated and the buffer is attached. If no unused buffers or segments are found, the oldest appropriate unused segment is used. The descriptor is unlinked from both the age list and the channel list and it's index is returned.

Parameters:
buf_class Buffer class
Returns:
Index of the free segment.

seg_index sends::seg_db::getOldest ( int  buf_class  ) 

Find and unlink a free segment.

Get an unused segment descriptor with the specified buffer class, starting from the least recently used and working through the age list until an unused segment descriptor is found. The descriptor is unlinked from both the age list and the channel list and its index is returned.

Parameters:
buf_class Buffer class
Returns:
Index of the free segment.

void sends::seg_db::insert ( seg_index  inx  ) 

Insert a segment.

Insert the specified segment number into the age and channel lists.

Parameters:
inx Index of segment to be inserted.

bool sends::seg_db::is_null ( seg_index  seg  )  const [inline]

Test for null pointer.

Test if the specified index is the null pointer.

Parameters:
seg Index to be tested for null value.
Returns:
True if pointer is null.

seg_index sends::seg_db::last_leq ( chan_index  ichn,
gps_type  gps 
) const

Find position in list for segment with gps t.

Return the index of the last segment that starts at or before the specified gps.

Parameters:
ichn Index of channel list to be searched.
gps GPS time to be searched for.
Returns:
Index of last segment with data before or at gps.

void sends::seg_db::make_new ( seg_index  inx  ) 

Move segment to end of age queue.

Move the specified segment to the end (newest) position of the age queue.

Parameters:
inx Index of segment to be moved.

segment & sends::seg_db::operator[] ( seg_index  seg  )  [inline]

Get a segment reference.

Get a writable reference to the specified Segment.

Parameters:
seg index of the segment to be referenced.
Returns:
Writeable reference to the specified segment.

const segment & sends::seg_db::operator[] ( seg_index  seg  )  const [inline]

Get a segment reference.

Get a constant reference to the specified Segment.

Parameters:
seg index of the segment to be referenced.
Returns:
Constant reference to the specified segment.

seg_index sends::seg_db::reserve ( chan_index  chan,
gps_type  start 
)

Reserve a segment.

Reserve the segment containing the specified time for the specified channel and return the segment index. If a matching segment is found, its use count is incremented and it is moved to the end of the age list. If no segments are found with the specified channel and time, the null index is returned.

Parameters:
chan Channel index
start Start time.
Returns:
Index of first segment in the specified range.


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

Generated on Tue Jun 10 12:18:12 2008 for SENDS by  doxygen 1.5.5