当前位置: 首页>>代码示例>>C++>>正文


C++ setDevice函数代码示例

本文整理汇总了C++中setDevice函数的典型用法代码示例。如果您正苦于以下问题:C++ setDevice函数的具体用法?C++ setDevice怎么用?C++ setDevice使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了setDevice函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: setDevice

void SgdUpdaterWithCpuAverager::apply() {
  // backup gpu value
  for (auto& para : parameters_) {
    SetDevice setDevice(para->getDeviceId());
    para->getBuf(PARAMETER_GRADIENT)
        ->copyFrom(*para->getBuf(PARAMETER_VALUE), kHostToDeviceStream);
  }

  // apply on cpu parameter
  if (auto callback = averager_->apply()) {
    for (auto para : cpuParameters_) {
      callback(para->getBufs(), para->getConfig(), -1LU);
    }
  }

  // copy to gpu value
  for (auto& para : parameters_) {
    SetDevice setDevice(para->getDeviceId());
    size_t pid = nonStaticParaIDMap_[para->getID()];
    Parameter* cpuPara = cpuParameters_[pid].get();
    if (parameters_[pid]->useGpu()) {
      para->getBuf(PARAMETER_VALUE)
          ->copyFrom(*cpuPara->getBuf(PARAMETER_APPLY), kHostToDeviceStream);
    }
  }
  hl_stream_synchronize(kHostToDeviceStream);
  for (auto& para : parameters_) {
    para->setValueUpdated();
  }
}
开发者ID:Biocodings,项目名称:Paddle,代码行数:30,代码来源:ParameterUpdater.cpp

示例2: KISODEBUG

void KIso::prepareDevice(const QString & filename,
                         const QString & mimetype, bool forced)
{
    KISOFUNC;
    KISODEBUG("Preparing: " << filename << " - type: " << mimetype << " - using the force: " << forced);
    /* 'hack' for Qt's false assumption that only S_ISREG is seekable */
    if ("inode/blockdevice" == mimetype)
        setDevice(new QFileHack(filename));
    else {
        if ("application/x-gzip" == mimetype
                || "application/x-bzip2" == mimetype)
            forced = true;


        KCompressionDevice *device;
        if(mimetype.isEmpty()) {
            device = new KFilterDev(filename);
        } else {
            device = new KCompressionDevice(filename, KFilterDev::compressionTypeForMimeType(mimetype));
        }
        if (device->compressionType() == KCompressionDevice::None && forced) {
            delete device;
        } else {
            setDevice(device);
        }
    }

}
开发者ID:KDE,项目名称:krusader,代码行数:28,代码来源:kiso.cpp

示例3: qDebug

void LEDControl::detectPath()
{
    qDebug() << "detectPath called";

    // get the name of this hardware from the /etc/hw-release file
    QSettings hwFile("/etc/hw-release", QSettings::IniFormat);
    QString name = hwFile.value("NAME").toString();
    qDebug() << "Name detected from /etc/hw-release is: " << name;

    // Use the name from /etc/hw-release to look up the control file location in controlfile.conf
    QSettings controlFileSettings("/usr/share/harbour-hammerhead-torch/controlfile.conf",QSettings::IniFormat);

    // Difficult to replace /usr/share/ with a variable, because QStandardPaths doesn't support an option that resolves to /usr/share/<APPNAME> yet
    //qDebug() << QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation); //QStandardPaths::AppDataLocation and QStandardPaths::AppLocalDataLocation added in Qt 5.4

    if ( controlFileSettings.contains(name) ) {
        setDevice( name );
        setPath( controlFileSettings.value(name).toString() );
    } else {
        qDebug() << "Hardware not recognised";
        setDevice("Unknown");
        setPath("Unknown");
    }

    // Use the name from /etc/hw-release to look up the brightness in brightness.conf
    QSettings brightnessSettings("/usr/share/harbour-hammerhead-torch/brightness.conf",QSettings::IniFormat);

    if ( brightnessSettings.contains(name) ) {
        setBrightness( brightnessSettings.value(name).toString() );
    } else {
        setBrightness(QString::number(1));
    }

}
开发者ID:sam-hobbs,项目名称:harbour-hammerhead-torch,代码行数:34,代码来源:ledcontrol.cpp

示例4: ConfigInfoDlg

