XCube Stream Reader SDK
|
Class for packet reader. More...
#include <CPacketReader.h>
Classes | |
struct | _packet_handle_ |
Structure of packet handle. More... | |
Public Types | |
typedef struct CPacketReader::_packet_handle_ | packet_handle_t |
Structure of packet handle. | |
Public Member Functions | |
CPacketReader () | |
Constructor. | |
virtual | ~CPacketReader () |
De-constructor. | |
X3cPacket * | getPacket () |
Get/Read a packet. | |
void | freePacket (X3cPacket *pkt) |
Free a packet. | |
void | setPacketFilter (UINT64 start, UINT64 end) |
void | setTimeFilter (CTimeFilter const &tFilter) |
UINT64 | getPacketCount () const |
bool | initialize (std::vector< std::string > const &fileNames, size_t bufSz, size_t chunkSz) |
Initialize packet reader. | |
int | start () |
Start packet reader. | |
bool | stop () |
Stop packet reader. | |
void | getPacketHandle (packet_handle_t *hdl) |
Get the packet handle. | |
void | freePacketHandle (packet_handle_t *hdl) |
Free the packet handle. | |
void | reset () |
Reset the packet reader state. | |
Static Public Attributes | |
static const size_t | MAX_DISK_READ_SIZE_MB = 128 |
Maxium data size a disk can read. |
Class for packet reader.
The packet reader is the base class to read packets from an X3C parallel or serial input streams (File or other) the system shall be called in this sequence: 1: setinputFiles - initialize the input file names 2: setreadChunks - how big the input buffer from the disk shall be 3: set buffer_size - the size of the read buffer (how much data we shall keep in memory) 4: checkArguments - make sure we are OK with all inputs 5: startReader - starts the input streams 6: while we need more data () 6.1: getPacket() 6.2: (if packet == NULL check if we have EOF) 6.3: freePacket(pkt) - signals the reader that it is OK to free buffer space taken by packet 6.4: until we do not need more data or EOF 7: stopReader() - stops the reader threads 8: delete the packet reader ..
Constructor.
Creates a new packet reader object. The user must initialize the reader before it can be used.
virtual CPacketReader::~CPacketReader | ( | ) | [virtual] |
De-constructor.
Deletes the packet reader and the objects associated with it
void CPacketReader::freePacket | ( | X3cPacket * | pkt | ) |
Free a packet.
Free the packet pointed to by pkt.
pkt | - packet to free |
void CPacketReader::freePacketHandle | ( | packet_handle_t * | hdl | ) |
Free the packet handle.
Free a packet handle
hdl | - packet handle to free |
Get/Read a packet.
Read one packet from the combined buffers in time-stamp order
void CPacketReader::getPacketHandle | ( | packet_handle_t * | hdl | ) |
Get the packet handle.
Write packet and stream information into hdl, packet handle has the information about which stream the packet belongs to, so that when caller does not need to go through all streams.(this is the difference between packet and packethandle) - packet handle to record packet and stream info
bool CPacketReader::initialize | ( | std::vector< std::string > const & | fileNames, |
size_t | bufSz, | ||
size_t | chunkSz | ||
) |
Initialize packet reader.
This method initializes the PacketReader. It is to be called once directly after the reader has been created. If the initialization is successful the reader is ready to start. On error delete this reader object and start over.
fileCnt | - the number of input files to read from |
fileNames | - the qualified filenames of the input files |
bufSz | - the input buffer size in MByte |
chunkSz | - the requested read size from disk |
void CPacketReader::reset | ( | ) |
Reset the packet reader state.
Reset the packet reader state to its initial state
void CPacketReader::setPacketFilter | ( | UINT64 | start, |
UINT64 | end | ||
) | [inline] |
Sets a packet filter based on start and end packet number. To get to the start packet, accessed will be sequential.
start | - start packet number |
end | - end packet number |
void CPacketReader::setTimeFilter | ( | CTimeFilter const & | tFilter | ) | [inline] |
Sets a time based filter for the reader. Access to the start packet will use an index file if it exists.
tFilter | - a reference to the time filter to set |
int CPacketReader::start | ( | ) |
Start packet reader.
Starts the reader and initializes all data structures needed
bool CPacketReader::stop | ( | ) |
Stop packet reader.
Stop the Packet reader. This should be called before the packet reader is supposed to be destroyed ..