pelican/server/test/src/TestChunker.cpp
/**
 * @details
 * Gets the next chunk of data from the device (if it exists).
 */
@details
Gets the next chunk of data from the device (if it exists).
@details Gets the next chunk of data from the device ( if it exists ) .
void TestChunker::next(QIODevice* device)
{
    device->open(QIODevice::ReadOnly);
    QByteArray array = device->readAll();
    device->close();
    if (array.size() == 0)
    {
        std::cout << "Nothing to read!" << std::endl;
        return;
    }
    WritableData writableData(0);
    try
    {
        writableData = getDataStorage(_size);
    }
    catch (const QString& e)
    {
        std::cout << "Unexpected exception: " << e.toStdString() << std::endl;
        return;
    }
    if (!writableData.isValid())
        return;
    while (!writableData.isValid()) {
        writableData = getDataStorage(_size);
        usleep(1);
    }
    writableData.write((void*)array.data(), _size, 0);
}
void TestChunker :: next ( QIODevice * device ) { device -> open ( QIODevice :: ReadOnly ) ; QByteArray array = device -> readAll ( ) ; device -> close ( ) ; if ( array . size ( ) == 0 ) { std :: cout << " " << std :: endl ; return ; } WritableData writableData ( 0 ) ; try { writableData = getDataStorage ( _size ) ; } catch ( const QString & e ) { std :: cout << " " << e . toStdString ( ) << std :: endl ; return ; } if ( ! writableData . isValid ( ) ) return ; while ( ! writableData . isValid ( ) ) { writableData = getDataStorage ( _size ) ; usleep ( 1 ) ; } writableData . write ( ( void * ) array . data ( ) , _size , 0 ) ; }
@details
 Gets the next chunk of data from the device (if it exists).
@details Gets the next chunk of data from the device ( if it exists ) .
// Read data off the device. // Get writable data object. // If the writable data object is not valid, then return. // ... or, block until writable data is valid. // Write some test data.