Exemplo n.º 1
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( ));
    }
Exemplo 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;
}
Exemplo n.º 3
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( ));
}
Exemplo 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( ));
}
Exemplo n.º 5
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 ));
}
Exemplo 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;
}
Exemplo 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;
    }
Exemplo n.º 8
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 );
}
Exemplo n.º 9
0
void onLargeEcho( const zeq::Event& event )
{
    BOOST_CHECK( event.getType() == zeq::vocabulary::EVENT_ECHO );
}