本文整理汇总了C++中Preferences::GetInt方法的典型用法代码示例。如果您正苦于以下问题:C++ Preferences::GetInt方法的具体用法?C++ Preferences::GetInt怎么用?C++ Preferences::GetInt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Preferences
的用法示例。
在下文中一共展示了Preferences::GetInt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: preferencesFile
/**
* If we write a new networktables.ini with some sample values, test that
* we get those same values back using the Preference class.
*/
TEST(PreferencesTest, ReadPreferencesFromFile) {
NetworkTable::Shutdown();
std::remove(kFileName);
std::ofstream preferencesFile(kFileName);
preferencesFile << "[NetworkTables Storage 3.0]" << std::endl;
preferencesFile
<< "string \"/Preferences/testFileGetString\"=\"Hello, preferences file\""
<< std::endl;
preferencesFile << "double \"/Preferences/testFileGetInt\"=1" << std::endl;
preferencesFile << "double \"/Preferences/testFileGetDouble\"=0.5"
<< std::endl;
preferencesFile << "double \"/Preferences/testFileGetFloat\"=0.25"
<< std::endl;
preferencesFile << "boolean \"/Preferences/testFileGetBoolean\"=true"
<< std::endl;
preferencesFile
<< "double \"/Preferences/testFileGetLong\"=1000000000000000000"
<< std::endl;
preferencesFile.close();
NetworkTable::Initialize();
Preferences* preferences = Preferences::GetInstance();
EXPECT_EQ("Hello, preferences file",
preferences->GetString("testFileGetString"));
EXPECT_EQ(1, preferences->GetInt("testFileGetInt"));
EXPECT_FLOAT_EQ(0.5, preferences->GetDouble("testFileGetDouble"));
EXPECT_FLOAT_EQ(0.25f, preferences->GetFloat("testFileGetFloat"));
EXPECT_TRUE(preferences->GetBoolean("testFileGetBoolean"));
EXPECT_EQ(1000000000000000000ll, preferences->GetLong("testFileGetLong"));
}
示例2: Execute
void CameraTest::Execute() {
cameraLEDsSubsystem->GreenOn();
cameraLEDsSubsystem->BlueOff();
// Allow time for the LEDs to light up
if(!timer->HasPeriodPassed(0.1)) { return; } // min tested was 80ms
Preferences * prefs = Preferences::GetInstance();
// Capture an image from the camera and save it to flash
timer->Reset();
ColorImage * image;
if (prefs->GetInt("image_retain", 1) == 1) {
cameraSubsystem->RetainImage("/cameratest.jpg");
image = cameraSubsystem->CaptureImage();
cameraSubsystem->RetainImage(NULL); // stop retaining
printf("[CAMERA] Captured image and wrote to /cameratest.jpg in %.1f ms\n", timer->Get() * 1000);
} else {
image = cameraSubsystem->CaptureImage();
printf("[CAMERA] Captured image in %.1f ms\n", timer->Get() * 1000);
}
// Load preferences for filtering threshold image
Threshold threshold = Threshold(prefs->GetInt("hue_low", 100), prefs->GetInt("hue_high", 140),
prefs->GetInt("sat_low", 90), prefs->GetInt("sat_high", 255),
prefs->GetInt("lum_low", 20), prefs->GetInt("lum_high", 255));
// Process the captured image
timer->Reset();
ImageProcessor * ip = new ImageProcessor();
ip->SetThreshold(threshold);
ip->Process(image);
printf("[CAMERA] Image processed in %.1f ms\n", timer->Get() * 1000);
// Write the processed images to flash
if (prefs->GetInt("image_retain", 1) == 1) {
timer->Reset();
ip->WriteImages("/cameratest");
printf("[CAMERA] Processed images written to /cameratest.*.bmp in %.1f ms\n", timer->Get() * 1000);
}
// Generate a target report
timer->Reset();
TargetReport * tr = new TargetReport(ip->GetThresholdImage(), ip->GetFilteredImage());
tr->Generate();
printf("[CAMERA] Target report generated in %.1f ms\n", timer->Get() * 1000);
tr->OutputScores();
finished = true;
delete tr;
delete ip;
}