BIE::RecordInputStream Class Reference

Record input streams are used to read a series of records from one or more sources. More...

#include <RecordInputStream.h>

Inheritance diagram for BIE::RecordInputStream:
Collaboration diagram for BIE::RecordInputStream:

List of all members.

Public Member Functions

 ~RecordInputStream ()
 Virtual destructor.
virtual bool nextRecord ()
 Gets the next record from the input stream.
virtual bool eos ()
 Returns true if the end of this, or an inherited stream has been reached.
virtual bool error ()
 Returns true if an error has occured in this, or an inherited stream.
bool isRootStream ()
 Returns true if the stream is a root stream.
RecordInputStreamdeleteField (string fieldname)
 Produces a new stream with the specified field masked out.
RecordInputStreamdeleteField (int fieldindex)
 Produces a new stream with the specified field masked out.
RecordInputStreamdeleteRange (int startfield, int endfield)
 Deletes a range of fields & inherits all other buffers from the existing stream.
RecordInputStreamjoinWithStream (int position, RecordInputStream *stream)
 Stream Concatination.
RecordInputStreamselectFields (RecordType *selection)
 Creates a new stream containing only the fields specified by the type descriptor.
RecordInputStreamselectFields (vector< int > *selection)
 Creates a new input stream containing only the fields specified by the field indices.
RecordInputStreamselectFields (vector< string > *selection)
 Creates a new stream containing only the fields specified by the field names.
RecordInputStreamrenameField (string oldname, string newname)
 Renames the specified field.
RecordInputStreamrenameField (int fieldindex, string newname)
 Renames the specified field.
RecordInputStreammoveField (string fieldname, int newposition)
 Moves a field (specified by name) to a new position (specified by index) and "slides" the fields in between to fill in the vacated position.
RecordInputStreammoveField (int oldposition, int newposition)
 Moves a field (specified by index) to a new position (specified by index) and "slides" the fields in between to fill in the vacated position.
RecordInputStreamfilterWith (int position, RecordStreamFilter *filter)
 Pipes the input through a filter which can add new fields based on the values of the fields in the existing stream.
virtual string toString ()
 Returns a string representation of the stream.
Get value methods.
These methods return the value contained in the buffer.

The type of the field must match the type required by the method and the buffer must have a value.

string getStringValue (int fieldindex)
int getIntValue (int fieldindex)
double getRealValue (int fieldindex)
bool getBoolValue (int fieldindex)
string getStringValue (string fieldname)
int getIntValue (string fieldname)
double getRealValue (string fieldname)
bool getBoolValue (string fieldname)
vector< int > getIntArrayValue (int fieldindex)
vector< double > getRealArrayValue (int fieldindex)
vector< bool > getBoolArrayValue (int fieldindex)

Protected Member Functions

void noLongerRoot ()
 Called when another stream inherits part of the buffer of this stream.
void setAsRoot ()
 Called when a stream becomes a root stream (at creation time or after an inheriting stream is deleted).

Protected Attributes

vector< RecordInputStream * > ris_inherited
 A list of the streams this stream inherits.

Friends

class boost::serialization::access


Detailed Description

Record input streams are used to read a series of records from one or more sources.

New record input streams can be created by reading from a data source (e.g. a file, or a network socket), by concatenating two streams, and by inheriting and modifying an existing stream.

Inheriting streams constructs an implicit tree structure, in which the leaves are raw data sources, nodes with two children are where streams are combined, and nodes with one child modify the stream in some way. Data is always pulled from the 'root' stream in this tree - this is done by recursively calling the nextRecord() method (calls recurse in a depth first manner). Requiring that a node is only inherited at most once (each node has at most one parent) means that only one node controls the flow of data (trees branch towards the source).

This class implements all operations on streams - field deletion, filtering, selection, etc. All reader classes are subclasses of this class.


Constructor & Destructor Documentation

BIE::RecordInputStream::~RecordInputStream (  ) 

Virtual destructor.

Frees memory and makes inherited streams root streams again.


Member Function Documentation

virtual bool BIE::RecordInputStream::nextRecord (  )  [virtual]

Gets the next record from the input stream.

Returns true if a record was successfully obtained, and false otherwise.

Reimplemented in BIE::RecordInputStream_MPI, BIE::RecordInputStream_Ascii, BIE::RecordInputStream_Binary, and BIE::RecordInputStream_NetCDF.

RecordInputStream* BIE::RecordInputStream::deleteRange ( int  startfield,
int  endfield 
)

Deletes a range of fields & inherits all other buffers from the existing stream.

RecordInputStream* BIE::RecordInputStream::joinWithStream ( int  position,
RecordInputStream stream 
)

Stream Concatination.

The stream is "inserted" into the existing stream at the specified position.

RecordInputStream* BIE::RecordInputStream::selectFields ( RecordType selection  ) 

Creates a new stream containing only the fields specified by the type descriptor.

All the fields in the type descriptor must be present for this call to succeed. Both field name and field type must match.

RecordInputStream* BIE::RecordInputStream::selectFields ( vector< int > *  selection  ) 

Creates a new input stream containing only the fields specified by the field indices.

All indices must be within the bounds of the buffer. No duplicate indices are allowed.

RecordInputStream* BIE::RecordInputStream::selectFields ( vector< string > *  selection  ) 

Creates a new stream containing only the fields specified by the field names.

A NoSuchFieldException is thrown if a name is not present in the buffer type. No duplicate names are allowed.

RecordInputStream* BIE::RecordInputStream::moveField ( string  fieldname,
int  newposition 
)

Moves a field (specified by name) to a new position (specified by index) and "slides" the fields in between to fill in the vacated position.

RecordInputStream* BIE::RecordInputStream::moveField ( int  oldposition,
int  newposition 
)

Moves a field (specified by index) to a new position (specified by index) and "slides" the fields in between to fill in the vacated position.

RecordInputStream* BIE::RecordInputStream::filterWith ( int  position,
RecordStreamFilter filter 
)

Pipes the input through a filter which can add new fields based on the values of the fields in the existing stream.

The filter must be "useable".

void BIE::RecordInputStream::setAsRoot (  )  [protected]

Called when a stream becomes a root stream (at creation time or after an inheriting stream is deleted).


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

Send suggestions, questions, and feedback to WEINBERG at ASTRO dot UMASS dot EDU.
Documentation generated at Fri Mar 26 00:35:12 2010 by doxygen