bool getOSVersion() { bool valid = false; const char *val; int len; config_file_t systemVersion; if (!loadConfigFile("System/Library/CoreServices/SystemVersion.plist", &systemVersion)) { valid = true; } else if (!loadConfigFile("System/Library/CoreServices/ServerVersion.plist", &systemVersion)) { valid = true; } if (valid) { if (getValueForKey(kProductVersion, &val, &len, &systemVersion)) { // getValueForKey uses const char for val // so copy it and trim *gMacOSVersion = '\0'; strncat(gMacOSVersion, val, MIN(len, 4)); } else valid = false; } return valid; }
inline struct SMBEntryPoint * getSmbios() { const char *smbios_filename; char dirSpec[512]; int len; struct SMBEntryPoint *orig_address; struct SMBEntryPoint *new_address; orig_address=getAddressOfSmbiosTable(); if (!getValueForKey("SMBIOS", &smbios_filename, &len, &bootInfo->bootConfig)) smbios_filename = "smbios.plist"; sprintf(dirSpec, "%s", smbios_filename); if (loadConfigFile(dirSpec, &bootInfo->smbiosConfig) == -1) { sprintf(dirSpec, "/Extra/%s", smbios_filename); if (loadConfigFile(dirSpec, &bootInfo->smbiosConfig) == -1) { sprintf(dirSpec, "bt(0,0)/Extra/%s", smbios_filename); if (loadConfigFile(dirSpec, &bootInfo->smbiosConfig) == -1) { verbose("No SMBIOS replacement found.\n"); } } } // if( (loadConfigFile("/Extra/smbios.plist", &bootInfo->smbiosConfig)) == -1 ) // loadConfigFile("bt(0,0)/Extra/smbios.plist", &bootInfo->smbiosConfig); // TODO: do we need this ? new_address = smbios_dry_run(orig_address); smbios_real_run(orig_address, new_address); return new_address; }
void TrackerConfig::load() { // Give precedence to local configuration string sFName = "avgtrackerrc"; if (fileExists(sFName) || !fileExists(getGlobalConfigDir() + sFName)) { loadConfigFile(sFName); } else { loadConfigFile(getGlobalConfigDir() + sFName); } }
string FabAtHomePrinter::initialize(const string& filePath) { if(!initialized) { string result = loadConfigFile(filePath); if(result.compare("") != 0) { return result; } //Connect to printer. stringstream ss; ss << "COM" << COM_PORT; unsigned int numModulesFound = NmcInit(const_cast<char*>(ss.str().c_str()), BAUD_RATE); if(numModulesFound < NUM_MODULES) { ss.str(""); ss << "Found " << numModulesFound << " modules but need " << NUM_MODULES << " modules."; return ss.str(); } //Initialize all motors. for(map<string,Motor,LessThanString>::iterator i = motors.begin(); i != motors.end(); ++i) { string result = i->second.initialize(); Util::assertTrue(result.compare("") == 0,result,__LINE__,__FILE__); } initialized = true; } return ""; }
GameEngine::GameEngine() { DEngine = 0; controlArray = new int[FCEnum::ARRAY_SIZE]; loadConfigFile(); }
void ConfigManager::loadDefaultConfigFile() { char configFile[MAXPATHLEN]; #if defined(UNIX) #if defined (IPOD) strcpy(configFile, DEFAULT_CONFIG_FILE); #else const char *home = getenv("HOME"); if (home != NULL && strlen(home) < MAXPATHLEN) snprintf(configFile, MAXPATHLEN, "%s/%s", home, DEFAULT_CONFIG_FILE); else strcpy(configFile, DEFAULT_CONFIG_FILE); #endif #else #if defined (WIN32) && !defined(_WIN32_WCE) && !defined(__SYMBIAN32__) GetWindowsDirectory(configFile, MAXPATHLEN); strcat(configFile, "\\" DEFAULT_CONFIG_FILE); #elif defined(PALMOS_MODE) strcpy(configFile,"/PALM/Programs/ScummVM/" DEFAULT_CONFIG_FILE); #elif defined(__PLAYSTATION2__) ((OSystem_PS2*)g_system)->makeConfigPath(configFile); #elif defined(__PSP__) strcpy(configFile, "ms0:/" DEFAULT_CONFIG_FILE); #elif defined (__SYMBIAN32__) strcpy(configFile, Symbian::GetExecutablePath()); strcat(configFile, DEFAULT_CONFIG_FILE); #else strcpy(configFile, DEFAULT_CONFIG_FILE); #endif #endif loadConfigFile(configFile); flushToDisk(); }
// ----------------------------------------------------------------------------- // // Purpose and Method: // Inputs: // Outputs: // Dependencies: // Restrictions and Caveats: // // ----------------------------------------------------------------------------- int main ( int argc, char **argv ) { // Evaluate head pose std::string ffd_config_file = "data/config_ffd.txt"; std::string headpose_config_file = "data/config_headpose.txt"; std::string face_cascade = "data/haarcascade_frontalface_alt.xml"; // Parse configuration files ForestParam hp_param, mp_param; if (!loadConfigFile(headpose_config_file, hp_param)) return EXIT_FAILURE; if (!loadConfigFile(ffd_config_file, mp_param)) return EXIT_FAILURE; // Loading images annotations std::vector<FaceAnnotation> annotations; if (!loadAnnotations(hp_param.image_path, annotations)) return EXIT_FAILURE; // Separate annotations by head-pose classes std::vector< std::vector<FaceAnnotation> > ann(NUM_HEADPOSE_CLASSES); for (unsigned int i=0; i < annotations.size(); i++) ann[annotations[i].pose+2].push_back(annotations[i]); // Evaluate performance using 90% train and 10% test std::vector< std::vector<FaceAnnotation> > test_ann(NUM_HEADPOSE_CLASSES); for (unsigned int i=0; i < ann.size(); i++) { int num_train_imgs = static_cast<int>(ann[i].size() * TRAIN_IMAGES_PERCENTAGE); test_ann[i].insert(test_ann[i].begin(), ann[i].begin()+num_train_imgs, ann[i].end()); } FaceForestOptions ff_options; ff_options.fd_option.path_face_cascade = face_cascade; ff_options.hp_forest_param = hp_param; ff_options.mp_forest_param = mp_param; evalForest(ff_options, test_ann); return EXIT_SUCCESS; };
bool AppDelegate::applicationDidFinishLaunching() { // load config auto config = Configuration::getInstance(); config->loadConfigFile("config/words.plist"); // init word data Constants::initWordData(); // random seed srand( unsigned( time(0) ) ); // initialize director auto director = Director::getInstance(); auto glview = director->getOpenGLView(); if(!glview) { glview = GLViewImpl::create("My Game"); director->setOpenGLView(glview); } auto screenSize = glview->getFrameSize(); auto designSize = Size(320, 480); std::vector<std::string> searchPaths; if (screenSize.height > 960) { searchPaths.push_back("HDR"); searchPaths.push_back("HD"); searchPaths.push_back("SD"); director->setContentScaleFactor(4.0f); } else if (screenSize.height > 480) { searchPaths.push_back("HD"); searchPaths.push_back("SD"); director->setContentScaleFactor(2.0f); } else { searchPaths.push_back("SD"); director->setContentScaleFactor(1.0f); } FileUtils::getInstance()->setSearchPaths(searchPaths); auto cacher = SpriteFrameCache::getInstance(); cacher->addSpriteFramesWithFile("assets.plist"); glview->setDesignResolutionSize(designSize.width, designSize.height, ResolutionPolicy::FIXED_HEIGHT); // set FPS. the default value is 1.0/60 if you don't call this director->setAnimationInterval(1.0 / 60); // create a scene. it's an autorelease object auto scene = HelloWorld::createScene(); // run director->runWithScene(scene); return true; }
MainWindow::MainWindow(QHash<int, Joystick*> *joysticks, CommandLineUtility *cmdutility, bool graphical, QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); ui->stackedWidget->setCurrentIndex(0); delete ui->tab_2; ui->tab_2 = 0; delete ui->tab; ui->tab = 0; this->graphical = graphical; signalDisconnect = false; showTrayIcon = !cmdutility->isTrayHidden() && graphical; this->joysticks = joysticks; if (showTrayIcon) { trayIconMenu = new QMenu(this); trayIcon = new QSystemTrayIcon(this); connect(trayIconMenu, SIGNAL(aboutToShow()), this, SLOT(refreshTrayIconMenu())); connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(trayIconClickAction(QSystemTrayIcon::ActivationReason)), Qt::DirectConnection); } fillButtons(joysticks); if (cmdutility->hasProfile()) { if (cmdutility->hasControllerNumber()) { loadConfigFile(cmdutility->getProfileLocation(), cmdutility->getControllerNumber()); } else { loadConfigFile(cmdutility->getProfileLocation()); } } aboutDialog = new AboutDialog(this); QApplication *app = static_cast<QApplication*> (QCoreApplication::instance()); connect(ui->menuOptions, SIGNAL(aboutToShow()), this, SLOT(mainMenuChange())); connect(ui->actionAbout_Qt, SIGNAL(triggered()), app, SLOT(aboutQt())); }
bool GameEngine::init() { loadConfigFile(); DEngine->init(); return true; }
bool ResourceManagerImplementation::loadConfigData() { if (!loadConfigFile()) return false; bool loadFromScript = lua->getGlobalInt("buildInitialResourcesFromScript"); String zonesString = lua->getGlobalString("activeZones"); StringTokenizer zonesTokens(zonesString); zonesTokens.setDelimeter(","); while(zonesTokens.hasMoreTokens()) { String zoneName; zonesTokens.getStringToken(zoneName); resourceSpawner->addZone(zoneName); } shiftInterval = lua->getGlobalInt("averageShiftTime"); int aveduration = lua->getGlobalInt("aveduration"); float spawnThrottling = float(lua->getGlobalInt("spawnThrottling")) / 100.0f; int lowerGateOverride = lua->getGlobalInt("lowerGateOverride"); int maxSpawnQuantity = lua->getGlobalInt("maxSpawnQuantity"); resourceSpawner->setSpawningParameters(loadFromScript, aveduration, spawnThrottling, lowerGateOverride, maxSpawnQuantity); String jtlResources = lua->getGlobalString("jtlresources"); StringTokenizer jtlTokens(jtlResources); jtlTokens.setDelimeter(","); while(jtlTokens.hasMoreTokens()) { String token; jtlTokens.getStringToken(token); resourceSpawner->addJtlResource(token); } LuaObject minpoolinc = lua->getGlobalObject("minimumpoolincludes"); String minpoolexc = lua->getGlobalString("minimumpoolexcludes"); resourceSpawner->initializeMinimumPool(minpoolinc, minpoolexc); LuaObject randpoolinc = lua->getGlobalObject("randompoolincludes"); String randpoolexc = lua->getGlobalString("randompoolexcludes"); int randpoolsize = lua->getGlobalInt("randompoolsize"); resourceSpawner->initializeRandomPool(randpoolinc, randpoolexc, randpoolsize); LuaObject fixedpoolinc = lua->getGlobalObject("fixedpoolincludes"); String fixedpoolexc = lua->getGlobalString("fixedpoolexcludes"); resourceSpawner->initializeFixedPool(fixedpoolinc, fixedpoolexc); String natpoolinc = lua->getGlobalString("nativepoolincludes"); String natpoolexc = lua->getGlobalString("nativepoolexcludes"); resourceSpawner->initializeNativePool(natpoolinc, natpoolexc); return true; }
INI::INI(const char *fileNameWithPath, bool _autoCreate): data(NULL), fStream(NULL), autoSave(false), autoCreate(_autoCreate) { strcpy(iniFileName, fileNameWithPath); loadConfigFile(); }
static void loadConfig(void) { char *configFilename; /* load default config first */ loadConfigFile("data/app/"CONFIG_FILENAME); /* load saved config */ configFilename = getSaveFilePath(CONFIG_FILENAME); if (fileExists(configFilename)) { loadConfigFile(configFilename); } /* so that the player doesn't get confused if this is a new game */ saveConfig(); }
Camera(int camera_id, std::string config_file_name = "") { capture.open(camera_id); valid = capture.isOpened(); if (!valid) std::cout << "[WARNING] failed to open camera " << camera_id << std::endl; else { undistort_enabled = loadConfigFile(config_file_name); capture.set(CV_CAP_PROP_FRAME_WIDTH, width); capture.set(CV_CAP_PROP_FRAME_HEIGHT, height); } }
Config::Config(QNetworkAccessManager *netManager, QObject* parent) : m_netManager(netManager) { // populate the allowed databases m_allowedDbs.append("urbanterror_4_1_1"); // urban terror 4.1.1 // load data loadConfigFile(); // check if couch server is set up correctly and that we can communicate with it checkCouchDb(); }
/** * Signal handler for HUP which tells us to swap the log file * and reload configuration file if specified * * @param sig */ void do_signal_sighup(RunTimeOpts * rtOpts, PtpClock * ptpClock) { NOTIFY("SIGHUP received\n"); #ifdef RUNTIME_DEBUG if(rtOpts->transport == UDP_IPV4 && rtOpts->ipMode != IPMODE_UNICAST) { DBG("SIGHUP - running an ipv4 multicast based mode, re-sending IGMP joins\n"); netRefreshIGMP(&ptpClock->netPath, rtOpts, ptpClock); } #endif /* RUNTIME_DEBUG */ /* if we don't have a config file specified, we're done - just reopen log files*/ if(strlen(rtOpts->configFile) != 0) { dictionary* tmpConfig = dictionary_new(0); /* Try reloading the config file */ NOTIFY("Reloading configuration file: %s\n",rtOpts->configFile); if(!loadConfigFile(&tmpConfig, rtOpts)) { dictionary_del(&tmpConfig); } else { dictionary_merge(rtOpts->cliConfig, tmpConfig, 1, 1, "from command line"); applyConfig(tmpConfig, rtOpts, ptpClock); dictionary_del(&tmpConfig); } } /* tell the service it can perform any HUP-triggered actions */ ptpClock->timingService.reloadRequested = TRUE; if(rtOpts->recordLog.logEnabled || rtOpts->eventLog.logEnabled || (rtOpts->statisticsLog.logEnabled)) INFO("Reopening log files\n"); restartLogging(rtOpts); if(rtOpts->statisticsLog.logEnabled) ptpClock->resetStatisticsLog = TRUE; }
int loadConfigDir( char *bundleName, // bundle directory name (e.g. "System.config") int useDefault, // use Default.table instead of instance tables char **table, // returns pointer to config table int allocTable // malloc the table and return in *table ) { char *buf; int i, ret; buf = malloc(256); ret = 0; // load up to 99 instance tables for (i=0; i < 99; i++) { sprintf(buf, "%s%s.config/Instance%d.table", IO_CONFIG_DIR, bundleName, i); if (useDefault || (loadConfigFile(buf, table, allocTable) != 0)) { if (i == 0) { // couldn't load first instance table; // try the default table sprintf(buf, "%s%s.config/%s", IO_CONFIG_DIR, bundleName, IO_DEFAULT_TABLE_FILENAME); if (loadConfigFile(buf, table, allocTable) == 0) { ret = 1; } else { if (!allocTable) error("Config file \"%s\" not found\n", buf); ret = -1; } } // we must be done. break; } } free(buf); return ret; }
static void setupSmbiosConfigFile(const char *filename) { char dirSpecSMBIOS[128] = ""; const char *override_pathname = NULL; int len = 0, err = 0; extern void scan_mem(); // Take in account user overriding if (getValueForKey(kSMBIOSKey, &override_pathname, &len, &bootInfo->bootConfig) && len > 0) { // Specify a path to a file, e.g. SMBIOS=/Extra/macProXY.plist sprintf(dirSpecSMBIOS, override_pathname); err = loadConfigFile(dirSpecSMBIOS, &bootInfo->smbiosConfig); } else { // Check selected volume's Extra. sprintf(dirSpecSMBIOS, "/Extra/%s", filename); if (err = loadConfigFile(dirSpecSMBIOS, &bootInfo->smbiosConfig)) { // Check booter volume/rdbt Extra. sprintf(dirSpecSMBIOS, "bt(0,0)/Extra/%s", filename); err = loadConfigFile(dirSpecSMBIOS, &bootInfo->smbiosConfig); } } if (err) { verbose("No SMBIOS replacement found.\n"); } // get a chance to scan mem dynamically if user asks for it while having the config options loaded as well, // as opposed to when it was in scan_platform(); also load the orig. smbios so that we can access dmi info without // patching the smbios yet getSmbios(SMBIOS_ORIGINAL); scan_mem(); smbios_p = (EFI_PTR32)getSmbios(SMBIOS_PATCHED); // process smbios asap }
void MetadataManager::setDouble(String uri, const char* name, double value) { XOJ_CHECK_TYPE(MetadataManager); if (uri.isEmpty()) { return; } loadConfigFile(); g_key_file_set_double(this->config, uri.c_str(), name, value); updateAccessTime(uri); }
/* main start for Arnold CPC emulator for linux */ int main(int argc, char *argv[]) { configInit(); //FIXME: disabled for debug /* print welcome message */ printf("Arnold Emulator (c) Kevin Thacker\n"); printf("Linux Port maintained by Andreas Micklei\n"); roms_init(); //printrom(); if (!CPCEmulation_CheckEndianness()) { printf("%s", Messages[72]); exit(1); } // /* check display */ // if (!XWindows_CheckDisplay()) // { // printf("Failed to open display. Or display depth is 8-bit\n"); // exit(-1); // } /* initialise cpc hardware */ CPC_Initialise(); Multiface_Install(); /* done before parsing command line args. Command line args will take priority */ loadConfigFile(); //FIXME: disabled for debug init_main(argc, argv); CPC_Finish(); Multiface_DeInstall(); //printf("heello"); saveConfigFile(); //FIXME: disabled for debug configFree(); //FIXME: disabled for debug exit(0); return 0; /* Never reached */ }
/** * Slot function for the load config menu. */ void CreateSceFile::loadConfigSlot() { if(!m_configFileName.isEmpty()) { saveConfigSlot(); } QString tmpFileName = QFileDialog::getOpenFileName(this, tr("Open script config file"), MainWindow::getAndCreateProgramUserFolder(), tr("XML files (*.xml);;Files (*)")); if(!tmpFileName.isEmpty()) { m_configFileName = tmpFileName; loadConfigFile(); emit configHasToBeSavedSignal(); } }
static void setupEfiGetOverrideConfig( void ) { const char *value; int len; int i; unsigned char uuid[UUID_LEN]; if (!getValueForKey(kSMBIOS, &value, &len, &bootInfo->bootConfig)) { value = "/Extra/smbios.plist"; } if (loadConfigFile(value, &bootInfo->smbiosConfig) == -1) { verbose("No SMBIOS replacement found\n"); } if (getValueForKey("SMUUID", &value, &len, &bootInfo->smbiosConfig) && value != NULL && stringToUUID(value, uuid) == 0) { verbose("Using SMUUID='%s' from smbios.plist as System-ID\n", value); memcpy(SystemID, uuid, UUID_LEN); } else if (getValueForKey(kSystemID, &value, &len, &bootInfo->bootConfig) && value != NULL && value[0] != 'N' && value[0] != 'n' && stringToUUID(value, uuid) == 0) { verbose("Using SystemID='%s' from com.apple.Boot.plist as System-ID\n", value); memcpy(SystemID, uuid, UUID_LEN); } else if (getSMBIOSUUID(uuid)) { verbose("Using original SMBIOS UUID='%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x' as System-ID\n", uuid[0],uuid[1],uuid[2],uuid[3],uuid[4],uuid[5],uuid[6],uuid[7], uuid[8],uuid[9],uuid[10],uuid[11],uuid[12],uuid[13],uuid[14],uuid[15]); memcpy(SystemID, uuid, UUID_LEN); } else { verbose("Using builtin default UUID as System-ID\n"); } if (getValueForKey("SMserial", &value, &len, &bootInfo->smbiosConfig)) { if (len < MAX_SERIAL_LEN) { for (i=0; i<len; i++) { SystemSerial[i] = value[i]; } SystemSerial[len] = '\0'; SystemSerialLength = (len + 1) * 2; } } if (getValueForKey("SMproductname", &value, &len, &bootInfo->smbiosConfig)) { if (len < MAX_MODEL_LEN) { for (i=0; i<len; i++) { Model[i] = value[i]; } Model[len] = '\0'; ModelLength = (len + 1) * 2; } } }
/* Load the smbios.plist override config file if any */ static void setupSmbiosConfigFile() { const char * value = getStringForKey(kSMBIOS, &bootInfo->bootConfig); extern void scan_mem(); if (!value) value = "/Extra/smbios.plist"; if (loadConfigFile(value, &bootInfo->smbiosConfig) == -1) { verbose("No SMBIOS replacement found\n"); } // get a chance to scan mem dynamically if user asks for it while having the config options loaded as well // as opposed to when it was in scan_platform(), also load the orig. smbios so that we can access dmi info without // patching the smbios yet getSmbios(SMBIOS_ORIGINAL); scan_mem(); smbios_p = (EFI_PTR32) getSmbios(SMBIOS_PATCHED); // process smbios asap }
// ----------------------------------------------------------------------------- // // Purpose and Method: // Inputs: // Outputs: // Dependencies: // Restrictions and Caveats: // // ----------------------------------------------------------------------------- int main ( int argc, char **argv ) { // Train feature points detector std::string ffd_config_file = "data/config_ffd.txt"; // Parse configuration file ForestParam mp_param; if (!loadConfigFile(ffd_config_file, mp_param)) return EXIT_FAILURE; // Loading images annotations std::vector<FaceAnnotation> annotations; if (!loadAnnotations(mp_param.image_path, annotations)) return EXIT_FAILURE; // Separate annotations by head-pose classes std::vector< std::vector<FaceAnnotation> > ann(NUM_HEADPOSE_CLASSES); for (unsigned int i=0; i < annotations.size(); i++) ann[annotations[i].pose+2].push_back(annotations[i]); // Evaluate performance using 90% train and 10% test std::vector< std::vector<FaceAnnotation> > train_ann(NUM_HEADPOSE_CLASSES); for (unsigned int i=0; i < ann.size(); i++) { int num_train_imgs = static_cast<int>(ann[i].size() * TRAIN_IMAGES_PERCENTAGE); train_ann[i].insert(train_ann[i].begin(), ann[i].begin(), ann[i].begin()+num_train_imgs); } // Train facial-feature forests /*for (int i=0; i < NUM_HEADPOSE_CLASSES; i++) for (int j=0; j < mp_param.ntrees; j++) trainTree(mp_param, train_ann, i, j);*/ // Train facial-feature tree int idx_forest = atoi(argv[1]); int idx_tree = atoi(argv[2]); trainTree(mp_param, train_ann, idx_forest, idx_tree); return EXIT_SUCCESS; };
/* Returns 0 if requested config files were loaded, * 1 if default files were loaded, * -1 if no files were loaded. * Prints error message if files cannot be loaded. */ int loadSystemConfig( char *which, int size ) { char *buf, *bp, *cp; int ret, len, doDefault=0; buf = bp = malloc(256); if (which && size) { for(cp = which, len = size; len && *cp && *cp != LP; cp++, len--) ; if (*cp == LP) { while (len-- && *cp && *cp++ != RP) ; /* cp now points past device */ strncpy(buf,which,cp - which); bp += cp - which; } else { cp = which; len = size; } if (*cp != '/') { strcpy(bp, IO_SYSTEM_CONFIG_DIR); strncat(bp, cp, len); if (strncmp(cp + len - strlen(IO_TABLE_EXTENSION), IO_TABLE_EXTENSION, strlen(IO_TABLE_EXTENSION)) != 0) strcat(bp, IO_TABLE_EXTENSION); } else { strncpy(bp, cp, len); bp[size] = '\0'; } if (strcmp(bp, SYSTEM_DEFAULT_FILE) == 0) doDefault = 1; ret = loadConfigFile(bp = buf, 0, 0); } else { ret = loadConfigDir((bp = SYSTEM_CONFIG), 0, 0, 0); } if (ret < 0) { error("System config file '%s' not found\n", bp); } else sysConfigValid = 1; free(buf); return (ret < 0 ? ret : doDefault); }
HeadPoseEstimator::HeadPoseEstimator(char *configFileName) { loadDefaults(); loadConfigFile(configFileName); crfe = new CRForestEstimator(); if( !crfe->loadForest(g_treepath.c_str(), g_ntrees)) { std::cout << "could not read forest!" << std::endl; return; } pointCloud = new MyCVPointCloud(640, 480); cylinderCoeff.values.resize(7); success = false; rotationMatrixEstimated = Eigen::Matrix3f::Identity(); }
/******************* FUNCTION *********************/ void CMRCmdOptions::parseOption ( char key, std::string arg, std::string value ) throw (svUnitTest::svutExArgpError) { std::stringstream err; switch(key) { case 'w': this->width = atoi(value.c_str()); if (width <= 0) { err << "Invalid width on -w/--width : " << value << std::endl; throw svUnitTest::svutExArgpError(err.str()); } break; case 'h': this->height = atoi(value.c_str()); if (width <= 0) { err << "Invalid height on -h/--height : " << value << std::endl; throw svUnitTest::svutExArgpError(err.str()); } break; case 'i': this->iterations = atoi(value.c_str()); if (width <= 0) { err << "Invalid number of iterations on -i/--iterations : " << value << std::endl; throw svUnitTest::svutExArgpError(err.str()); } break; case 'c': this->configFile = value; loadConfigFile(configFile); break; case 'd': dumpUsedDic = dictionary_new(5); this->dumpConfigFile = value; break; default: err << "Unknown argument : " << arg << std::endl; throw svUnitTest::svutExArgpError(err.str()); break; } }
bool MetadataManager::getDouble(String uri, const char* name, double& value) { XOJ_CHECK_TYPE(MetadataManager); if (uri.isEmpty()) { return false; } loadConfigFile(); GError* error = NULL; double v = g_key_file_get_double(this->config, uri.c_str(), name, &error); if (error) { g_error_free(error); return false; } value = v; return true; }
void DetectorColor::init(const std::string& filename, const cv::Size& frameSize, const Color& color, const bool& windowVideoShow, const bool& windowLimitsShow, const std::string& name) { this->frameSize = frameSize; this->color = color; this->windowVideoShow = windowVideoShow; this->windowLimitsShow = windowLimitsShow; this->name = name; cropFilter.roi.x = 0; cropFilter.roi.y = 0; cropFilter.roi.width = frameSize.width; cropFilter.roi.height = frameSize.height; if (!filename.empty()) { po::options_description options; options.add_options() ("name", po::value<std::string>(&this->name)) ("window.video.show", po::value<bool>(&this->windowVideoShow)->default_value(this->windowVideoShow)) ("window.limits.show", po::value<bool>(&this->windowLimitsShow)->default_value(this->windowLimitsShow)) ; options.add(hsvFilter.options()); options.add(openFilter.options()); options.add(closeFilter.options()); po::variables_map vm; loadConfigFile(filename, options, vm); po::notify(vm); hsvFilter.notify(); openFilter.notify(); closeFilter.notify(); } if (this->windowVideoShow) { createWindowVideo(); } if (this->windowLimitsShow) { createWindowLimits(); } }
//=================Game===================== // void Game::run() { loadConfigFile(mConfig); sf::Time timeSinceLastUpdate = sf::Time::Zero; mTimePerFrame = sf::seconds(1.f/60.f); while(mWindow.isOpen()) { sf::Time elapsedTime = mGameClock.restart(); timeSinceLastUpdate = elapsedTime; while(timeSinceLastUpdate > mTimePerFrame) { timeSinceLastUpdate -= mTimePerFrame; processEvents(); update(mTimePerFrame); } } }