예제 #1
0
파일: gpu_sd.cpp 프로젝트: hernando/gpusd
static void setKeys( lunchbox::Servus& service, const GPUInfos& gpus,
                     const std::string& session, const std::string& hostname )
{
    service.set( "Session", session );
    service.set( "Hostname", hostname );

    std::ostringstream out;
    out << gpus.size();
    service.set( "GPU Count", out.str( ));

    for( GPUInfos::const_iterator i = gpus.begin(); i != gpus.end(); ++i )
    {
        const GPUInfo& info = *i;
        const size_t index = i - gpus.begin();

        // GPU<integer> Type=GLX | WGL | WGLn | CGL
        out.str("");
        out << "GPU" << index << " Type";
        service.set( out.str(), info.getName( ));

        if( info.port != GPUInfo::defaultValue )
            // GPU<integer> Port=<integer> // X11 display number, 0 otherwise
            setKey( service, index, "Port", info.port );

        if( info.device != GPUInfo::defaultValue )
            // GPU<integer> Device=<integer> // X11 display number, 0 otherwise
            setKey( service, index, "Device", info.device );

        if( info.pvp[2] > 0 && info.pvp[3] > 0 )
        {
            setKey( service, index, "X", info.pvp[0] );
            setKey( service, index, "Y", info.pvp[1] );
            setKey( service, index, "Width", info.pvp[2] );
            setKey( service, index, "Height", info.pvp[3] );
        }

        if( info.flags != 0 )
            setKey( service, index, "Flags", info.flags );
    }
}