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 | ||
public | static const int | first_page |
public | static const int | unknown |
private | PacketPipe* | _pipe |
private | LDPPacket* | p |
private | int | position |
private | int | _npages |
private | int | _prev_npages |
private | double | _prev_time |
private | int | _prev_apid |
private | int | _prev_product |
private | int | _prev_page |
private | int | _prev_size |
private | int | hit_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()
|
public | virtual | int | newProduct()
|
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 |