Esempio n. 1
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( ));
}
Esempio n. 2
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;
}
Esempio n. 3
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( ));
}
Esempio n. 4
0
    void onReply( const ::zeq::Event& event )
    {
        const auto& i = std::find( _requests.begin(), _requests.end(),
                                   event.getType( ));
        if( i == _requests.end( ))
            return;

        _requests.erase( i );
        _replySubscriber.deregisterHandler( event.getType( ));
    }
Esempio n. 5
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;
}
Esempio n. 6
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 )( ));
}
Esempio n. 7
0
void onDataSourceEvent( const zeq::Event& event, const zeq::URI& reference )
{
    BOOST_CHECK( event.getType() == livre::zeq::EVENT_DATASOURCE );
    const lunchbox::URI& deserialized =
        livre::zeq::deserializeDataSource( event );
    BOOST_CHECK_EQUAL( lexical_cast< std::string >( reference ),
                       lexical_cast< std::string >( deserialized ));
}
Esempio n. 8
0
void buildVectorOnlyBuffer(
    zeq::Event& event,
    void (Builder::*adder)( flatbuffers::Offset< flatbuffers::Vector< T >>),
    const std::vector< T >& vector)
{
    flatbuffers::FlatBufferBuilder& fbb = event.getFBB();
    Builder builder( fbb );
    (builder.*adder)( fbb.CreateVector( vector.data(), vector.size() ));
    fbb.Finish( builder.Finish( ));
}
Esempio n. 9
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;
}
Esempio n. 10
0
void onDataSourceDataEvent( const zeq::Event& event,
                            const livre::VolumeInformation& info )
{
    BOOST_CHECK( event.getType() == livre::zeq::EVENT_DATASOURCE_DATA );
    const livre::zeq::RemoteInformation& deserialized =
        livre::zeq::deserializeDataSourceData( event );
    const livre::VolumeInformation& info2 = deserialized.second;

    BOOST_CHECK_EQUAL( deserialized.first, zeq::uint128_t( 17, 42 ));
    BOOST_CHECK_EQUAL( info.compCount, info2.compCount );
    BOOST_CHECK_EQUAL( info.rootNode.getDepth(), info2.rootNode.getDepth( ));
    BOOST_CHECK_EQUAL( info.overlap, info2.overlap );
    BOOST_CHECK_EQUAL( info.maximumBlockSize, info2.maximumBlockSize );
    BOOST_CHECK_EQUAL( info.minPos, info2.minPos );
    BOOST_CHECK_EQUAL( info.maxPos, info2.maxPos );
    BOOST_CHECK_EQUAL( info.worldSize, info2.worldSize );
    BOOST_CHECK_EQUAL( info.voxels, info2.voxels );
    BOOST_CHECK_EQUAL( info.worldSpacePerVoxel, info2.worldSpacePerVoxel );
}
Esempio n. 11
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;
    }
Esempio n. 12
0
LODNodeSampleData deserializeDataSampleData( const ::zeq::Event& event )
{
    auto data = GetMemory( event.getData( ))->data();
    return std::make_pair( data->Data(), data->size( ));
}
Esempio n. 13
0
void onLargeEcho( const zeq::Event& event )
{
    BOOST_CHECK( event.getType() == zeq::vocabulary::EVENT_ECHO );
}
Esempio n. 14
0
data::ImageJPEG deserializeImageJPEG( const ::zeq::Event& event )
{
    auto data = GetImageJPEG( event.getData( ) );
    return data::ImageJPEG( data->data()->size(), data->data()->Data( ));
}