Ejemplo n.º 1
0
RemoteInformation deserializeDataSourceData( const ::zeq::Event& event )
{
    if( event.getType() != EVENT_DATASOURCE_DATA )
        return RemoteInformation();

    auto data = GetVolumeInformation( event.getData( ));
    RemoteInformation info;
    livre::VolumeInformation& vi = info.second;

    info.first.low() = data->eventLow();
    info.first.high() = data->eventHigh();
    vi.isBigEndian = data->isBigEndian();
    vi.compCount = data->compCount();
    vi.dataType = DataType( data->dataType( ));
    vi.overlap = _deserializeVector3< unsigned >( data->overlap( ));
    vi.maximumBlockSize = _deserializeVector3< unsigned >(
                                 data->maximumBlockSize( ));
    vi.minPos = _deserializeVector3< float >( data->minPos( ));
    vi.maxPos = _deserializeVector3< float >( data->maxPos( ));
    vi.voxels = _deserializeVector3< unsigned >( data->voxels( ));
    vi.worldSize = _deserializeVector3< float >( data->worldSize( ));
    vi.boundingBox.getMin() = _deserializeVector3< float >(
                                     data->boundingBoxMin( ));
    vi.boundingBox.getMax() = _deserializeVector3< float >(
                                     data->boundingBoxMax( ));
    vi.worldSpacePerVoxel = data->worldSpacePerVoxel();

    const Vector3ui& blockSize = vi.maximumBlockSize - vi.overlap * 2;
    Vector3ui blocksSize = vi.voxels / blockSize;
    blocksSize = blocksSize / ( 1u << data->depth( ));

    vi.rootNode = RootNode( data->depth(), blocksSize );
    return info;
}
Ejemplo n.º 2
0
std::string deserializeString( const ::zeq::Event& event )
{
    BOOST_CHECK_EQUAL( event.getType(), EVENT_NEWEVENT );

    auto data = GetNewEvent( event.getData( ));
    return std::string( data->message()->c_str( ));
}
Ejemplo n.º 3
0
std::vector< T > deserializeVector(
    const zeq::Event& event,
    const flatbuffers::Vector< T >* (U::*getter)( ) const )
{
    auto data = flatbuffers::GetRoot< U >( event.getData( ));
    return deserializeVector(( data->*getter )( ));
}
Ejemplo n.º 4
0
lunchbox::URI deserializeDataSource( const ::zeq::Event& event )
{
    if( event.getType() != EVENT_DATASOURCE )
        return lunchbox::URI();

    auto data = GetURI( event.getData( ));
    return lunchbox::URI( data->uri()->c_str( ));
}
Ejemplo n.º 5
0
SpikeMap deserializeSpikes( const zeq::Event& event )
{
    auto data = GetSpikes( event.getData( ));
    SpikeMap spikes;
    for( flatbuffers::uoffset_t i = 0; i < data->spikes()->Length(); ++i )
    {
        const Spike* spike = data->spikes()->Get( i );
        spikes.insert( std::make_pair( spike->time(), spike->cell( )));
    }
    return spikes;
}
Ejemplo n.º 6
0
LODNodeSample deserializeDataSample( const ::zeq::Event& event )
{
    LODNodeSample sample;
    sample.first = event.getType();

    auto data = GetLODNode( event.getData( ));
    sample.second = livre::LODNode(
        NodeId( data->nodeId( )),
        _deserializeVector3< int32_t >( data->blockSize( )),
        Boxf( _deserializeVector3< float >( data->worldBoxMin( )),
              _deserializeVector3< float >( data->worldBoxMax( ))));

    return sample;
}
Ejemplo n.º 7
0
    bool publish( const zeq::Event& event )
    {
#ifdef COMMON_LITTLEENDIAN
        const uint128_t& type = event.getType();
#else
        uint128_t type = event.getType();
        detail::byteswap( type ); // convert to little endian wire protocol
#endif
        zmq_msg_t msgHeader;
        zmq_msg_init_size( &msgHeader, sizeof( type ));
        memcpy( zmq_msg_data( &msgHeader ), &type, sizeof( type ));
        int ret = zmq_msg_send( &msgHeader, socket,
                                event.getSize() > 0 ? ZMQ_SNDMORE : 0 );
        zmq_msg_close( &msgHeader );
        if( ret == -1 )
        {
            ZEQWARN << "Cannot publish message header, got "
                   << zmq_strerror( zmq_errno( )) << std::endl;
            return false;
        }

        if( event.getSize() == 0 )
            return true;

        zmq_msg_t msg;
        zmq_msg_init_size( &msg, event.getSize( ));
        memcpy( zmq_msg_data(&msg), event.getData(), event.getSize( ));
        ret = zmq_msg_send( &msg, socket, 0 );
        zmq_msg_close( &msg );
        if( ret  == -1 )
        {
            ZEQWARN << "Cannot publish message data, got "
                    << zmq_strerror( zmq_errno( )) << std::endl;
            return false;
        }
        return true;
    }
Ejemplo n.º 8
0
LODNodeSampleData deserializeDataSampleData( const ::zeq::Event& event )
{
    auto data = GetMemory( event.getData( ))->data();
    return std::make_pair( data->Data(), data->size( ));
}
Ejemplo n.º 9
0
data::ImageJPEG deserializeImageJPEG( const ::zeq::Event& event )
{
    auto data = GetImageJPEG( event.getData( ) );
    return data::ImageJPEG( data->data()->size(), data->data()->Data( ));
}