本文整理汇总了C++中Driver类的典型用法代码示例。如果您正苦于以下问题:C++ Driver类的具体用法?C++ Driver怎么用?C++ Driver使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Driver类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseCoverageFeatures
int parseCoverageFeatures(const Driver &D, const llvm::opt::Arg *A) {
assert(A->getOption().matches(options::OPT_fsanitize_coverage) ||
A->getOption().matches(options::OPT_fno_sanitize_coverage));
int Features = 0;
for (int i = 0, n = A->getNumValues(); i != n; ++i) {
const char *Value = A->getValue(i);
int F = llvm::StringSwitch<int>(Value)
.Case("func", CoverageFunc)
.Case("bb", CoverageBB)
.Case("edge", CoverageEdge)
.Case("indirect-calls", CoverageIndirCall)
.Case("trace-bb", CoverageTraceBB)
.Case("trace-cmp", CoverageTraceCmp)
.Case("8bit-counters", Coverage8bitCounters)
.Default(0);
if (F == 0)
D.Diag(clang::diag::err_drv_unsupported_option_argument)
<< A->getOption().getName() << Value;
Features |= F;
}
return Features;
}
示例2: common_rx_partial_packets
void common_rx_partial_packets(Driver& test, int tx)
{
uint8_t buffer[100];
uint8_t msg[4] = { 0, 'a', 'b', 0 };
writeToDriver(test, tx, msg, 2);
BOOST_REQUIRE_THROW(test.readPacket(buffer, 100, 10), TimeoutError);
writeToDriver(test, tx, msg + 2, 2);
BOOST_REQUIRE_EQUAL(4, test.readPacket(buffer, 100, 10));
BOOST_REQUIRE_EQUAL(0, test.getStats().tx);
BOOST_REQUIRE_EQUAL(4, test.getStats().good_rx);
BOOST_REQUIRE_EQUAL(0, test.getStats().bad_rx);
BOOST_REQUIRE( !memcmp(msg, buffer, 4) );
writeToDriver(test, tx, msg, 4);
BOOST_REQUIRE_EQUAL(4, test.readPacket(buffer, 100, 10));
BOOST_REQUIRE_EQUAL(0, test.getStats().tx);
BOOST_REQUIRE_EQUAL(8, test.getStats().good_rx);
BOOST_REQUIRE_EQUAL(0, test.getStats().bad_rx);
BOOST_REQUIRE( !memcmp(msg, buffer, 4) );
}
示例3: testArbolConVariasCategorias
void testArbolConVariasCategorias() {
Driver d;
/**
* cat1
* |- cat2
* \- cat3
* \- cat4
*/
d.nuevoArbol("cat1");
d.agregarCategoria("cat1","cat2");
d.agregarCategoria("cat1","cat3");
d.agregarCategoria("cat3","cat4");
ASSERT_EQ(d.cantCategoriasHijas("cat1"), 2);
ASSERT_EQ(d.cantCategoriasHijas("cat2"), 0);
ASSERT_EQ(d.cantCategoriasHijas("cat3"), 1);
}
示例4: parseDirectory
void parseDirectory( Driver& driver, QDir& dir, bool rec, bool parseAllFiles )
{
QStringList fileList;
if ( parseAllFiles )
fileList = dir.entryList( QDir::Files );
else
fileList = dir.entryList( "*.h;*.H;*.hh;*.hxx;*.hpp;*.tlh" );
QStringList::Iterator it = fileList.begin();
while ( it != fileList.end() )
{
QString fn = dir.path() + "/" + ( *it );
++it;
driver.parseFile( fn );
}
if ( rec )
{
QStringList fileList = dir.entryList( QDir::Dirs );
QStringList::Iterator it = fileList.begin();
while ( it != fileList.end() )
{
if ( ( *it ).startsWith( "." ) )
{
++it;
continue;
}
QDir subdir( dir.path() + "/" + ( *it ) );
++it;
parseDirectory( driver, subdir, rec, parseAllFiles );
}
}
}
示例5: test_mover_estudiante_fuera
void test_mover_estudiante_fuera() {
Driver campus;
campus.crearCampus(10,10);
Dicc<Agente,aed2::Posicion> agentes;
campus.comenzarRastrillaje(agentes);
aed2::Posicion p2;
p2.x = 1;
p2.y = 1;
Nombre s = "pepe";
campus.ingresarEstudiante(s,p2);
campus.moverEstudiante(s, arriba);
ASSERT(campus.cantEstudiantes() == 0);
}
示例6: commandHandler
void commandHandler(const lcm::ReceiveBuffer* iBuf,
const std::string& iChannel,
const multisense::command_t* iMessage) {
std::cout << "command message received" << std::endl;
std::cout << " fps: " << iMessage->fps << std::endl;
std::cout << " gain: " << iMessage->gain << std::endl;
std::cout << " auto exposure: " <<
(iMessage->agc ? "true" : "false") << std::endl;
std::cout << " exposure: " << iMessage->exposure_us << " us" << std::endl;
std::cout << " led flash: " <<
(iMessage->leds_flash ? "true" : "false") << std::endl;
std::cout << " led duty cycle: " << iMessage->leds_duty_cycle << std::endl;
mLaser->setSpindleSpeed(iMessage->rpm);
if (iMessage->fps > 0) mCamera->setFrameRate(iMessage->fps);
if (iMessage->gain > 0) mCamera->setGainFactor(iMessage->gain);
if (iMessage->agc == 0) mCamera->setAutoExposure(false);
if ((iMessage->exposure_us > 0) && (iMessage->agc <= 0)) {
mCamera->setExposureTime(iMessage->exposure_us);
}
if (iMessage->agc > 0) mCamera->setAutoExposure(true);
if ((iMessage->leds_flash >= 0) || (iMessage->leds_duty_cycle >= 0)) {
mDriver->setLedState(iMessage->leds_flash>0, iMessage->leds_duty_cycle);
}
}
示例7: test_mover_estudiante
void test_mover_estudiante() {
Driver campus;
campus.crearCampus(10,10);
Dicc<Agente,aed2::Posicion> agentes;
campus.comenzarRastrillaje(agentes);
aed2::Posicion p2;
p2.x = 1;
p2.y = 1;
Nombre s = "pepe";
campus.ingresarEstudiante(s,p2);
campus.moverEstudiante(s, abajo);
aed2::Posicion p3;
p3.x = 1;
p3.y = 2;
aed2::Posicion p = campus.posEstudianteYHippie(s);
ASSERT(p3.x == p.x && p3.y == p.y);
}
示例8: test_agregar_obstaculos
/**
* Ejemplo de caso de test, con llamadas a las rutinas de aserción
* definidas en mini_test.h
*/
void test_agregar_obstaculos() {
Driver campus;
campus.crearCampus(10,10);
Dicc<Agente,aed2::Posicion> agentes;
campus.comenzarRastrillaje(agentes);
aed2::Posicion p;
p.x = 2;
p.y = 3;
campus.agregarObstaculo(p);
ASSERT(campus.ocupada(p) == true);
aed2::Posicion p2;
p2.x = 1;
p2.y = 1;
ASSERT(campus.ocupada(p2) == false);
}
示例9: driverFactory
Driver* driverFactory(Seq* seq, QString driverName)
{
Driver* driver = 0;
#if 1 // DEBUG: force "no audio"
bool useJackFlag = (preferences.useJackAudio || preferences.useJackMidi);
bool useAlsaFlag = preferences.useAlsaAudio;
bool usePortaudioFlag = preferences.usePortaudioAudio;
bool usePulseAudioFlag = preferences.usePulseAudio;
if (!driverName.isEmpty()) {
driverName = driverName.toLower();
useJackFlag = false;
useAlsaFlag = false;
usePortaudioFlag = false;
usePulseAudioFlag = false;
if (driverName == "jack")
useJackFlag = true;
else if (driverName == "alsa")
useAlsaFlag = true;
else if (driverName == "pulse")
usePulseAudioFlag = true;
else if (driverName == "portaudio")
usePortaudioFlag = true;
}
useALSA = false;
useJACK = false;
usePortaudio = false;
usePulseAudio = false;
#ifdef USE_PULSEAUDIO
if (usePulseAudioFlag) {
driver = getPulseAudioDriver(seq);
if (!driver->init()) {
qDebug("init PulseAudio failed");
delete driver;
driver = 0;
}
else
usePulseAudio = true;
}
#else
(void)usePulseAudioFlag; // avoid compiler warning
#endif
#ifdef USE_PORTAUDIO
if (usePortaudioFlag) {
driver = new Portaudio(seq);
if (!driver->init()) {
qDebug("init PortAudio failed");
delete driver;
driver = 0;
}
else
usePortaudio = true;
}
#else
(void)usePortaudioFlag; // avoid compiler warning
#endif
#ifdef USE_ALSA
if (driver == 0 && useAlsaFlag) {
driver = new AlsaAudio(seq);
if (!driver->init()) {
qDebug("init ALSA driver failed\n");
delete driver;
driver = 0;
}
else {
useALSA = true;
}
}
#else
(void)useAlsaFlag; // avoid compiler warning
#endif
#ifdef USE_JACK
if (useJackFlag) {
useAlsaFlag = false;
usePortaudioFlag = false;
driver = new JackAudio(seq);
if (!driver->init()) {
qDebug("no JACK server found\n");
delete driver;
driver = 0;
}
else
useJACK = true;
}
#else
(void)useJackFlag; // avoid compiler warning
#endif
#endif
if (driver == 0)
qDebug("no audio driver found");
return driver;
}
示例10: AssociationCommandVec
//-----------------------------------------------------------------------------
// <Group::OnGroupChanged>
// Change the group contents and notify the watchers
//-----------------------------------------------------------------------------
void Group::OnGroupChanged
(
vector<InstanceAssociation> const& _associations
)
{
bool notify = false;
// If the number of associations is different, we'll save
// ourselves some work and clear the old set now.
if( _associations.size() != m_associations.size() )
{
m_associations.clear();
notify = true;
}
else
{
// Handle initial group creation case
if ( _associations.size() == 0 && m_associations.size() == 0 )
{
notify = true;
}
}
// Add the new associations.
uint8 oldSize = (uint8)m_associations.size();
uint8 i;
for( i=0; i<_associations.size(); ++i )
{
m_associations[_associations[i]] = AssociationCommandVec();
}
if( (!notify) && ( oldSize != m_associations.size() ) )
{
// The number of nodes in the original and new groups is the same, but
// the number of associations has grown. There must be different nodes
// in the original and new sets of nodes in the group. The easiest way
// to sort this out is to clear the associations and add the new nodes again.
m_associations.clear();
for( i=0; i<_associations.size(); ++i )
{
m_associations[_associations[i]] = AssociationCommandVec();
}
notify = true;
}
if( notify )
{
// If the node supports COMMAND_CLASS_ASSOCIATION_COMMAND_CONFIGURATION, we need to request the command data.
if( Driver* driver = Manager::Get()->GetDriver( m_homeId ) )
{
if( Node* node = driver->GetNodeUnsafe( m_nodeId ) )
{
if( AssociationCommandConfiguration* cc = static_cast<AssociationCommandConfiguration*>( node->GetCommandClass( AssociationCommandConfiguration::StaticGetCommandClassId() ) ) )
{
for( map<InstanceAssociation,AssociationCommandVec,classcomp>::iterator it = m_associations.begin(); it != m_associations.end(); ++it )
{
cc->RequestCommands( m_groupIdx, it->first.m_nodeId );
}
}
}
}
// Send notification that the group contents have changed
Notification* notification = new Notification( Notification::Type_Group );
notification->SetHomeAndNodeIds( m_homeId, m_nodeId );
notification->SetGroupIdx( m_groupIdx );
Manager::Get()->GetDriver( m_homeId )->QueueNotification( notification );
// Update routes on remote node if necessary
bool update = false;
Options::Get()->GetOptionAsBool( "PerformReturnRoutes", &update );
if( update )
{
Driver *drv = Manager::Get()->GetDriver( m_homeId );
if (drv)
drv->UpdateNodeRoutes( m_nodeId );
}
}
}
示例11: test_mueve_estudiante_y_convierte
// DIFICIL
void test_mueve_estudiante_y_convierte() {
// Testea que cuando se mueve un estudiante y rodea a un hippie se convierte
Driver campus;
campus.crearCampus(10,10);
Dicc<Agente,aed2::Posicion> agentes;
campus.comenzarRastrillaje(agentes);
aed2::Posicion p1;
p1.x = 1;
p1.y = 1;
aed2::Posicion p2;
p2.x = 2;
p2.y = 1;
aed2::Posicion p3;
p3.x = 3;
p3.y = 1;
Nombre s1 = "pepe";
Nombre s2 = "pepo";
Nombre s3 = "pepa";
// Ingreso 3 estudiantes uno al lado del otro
campus.ingresarEstudiante(s1,p1);
campus.ingresarEstudiante(s2,p2);
campus.ingresarEstudiante(s3,p3);
// Avanzo el estudiante del medio
campus.moverEstudiante(s2,abajo);
campus.moverEstudiante(s2,abajo);
// Ahora hago ingresar un hippie Y NO SE TIENE QUE CONVERTIR
Nombre h1 = "wololoHippie";
campus.ingresarHippie(h1,p2);
ASSERT(campus.cantEstudiantes() == 3);
ASSERT(campus.cantHippies() == 1);
// Muevo el estudiante hacia arriba y tiene que convertir talannnn
campus.moverEstudiante(s2,arriba);
ASSERT(campus.cantEstudiantes() == 4);
ASSERT(campus.cantHippies() == 0);
}
示例12: main
int main()
{
Driver driver;
driver.run();
}
示例13: main
int main(int argc, char * argv[])
{
std::cout << "\n Intel(r) Performance Counter Monitor " << INTEL_PCM_VERSION << std::endl;
std::cout << "\n Power Monitoring Utility\n Copyright (c) 2011-2012 Intel Corporation\n";
int imc_profile = 0;
int pcu_profile = 0;
int delay = -1;
char * ext_program = NULL;
freq_band[0] = default_freq_band[0];
freq_band[1] = default_freq_band[1];
freq_band[2] = default_freq_band[2];
int my_opt = -1;
while ((my_opt = getopt(argc, argv, "m:p:a:b:c:")) != -1)
{
switch(my_opt)
{
case 'm':
imc_profile = atoi(optarg);
break;
case 'p':
pcu_profile = atoi(optarg);
break;
case 'a':
freq_band[0] = atoi(optarg);
break;
case 'b':
freq_band[1] = atoi(optarg);
break;
case 'c':
freq_band[2] = atoi(optarg);
break;
default:
print_usage(argv[0]);
return -1;
}
}
if (optind >= argc)
{
print_usage(argv[0]);
return -1;
}
delay = atoi(argv[optind]);
if(delay == 0)
ext_program = argv[optind];
else
delay = (delay<0)?1:delay;
#ifdef _MSC_VER
// Increase the priority a bit to improve context switching delays on Windows
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL);
TCHAR driverPath[1024];
GetCurrentDirectory(1024, driverPath);
wcscat(driverPath, L"\\msr.sys");
// WARNING: This driver code (msr.sys) is only for testing purposes, not for production use
Driver drv;
// drv.stop(); // restart driver (usually not needed)
if (!drv.start(driverPath))
{
std::cout << "Can not access CPU performance counters" << std::endl;
std::cout << "You must have signed msr.sys driver in your current directory and have administrator rights to run this program" << std::endl;
return -1;
}
#endif
PCM * m = PCM::getInstance();
m->disableJKTWorkaround();
if(!(m->hasPCICFGUncore()))
{
std::cout <<"Unsupported processor model ("<<m->getCPUModel()<<"). Only models "<<PCM::JAKETOWN<<" (JAKETOWN), " << PCM::IVYTOWN<< " (IVYTOWN) are supported."<< std::endl;
return -1;
}
if(PCM::Success != m->programServerUncorePowerMetrics(imc_profile,pcu_profile,freq_band))
{
#ifdef _MSC_VER
std::cout << "You must have signed msr.sys driver in your current directory and have administrator rights to run this program" << std::endl;
#elif defined(__linux__)
std::cout << "You need to be root and loaded 'msr' Linux kernel module to execute the program. You may load the 'msr' module with 'modprobe msr'. \n";
#endif
return -1;
}
ServerUncorePowerState * BeforeState = new ServerUncorePowerState[m->getNumSockets()];
ServerUncorePowerState * AfterState = new ServerUncorePowerState[m->getNumSockets()];
uint64 BeforeTime = 0, AfterTime = 0;
std::cout << std::dec << std::endl;
std::cout.precision(2);
std::cout << std::fixed;
std::cout << "\nMC counter group: "<<imc_profile << std::endl;
std::cout << "PCU counter group: "<<pcu_profile << std::endl;
if(pcu_profile == 0)
//.........这里部分代码省略.........
示例14: Distro
Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
: Generic_ELF(D, Triple, Args) {
GCCInstallation.init(Triple, Args);
Multilibs = GCCInstallation.getMultilibs();
llvm::Triple::ArchType Arch = Triple.getArch();
std::string SysRoot = computeSysRoot();
// Cross-compiling binutils and GCC installations (vanilla and openSUSE at
// least) put various tools in a triple-prefixed directory off of the parent
// of the GCC installation. We use the GCC triple here to ensure that we end
// up with tools that support the same amount of cross compiling as the
// detected GCC installation. For example, if we find a GCC installation
// targeting x86_64, but it is a bi-arch GCC installation, it can also be
// used to target i386.
// FIXME: This seems unlikely to be Linux-specific.
ToolChain::path_list &PPaths = getProgramPaths();
PPaths.push_back(Twine(GCCInstallation.getParentLibPath() + "/../" +
GCCInstallation.getTriple().str() + "/bin")
.str());
Distro Distro(D.getVFS());
if (Distro.IsOpenSUSE() || Distro.IsUbuntu()) {
ExtraOpts.push_back("-z");
ExtraOpts.push_back("relro");
}
if (Arch == llvm::Triple::arm || Arch == llvm::Triple::thumb)
ExtraOpts.push_back("-X");
const bool IsAndroid = Triple.isAndroid();
const bool IsMips = tools::isMipsArch(Arch);
const bool IsHexagon = Arch == llvm::Triple::hexagon;
if (IsMips && !SysRoot.empty())
ExtraOpts.push_back("--sysroot=" + SysRoot);
// Do not use 'gnu' hash style for Mips targets because .gnu.hash
// and the MIPS ABI require .dynsym to be sorted in different ways.
// .gnu.hash needs symbols to be grouped by hash code whereas the MIPS
// ABI requires a mapping between the GOT and the symbol table.
// Android loader does not support .gnu.hash.
// Hexagon linker/loader does not support .gnu.hash
if (!IsMips && !IsAndroid && !IsHexagon) {
if (Distro.IsRedhat() || Distro.IsOpenSUSE() ||
(Distro.IsUbuntu() && Distro >= Distro::UbuntuMaverick))
ExtraOpts.push_back("--hash-style=gnu");
if (Distro.IsDebian() || Distro.IsOpenSUSE() || Distro == Distro::UbuntuLucid ||
Distro == Distro::UbuntuJaunty || Distro == Distro::UbuntuKarmic)
ExtraOpts.push_back("--hash-style=both");
}
if (Distro.IsRedhat() && Distro != Distro::RHEL5 && Distro != Distro::RHEL6)
ExtraOpts.push_back("--no-add-needed");
#ifdef ENABLE_LINKER_BUILD_ID
ExtraOpts.push_back("--build-id");
#endif
if (Distro.IsOpenSUSE())
ExtraOpts.push_back("--enable-new-dtags");
// The selection of paths to try here is designed to match the patterns which
// the GCC driver itself uses, as this is part of the GCC-compatible driver.
// This was determined by running GCC in a fake filesystem, creating all
// possible permutations of these directories, and seeing which ones it added
// to the link paths.
path_list &Paths = getFilePaths();
const std::string OSLibDir = getOSLibDir(Triple, Args);
const std::string MultiarchTriple = getMultiarchTriple(D, Triple, SysRoot);
// Add the multilib suffixed paths where they are available.
if (GCCInstallation.isValid()) {
const llvm::Triple &GCCTriple = GCCInstallation.getTriple();
const std::string &LibPath = GCCInstallation.getParentLibPath();
const Multilib &Multilib = GCCInstallation.getMultilib();
const MultilibSet &Multilibs = GCCInstallation.getMultilibs();
// Add toolchain / multilib specific file paths.
addMultilibsFilePaths(D, Multilibs, Multilib,
GCCInstallation.getInstallPath(), Paths);
// Sourcery CodeBench MIPS toolchain holds some libraries under
// a biarch-like suffix of the GCC installation.
addPathIfExists(D, GCCInstallation.getInstallPath() + Multilib.gccSuffix(),
Paths);
// GCC cross compiling toolchains will install target libraries which ship
// as part of the toolchain under <prefix>/<triple>/<libdir> rather than as
// any part of the GCC installation in
// <prefix>/<libdir>/gcc/<triple>/<version>. This decision is somewhat
// debatable, but is the reality today. We need to search this tree even
// when we have a sysroot somewhere else. It is the responsibility of
// whomever is doing the cross build targeting a sysroot using a GCC
// installation that is *not* within the system root to ensure two things:
//
// 1) Any DSOs that are linked in from this tree or from the install path
// above must be present on the system root and found via an
//.........这里部分代码省略.........
示例15: IT_IT
void UnitCfg::QueryResponse (QObject *p, const QString &c, int State, QObject*caller) // notify transaction completerequestrt needs the name record addedivityLled int2);, tion text,repprint int2);ate text);
{
if(p != this) return;
IT_IT("UnitCfg::QueryResponse");
switch (State)
{
case tList:
{
// fill the name list box
GetConfigureDb ()->FillComboBox (Name, "NAME");
Name->setCurrentItem (0);
SelChanged (0);
Name->setFocus ();
ButtonState (true);
};
break;
case tItem:
{
IT_COMMENT("Received User Data");
// fill the fields
Comment->setText (UndoEscapeSQLText(GetConfigureDb()->GetString ("COMMENT")));
SetComboItem (UnitType, GetConfigureDb ()->GetString ("UNITTYPE"));
Enabled->setChecked (GetConfigureDb ()->GetString ("ENABLED").toInt ());
Comment->setFocus ();
ButtonState (true);
};
break;
case tDrop:
{
int n = GetConfigureDb()->GetNumberResults();
QStringList list;
QString point_list = "(";
if (n)
{
for(int i = 0; i < n; i++,GetConfigureDb()->FetchNext())
{
if(i)
{
point_list += ",";
};
point_list += "'" + GetConfigureDb()->GetString("NAME") + "'";
//
list << GetConfigureDb()->GetString ("NAME");
};
point_list += ");";
}
QString cmd ="delete from TAGS_DB where NAME in " + point_list;
GetCurrentDb ()->DoExec (0,cmd,0);
//
cmd ="delete from CVAL_DB where NAME in " + point_list;
GetCurrentDb ()->DoExec (0,cmd,0);
if(!list.isEmpty())
{
QStringList::Iterator it = list.begin();
for(;it != list.end();++it)
{
QString cmd = "drop table "+ (*it) + ";";
GetResultDb()->DoExec(0,cmd,0);
}
}
//TO DO APA caricare tutti i Driver *p in un dizionario come fa il monitor
//e poi usarli quando e' necessario
Driver * p = FindDriver(UnitType->currentText());
if(p)
{
DOAUDIT(tr("Drop Unit Tables:") + Name->currentText());
p->DropAllSpecTables(list); // invoked the unit level drop tables
}
}
break;
case tNew:
case tDelete:
case tApply:
ButtonState (true);
default:
break;
};
};