void ConfigLabel::mousePressEvent(QMouseEvent *ev)
{
	if (QGuiApplication::mouseButtons() == Qt::RightButton)
	{
		QRect rect = this->rect();
		auto CIDlg = new ConfigInfoDlg(this, DevThr);
		int ret = CIDlg->exec();
		setDevice(Last_StoreData.DeviceType);
	}
	else if (QGuiApplication::mouseButtons() == Qt::LeftButton)
	{
		QMenu *ChooseMenu = new QMenu(this);
		QAction *Choose801Action = new QAction("TR801", this);
		QAction *Choose802Action = new QAction("TR802", this);
		QAction *Choose805Action = new QAction("TR805", this);
		connect(Choose801Action, &QAction::triggered, [&](){
			setDevice(TR801, true);
		});
		connect(Choose802Action, &QAction::triggered, [&](){
			setDevice(TR802, true);
		});
		connect(Choose805Action, &QAction::triggered, [&](){
			setDevice(TR805, true);
		});
		QFont font;
		font.setPointSize(10);
		ChooseMenu->setFont(font);
		ChooseMenu->addAction(Choose801Action);
		ChooseMenu->addAction(Choose802Action);
		ChooseMenu->addAction(Choose805Action);
		ChooseMenu->exec(QCursor::pos());
	}
}
开发者ID:chenzhengxi,项目名称:TR800-CFG,代码行数:33,代码来源:ConfigLabel.cpp

示例5: probeDevices

bool
GtkOvgGlue::init(int /*argc*/, char ** /*argv*/[])
{
    GNASH_REPORT_FUNCTION;
    
    bool egl = false;
    bool rawfb = false;
    bool dfb = false;
    bool x11 = false;
    
    // Probe to see what display devices we have that could be used.
    boost::shared_array<renderer::GnashDevice::dtype_t> devs = probeDevices();
    if (devs) {
        int i = 0;
        while (devs[i] != renderer::GnashDevice::NODEV) {
            switch (devs[i++]) {
              case renderer::GnashDevice::EGL:
                  log_debug(_("Probing found an EGL display device"));
                  egl = true;
                  break;
              case renderer::GnashDevice::RAWFB:
                  log_debug(_("Probing found a raw Framebuffer display device"));
                  rawfb = true;
                  break;
              case renderer::GnashDevice::X11:
                  log_debug(_("Probing found an X11 display device"));
                  x11 = true;
                  break;
              case renderer::GnashDevice::DIRECTFB:
                  log_debug(_("Probing found a DirectFB display device"));
                  dfb = true;
                  break;
              case renderer::GnashDevice::NODEV:
              default:
                  log_error(_("No display devices found by probing!"));
                  break;
            }
        }

        // Now that we know what exists, we have to decide which one to
        // use, as OpenVG can work with anything. We can only have one
        // display device operating at a time.
        if (egl) {
            setDevice(renderer::GnashDevice::EGL);
        } else if (rawfb) {
            setDevice(renderer::GnashDevice::RAWFB);
        } else if (dfb) {
            setDevice(renderer::GnashDevice::DIRECTFB);
        } else if (x11) {
            setDevice(renderer::GnashDevice::X11);
        }        
    }

    // Initialize the display device
    _device->initDevice(0, 0);

    return true;
}
开发者ID:BrandRegard,项目名称:gnash,代码行数:58,代码来源:gtk_glue_ovg.cpp

示例6: setDeviceWithFallback

void setDeviceWithFallback(AudioDeviceID newDeviceID, AudioDeviceID fallbackDeviceID, ASDeviceType typeRequested) {
	UInt32 propertySize = sizeof(UInt32);

	if (getCurrentlySelectedDeviceID(typeRequested) == newDeviceID) {
      setDevice(fallbackDeviceID, typeRequested);
	} else {
	  setDevice(newDeviceID, typeRequested);
	}
}
开发者ID:razum2um,项目名称:switchaudio-osx,代码行数:9,代码来源:audio_switch.c

示例7: check_ressource

void check_ressource(PCtrlBlock_t* new_running_process) {

	if (new_running_process != ptrIdleTask) {
		virtual_dev_t* virtual_dev = NULL;

		hashmap_get(pid_to_virt_dev_map, new_running_process->pid, &virtual_dev);

		if (new_running_process == foreground_process) {

			setDevice(0);
			if (virtual_dev != NULL) {
				virtual_dev->current_device_type = virtual_dev->requested_device_type;
			}

			if (foreground_changed == 1) {
				foreground_changed = 0;

				//			setBackgroundColor(BLACK);
				//			setColor(WHITE);
				//			rectangle(0,0, GLCD_RIGHT, GLCD_BOTTOM);
				//			gotoXY(0,0);
			}
		} else {
			if (virtual_dev != NULL) {
				virtual_dev->current_device_type = dev_null;
			}
			setDevice(1);
		}

	}



//
//	virtual_dev_t* virtual_dev = NULL;
//
//	hashmap_get(pid_to_virt_dev_map,new_running_process->pid, &virtual_dev);
//
////	}else{
////		while(1){}
////	}
//
//	if(new_running_process == foreground_process){
//		if(virtual_dev!= NULL){
//			virtual_dev->current_device_type = virtual_dev->requested_device_type;
//		}
//		setDevice(0);
//	}else{
//		if(virtual_dev!= NULL){
//			virtual_dev->current_device_type = dev_null;
//		}
//		setDevice(1);
//	}


}
开发者ID:mgiaco,项目名称:ehalos,代码行数:56,代码来源:resource_manager.c

