Alphabetic Class Index   |   Class Inheritance Tree Index   |   Tool Index

Class: LDPBuffer

Parent class: streambuf

Description:
This class is for reading the contents of a Swift Large Data Product. To use it, you first must connect a stream of LDP packets to the input pipe returned by the pipe() method. Then you probably want to create an istream wrapped around the LDPBuffer. At this point you can read from the istream just as you would a file containing the decoded contents of the LDP. A typical use would be to wrap the istream in a Reader object so you can decode binary data.

A streambuf has a limited way of signaling errors. All it can do is report EOF. However, many complicated things can go wrong with a stream of LDP packets. Therefore this class uses the following strategy. Whenever anything goes wrong it signals EOF. You may then call one of the moreData(), newProduct(), missingPages(), or missingBytes() status methods to figure out what is going on. In some cases you might want to continue reading data after the LDPBuffer reports EOF. Then you simply reset the istream status using its clear() method.

The apid(), product(), page(), and size() methods and their "prev_" counterparts can be used to get information about the current (or previous) packet being read.

This class does not currently support "seeking". In other words each byte must be read sequentially.

Data Fields
publicstatic const intfirst_page
publicstatic const intunknown
privatePacketPipe*_pipe
privateLDPPacket*p
privateintposition
privateint_npages
privateint_prev_npages
privatedouble_prev_time
privateint_prev_apid
privateint_prev_product
privateint_prev_page
privateint_prev_size
privateinthit_eof_in_last_block_read

Constructors / Destructor
public LDPBuffer()
Constructor.
public ~LDPBuffer()

Methods
public virtual PacketPipe& pipe()
public virtual int prev_apid()
public virtual int prev_product()
public virtual int prev_page()
public virtual int prev_size()
public virtual double prev_time()
public virtual int apid()
public virtual int product()
public virtual int page()
public virtual int size()
public virtual double time()
public virtual int moreData()
  • Returns 0 if we have read all the packets from the stream
  • Returns 1 otherwise
public virtual int newProduct()
  • Returns 1 if the current and previous packets were in different products
  • Returns 0 if the current and previous packets were in the same product
  • Returns 1 if the current packet is the first ever read or if no packets have been read.
  • Returns 1 if at the end of the data stream
public virtual int missingPages()
Returns the number of pages missing between the packet currently being read and the previous packet. If called at EOF, this will tell whether a gap was encountered and how large it was (in packets). Returns 0 if no packets have been read yet or if a product ended, but we didn't know how many pages it should contain.
public virtual int missingBytes()
Returns the result of missingPages() multiplied by the number of bytes per page. It looks at the packets on either side of the gap (if any) to determine the page size. Returns LDPBuffer::unknown if the page size can't be determined. This method assumes packets have uniform size, except for the last non-redundant packet. If this is not true, this method could return incorrect results.
public virtual int underflow()
This method is required to implement a streambuf subclass. It gets called whenever someone tries to read past the end of the current packet. It resets the internal buffer to the next packet, and returns the first byte in that packet as an int. It returns EOF if there are any problems.
public virtual int uflow()
This is just like the "underflow" method, except that it increments the buffer pointer by one to account for the character it returns.
private int nextPacket()
Private method for pulling the next packet out of the pipe. Returns 1 if there is anything funny going on between the two packets, like a gap or a product number or APID change, or if a NULL packet was pulled out of the pipe. Returns 0 if everything is fine.

Operators


Alphabetic Class Index   |   Class Inheritance Tree Index   |   Tool Index