示例8: setDevice

bool GeoWriter::write(QIODevice* device, const GeoNode *feature)
{
    setDevice( device );
    setAutoFormatting( true );
    writeStartDocument();

    //FIXME: write the starting tags. Possibly register a tag handler to do this
    // with a null string as the object name?
    
    GeoTagWriter::QualifiedName name( "", m_documentType );
    const GeoTagWriter* writer = GeoTagWriter::recognizes(name);
    if( writer ) {
        //FIXME is this too much of a hack?
        //geodataobject is never used in this context
        GeoNode node;
        writer->write( &node, *this );
    } else {
        mDebug() << "There is no GeoWriter registered for: " << name;
        return false;
    }
    
    if( ! writeElement( feature ) ) {
        return false;
    }
    
    //close the document
    writeEndElement();
    return true;
}
开发者ID:PayalPradhan,项目名称:marble,代码行数:29,代码来源:GeoWriter.cpp

示例9: GHOST_NDOFManager

GHOST_NDOFManagerUnix::GHOST_NDOFManagerUnix(GHOST_System& sys)
    : GHOST_NDOFManager(sys),
      m_available(false)
{
	if (spnav_open() != -1) {
		m_available = true;

		/* determine exactly which device (if any) is plugged in */

#define MAX_LINE_LENGTH 100

		/* look for USB devices with Logitech or 3Dconnexion's vendor ID */
		FILE *command_output = popen("lsusb | grep '046d:\\|256f:'", "r");
		if (command_output) {
			char line[MAX_LINE_LENGTH] = {0};
			while (fgets(line, MAX_LINE_LENGTH, command_output)) {
				unsigned short vendor_id = 0, product_id = 0;
				if (sscanf(line, "Bus %*d Device %*d: ID %hx:%hx", &vendor_id, &product_id) == 2)
					if (setDevice(vendor_id, product_id)) {
						break; /* stop looking once the first 3D mouse is found */
					}
			}
			pclose(command_output);
		}
	}
	else {
#ifdef DEBUG
		/* annoying for official builds, just adds noise and most people don't own these */
		puts("ndof: spacenavd not found");
		/* This isn't a hard error, just means the user doesn't have a 3D mouse. */
#endif
	}
}
开发者ID:DrangPo,项目名称:blender,代码行数:33,代码来源:GHOST_NDOFManagerUnix.cpp

示例10: setDevice

mUPnP::DeviceData::DeviceData()  {
  setDevice(NULL);
  setSSDPPacket(NULL);
  advertiser = NULL;
  leaseTime = Device::DEFAULT_LEASE_TIME;
  httpPort = Device::HTTP_DEFAULT_PORT;
}
开发者ID:WilliamRen,项目名称:mupnpcc,代码行数:7,代码来源:DeviceData.cpp

示例11: setDevice

bool PdmlReader::read(QIODevice *device, PcapFileFormat *pcap, bool *stop)
{
    setDevice(device);
    pcap_ = pcap;
    stop_ = stop;

    while (!atEnd())
    {
        readNext();
        if (isStartElement())
        {
            if (name() == "pdml")
                readPdml();
            else
                raiseError("Not a pdml file!");
        }
    }

    if (error() && (errorString() != "USER-CANCEL"))
    {
        qDebug("Line %lld", lineNumber());
        qDebug("Col %lld", columnNumber());
        qDebug("%s", errorString().toAscii().constData());
        return false;
    }
    return true;
}
开发者ID:anju61188,项目名称:ostinato,代码行数:27,代码来源:pdmlreader.cpp

示例12: switch

void BbAccelerometer::applyAccelerationMode()
{
    const QAccelerometer * const accelerometer = qobject_cast<QAccelerometer *>(sensor());
    if (accelerometer) {
        QString fileName;
        sensor_type_e sensorType;
        switch (accelerometer->accelerationMode()) {
        case QAccelerometer::Gravity:
            fileName = QLatin1String("/dev/sensor/gravity");
            sensorType = SENSOR_TYPE_GRAVITY;
            break;
        case QAccelerometer::User:
            fileName = QLatin1String("/dev/sensor/linAccel");
            sensorType = SENSOR_TYPE_LINEAR_ACCEL;
            break;
        default:
        case QAccelerometer::Combined:
            fileName = devicePath();
            sensorType = SENSOR_TYPE_ACCELEROMETER;
            break;
        }

        setDevice(fileName, sensorType);
    }
}
开发者ID:deztructor,项目名称:qtsensors,代码行数:25,代码来源:bbaccelerometer.cpp

示例13: setDevice

void
myGPUUnstructuredGridVolumeRayCastMapper::setArgumentsMemory (void)
{
    setDevice ();

    // Scalar
    long long scalarMemSize =
        this->Scalars->GetDataSize () * this->Scalars->GetDataTypeSize ();
    CUDA_SAFECALL (cudaMalloc ((void **) &dScalar, scalarMemSize));
    dMemUsageArgs += scalarMemSize;

    MEMCPY_H_to_D (dScalar, this->Scalars->GetVoidPointer (0), scalarMemSize);
    hBunykRayCastArg.scalar = dScalar;
    hBunykRayCastArg.scalarNumComponent =
        this->Scalars->GetNumberOfComponents ();
    hBunykRayCastArg.scalarNumOfTuples = this->Scalars->GetNumberOfTuples ();

    hBunykRayCastArg.CellScalar = this->CellScalars;

    //
    dMemAlloc < dBunykRayCastArguments > (&dBunykRayCastArg, 1, &dMemUsageArgs,
                                          deviceID);
    printf ("[GPU BunykRayCast] %.2f MB was allocated for arguments.\n",
            dMemUsageArgs / (_1M_));

    dMemUsage += dMemUsageArgs;
}
开发者ID:GibeomGu,项目名称:flow,代码行数:27,代码来源:myGPUUnstructuredGridVolumeRayCastMapper.cpp

示例14: getenv

bool SystemFile::open( void ) {
      QString Prefix = getenv( "NS2OUTPUTTO" );

      if( Prefix != "stderr" /* && Name != "interfaces" */ ) {
        // generate files where the need to be
        if( F ) {
          F->close();
          delete F;
        }

        F = new QFile( Prefix + Path + ((InAppend)?"":"bup") );
        Log(( "Open systemfile %s\n", F->name().latin1() ));
        if( ! F->open( ((InAppend)?IO_Append : 0 ) | IO_WriteOnly ) ) {
          return 0;
        }
      } else {
        if( ! F ) {
          odebug << "!!!!!!!!!!!!!!!!!! " << oendl;
          odebug << "!!!! TESTMODE !!!!" << oendl;
          odebug << "!!!!!!!!!!!!!!!!!! " << oendl;
          odebug << "!!!!" << oendl;
          odebug << "!!!! GENERATE " << Path << oendl;
          if( InAppend ) {
            odebug << "!!!! In APPEND mode" << oendl;
          }
          odebug << "!!!!" << oendl;
          odebug << "!!!!!!!!!!!!!!!!!!" << oendl;

          F = new QFile();
          F->open( IO_WriteOnly, stderr );
        }
      }
      setDevice( F );
      return 1;
}
开发者ID:opieproject,项目名称:opie,代码行数:35,代码来源:systemfile.cpp

示例15: PERF_TEST_P

PERF_TEST_P(DevInfo, StereoBeliefPropagation, testing::ValuesIn(devices()))
{
    DeviceInfo devInfo = GetParam();

    setDevice(devInfo.deviceID());

    Mat img_l_host = readImage("gpu/stereobm/aloe-L.png", CV_LOAD_IMAGE_GRAYSCALE);
    Mat img_r_host = readImage("gpu/stereobm/aloe-R.png", CV_LOAD_IMAGE_GRAYSCALE);

    ASSERT_FALSE(img_l_host.empty());
    ASSERT_FALSE(img_r_host.empty());

    GpuMat img_l(img_l_host);
    GpuMat img_r(img_r_host);

    GpuMat dst;

    StereoBeliefPropagation bp(128);

    declare.time(10.0);

    SIMPLE_TEST_CYCLE()
    {
        bp(img_l, img_r, dst);
    }

    Mat dst_host(dst);
    
    SANITY_CHECK(dst_host);
}
开发者ID:malcolmreynolds,项目名称:OpenCV,代码行数:30,代码来源:perf_calib3d.cpp


注:本文中的setDevice函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。