void GlutDisplaySystem::setup(Setting& setting) { String sCfg; setting.lookupValue("config", sCfg); int width; int height; myFov = 60; myNearz = 1.0f; myFarz = 100; libconfig::ArgumentHelper ah; ah.newInt("width", "Resolution width", width); ah.newInt("height", "Resolution width", height); ah.newNamedInt('f', "fov", "fov", "field of view", myFov); ah.newNamedDouble('z', "nearz", "nearZ", "near Z clipping plane", myNearz); ah.newNamedDouble('Z', "farz", "farZ", "far Z clipping plane", myFarz); ah.process(sCfg.c_str()); myResolution[0] = width; myResolution[1] = height; myAspect = (float)width / height; mySetting = &setting; }
bool Settings::RestoreValues(const BMessage& message) { AutoLocker<BLocker> locker(fLock); for (int32 i = 0; i < fDescription->CountSettings(); i++) { Setting* setting = fDescription->SettingAt(i); BVariant value; if (value.SetFromMessage(message, setting->ID()) == B_OK) { if (!SetValue(setting, value)) return false; } } return true; }
void IconList::settingChanged(const Setting &setting, QVariant value) { if(setting.id() != "IconsDir") return; directoryChanged(value.toString()); }
float GetExperienceForLevel(ActorValueInfo * info, UInt32 level) { if(!info || !info->skillUsages) return 0.0; double fSkillUseCurve = 0.0; SettingCollectionMap * settings = *g_gameSettingCollection; if(!settings) return 0.0; Setting * skillUseCurve = settings->Get("fSkillUseCurve"); if(skillUseCurve) skillUseCurve->GetDouble(&fSkillUseCurve); return info->skillUsages[ActorValueInfo::kSkillImproveMult] * pow(level, fSkillUseCurve) + info->skillUsages[ActorValueInfo::kSkillImproveOffset]; }
RaspberryPiController::RaspberryPiController(const Setting &cfg) : StageController(cfg), motor_cw_gpio(unsigned(cfg.lookup("motor_cw_gpio"))), motor_ccw_gpio(unsigned(cfg.lookup("motor_ccw_gpio"))), encoder_gpios(config_get_encoder_gpios(cfg)) { gpioSetMode(motor_cw_gpio, PI_OUTPUT); gpioSetMode(motor_ccw_gpio, PI_OUTPUT); for (auto& g: encoder_gpios) { gpioSetMode(g.first, PI_INPUT); gpioSetAlertFuncEx(g.first, static_encoder_callback, this); } }
void ConfigFactory::createTimeSeriesList(Setting& timeSeriesGroup) { int tsCount = timeSeriesGroup.getLength(); // loop through the time series and create them. for (int iSeries = 0; iSeries < tsCount; ++iSeries) { Setting& series = timeSeriesGroup[iSeries]; string seriesName = series["name"]; TimeSeries::sharedPointer theTimeSeries = createTimeSeriesOfType(series); if (theTimeSeries != NULL) { _timeSeriesList[seriesName] = theTimeSeries; } } // connect single sources (ModularTimeSeries subclasses) typedef std::map<string, string> stringMap_t; BOOST_FOREACH(const stringMap_t::value_type& stringPair, _timeSeriesSourceList) { string tsName = stringPair.first; string sourceName = stringPair.second; if (_timeSeriesList.find(tsName) == _timeSeriesList.end()) { std::cerr << "cannot locate Timeseries " << tsName << std::endl; continue; } if (_timeSeriesList.find(sourceName) == _timeSeriesList.end()) { std::cerr << "cannot locate specified source Timeseries " << sourceName << std::endl; std::cerr << "-- (specified by Timeseries " << tsName << ")" << std::endl; continue; } ModularTimeSeries::sharedPointer ts = boost::static_pointer_cast<ModularTimeSeries>(_timeSeriesList[tsName]); TimeSeries::sharedPointer source = _timeSeriesList[sourceName]; ts->setSource(source); }
void BoundaryModuleDrivenBase::init( Grid* pGrid, Setting& cfg){ BoundaryModule::init(pGrid,cfg); Setting& params = cfg.lookup("params"); string polString = params.lookup("polarisation"); if( polString == "x" || polString == "TE") mPOL = TE; if( polString == "y" || polString == "TM") mPOL = TM; return; }
void Yahoo::createQuoteUrls (QString &d) { // multiple quotes: download.finance.yahoo.com/d/quotes.csv?s=IBM+RHAT+SCOX+MSFT+GOLD&f=sl1d1t1c1ohgv // multiple close only: download.finance.yahoo.com/d/quotes.csv?s=IBM+RHAT+SCOX+MSFT+GOLD&f=sl1 // URLPrefix = "http://download.finance.yahoo.com/d/quotes.csv?s="; // URLPostfix = "&f=snl1d1t1c1ohgv&e=.csv"; QString s = "http://download.finance.yahoo.com/d/quotes.csv?s="; s.append(d); s.append("&f=snl1d1t1c1ohgv&e=.csv"); Setting *set = new Setting; QString ts = "url"; set->setData(ts, s); ts = "symbol"; set->setData(ts, d); url.append(set); }
bool Cmd_GetStringGameSetting_Execute(COMMAND_ARGS) { char settingName[0x100] = { 0 }; const char* settingString = ""; if (ExtractArgs(EXTRACT_ARGS, &settingName)) { Setting* setting = NULL; GameSettingCollection* gmsts = GameSettingCollection::GetSingleton(); if (gmsts && gmsts->GetGameSetting(settingName, &setting) && setting && setting->GetType() == Setting::kSetting_String) setting->Get(settingString); } AssignToStringVar(PASS_COMMAND_ARGS, settingString); return true; }
void LOWPASS::setIndicatorSettings (Setting &dict) { setDefaults(); if (! dict.count()) return; QString s; dict.getData(colorLabel, s); if (s.length()) color.setNamedColor(s); dict.getData(lineTypeLabel, s); if (s.length()) lineType = (PlotLine::LineType) s.toInt(); dict.getData(labelLabel, s); if (s.length()) label = s; dict.getData(inputLabel, s); if (s.length()) input = (BarData::InputType) s.toInt(); dict.getData(freqLabel, s); if (s.length()) freq = s.toFloat(); dict.getData(widthLabel, s); if (s.length()) width = s.toFloat(); }
void SINWAV::setIndicatorSettings (Setting &dict) { setDefaults(); if (! dict.count()) return; QString s; dict.getData(colorSinLabel, s); if (s.length()) colorSin.setNamedColor(s); dict.getData(colorLeadLabel, s); if (s.length()) colorLead.setNamedColor(s); dict.getData(labelSinLabel, s); if (s.length()) labelSin = s; dict.getData(labelLeadLabel, s); if (s.length()) labelLead = s; dict.getData(lineTypeSinLabel, s); if (s.length()) lineTypeSin = (PlotLine::LineType) s.toInt(); dict.getData(lineTypeLeadLabel, s); if (s.length()) lineTypeLead = (PlotLine::LineType) s.toInt(); }
void WriteTA(Setting& s, TextAttributes& taResult) { UpdateSetting(s,"position", (int&)taResult.position, Setting::TypeInt); UpdateSetting(s,"posType", (int&)taResult.posType, Setting::TypeInt); UpdateSetting(s,"xPosRatio", taResult.xPosRatio, Setting::TypeInt); UpdateSetting(s,"yPosRatio", taResult.yPosRatio, Setting::TypeInt); std::string text(taResult.text); UpdateSetting(s,"text", text, Setting::TypeString); UpdateSetting(s,"backgroundColor", (int&)taResult.backgroundColor, Setting::TypeInt); UpdateSetting(s,"textColor", (int&)taResult.textColor, Setting::TypeInt); UpdateSetting(s,"isFontSelected", taResult.isFontSelected, Setting::TypeInt); Setting* sf; if (s.exists("Font")) sf = &(s["Font"]); else sf = &(s.add("Font", Setting::TypeGroup)); WriteFont(*sf, taResult.logfont); }
void CUS::setIndicatorSettings (Setting &dict) { formulaList.clear(); if (! dict.count()) return; QString ts = "script"; QString s; dict.getData(ts, s); if (s.length()) formulaList = QStringList::split("|", s, FALSE); ts = "version"; dict.getData(ts, s); if (s.length()) version = s.toDouble(); }
void ChannelGroupStorage::Save(void) { QString value = setting->getValue(); if (value == "1") ChannelGroup::AddChannel(chanid, grpid); else ChannelGroup::DeleteChannel(chanid, grpid); }
cubiclinear_histomorph::cubiclinear_histomorph(const Configuration & ctx): normalize_to_nominal(false) { boost::shared_ptr<VarIdManager> vm = ctx.pm->get<VarIdManager>(); //build nominal histogram: h0_wu = get_constant_histogram(Configuration(ctx, ctx.setting["nominal-histogram"])); h0 = h0_wu.get_values_histogram(); if(ctx.setting.exists("normalize_to_nominal")){ normalize_to_nominal = ctx.setting["normalize_to_nominal"]; } Setting psetting = ctx.setting["parameters"]; size_t n = psetting.size(); parameter_factors.resize(n, 1.0); bool have_parameter_factors = ctx.setting.exists("parameter_factors"); for(size_t i=0; i<n; i++){ string par_name = psetting[i]; ParId pid = vm->get_par_id(par_name); par_ids.insert(pid); vid.push_back(pid); string setting_name; //plus: setting_name = par_name + "-plus-histogram"; hplus_diff.push_back(get_constant_histogram(Configuration(ctx, ctx.setting[setting_name])).get_values_histogram()); hplus_diff.back().check_compatibility(h0); hplus_diff.back().add_with_coeff(-1.0, h0); //minus: setting_name = par_name + "-minus-histogram"; hminus_diff.push_back(get_constant_histogram(Configuration(ctx, ctx.setting[setting_name])).get_values_histogram()); hminus_diff.back().check_compatibility(h0); hminus_diff.back().add_with_coeff(-1.0, h0); sum.push_back(hplus_diff.back()); sum.back() += hminus_diff.back(); diff.push_back(hplus_diff.back()); diff.back().add_with_coeff(-1, hminus_diff.back()); if(have_parameter_factors){ parameter_factors[i] = ctx.setting["parameter_factors"][i]; } } h0_sum = 0; for(size_t i=0; i < h0.get_nbins(); ++i){ h0_sum += h0.get(i); } }
void PP::getIndicatorSettings (Setting &dict) { QString ts = resColor.name(); dict.setData(resColorLabel, ts); ts = supColor.name(); dict.setData(supColorLabel, ts); ts = QString::number(resLineType); dict.setData(resLineTypeLabel, ts); ts = QString::number(supLineType); dict.setData(supLineTypeLabel, ts); dict.setData(resLabelLabel, resLabel); dict.setData(resLabel2Label, resLabel2); dict.setData(resLabel3Label, resLabel3); dict.setData(supLabelLabel, supLabel); dict.setData(supLabel2Label, supLabel2); dict.setData(supLabel3Label, supLabel3); dict.setData(labelLabel, label); dict.setData(pluginLabel, pluginName); }
bool Cmd_SetNumericIniSetting_Execute(COMMAND_ARGS) { char settingName[512] = { 0 }; float newVal = 0; *result = 0; if (ExtractArgs(EXTRACT_ARGS, &settingName, &newVal)) { Setting* setting; if (GetIniSetting(settingName, &setting)) { if (setting->Set(newVal)) *result = 1; } else if (IsConsoleMode()) Console_Print("SetNumericIniSetting >> NOT FOUND"); } return true; }
mcmc_posterior_histo::mcmc_posterior_histo(const theta::Configuration & cfg): Producer(cfg), init(false), smooth(false){ Setting s = cfg.setting; boost::shared_ptr<VarIdManager> vm = cfg.pm->get<VarIdManager>(); size_t n = s["parameters"].size(); for(size_t i=0; i<n; ++i){ string parameter_name = s["parameters"][i]; parameter_names.push_back(parameter_name); parameters.push_back(vm->get_par_id(parameter_name)); nbins.push_back(static_cast<unsigned int>(s["histo_" + parameter_name]["nbins"])); lower.push_back(s["histo_" + parameter_name]["range"][0]); upper.push_back(s["histo_" + parameter_name]["range"][1]); } mcmc_strategy = construct_mcmc_strategy(cfg); if(s.exists("smooth")){ smooth = s["smooth"]; } for(size_t i=0; i<parameters.size(); ++i){ columns.push_back(products_sink->declare_product(*this, "posterior_" + parameter_names[i], theta::typeHisto)); } }
// keeping the clock creation simple for now - e.g., no function pointers. void ConfigFactory::createClocks(Setting& clockGroup) { int clockCount = clockGroup.getLength(); for (int iClock = 0; iClock < clockCount; ++iClock) { Setting& clock = clockGroup[iClock]; string clockName = clock["name"]; int period = clock["period"]; Clock::sharedPointer aClock( new Clock(period) ); _clockList[clockName] = aClock; } return; }
bool Cmd_SetNumericGameSetting_Execute(COMMAND_ARGS) { char settingName[512] = { 0 }; float newVal = 0; *result = 0; if (ExtractArgs(EXTRACT_ARGS, &settingName, &newVal)) { Setting* setting; GameSettingCollection* gmsts = GameSettingCollection::GetSingleton(); if (gmsts && gmsts->GetGameSetting(settingName, &setting)) { if (setting->Set(newVal)) *result = 1; } else if (IsConsoleMode()) Console_Print("SetNumericGameSetting >> NOT FOUND"); } return true; }
int readSensors (Setting &sensorConfig, sensorList &sensors, bodyMap &limbs, jointMap &joints, shapeMap &shapes) { //Sensors: // type = {JointSensor, HeightSensor, BodyAngleSensor // target // for HeightSensor: minH, maxH // for BodyAngleSensor: minA, maxA int nSensors = sensorConfig.getLength(); for (int i = 0; i<nSensors; ++i) { try { Setting &curSensor = sensorConfig[i]; string type = curSensor["type"]; string target = curSensor["target"]; if (type == "JointSensor") { SensorP s(new JointSensor(joints[target])); sensors.push_back(s); } else if (type == "HeightSensor") { double minH = curSensor["minH"], maxH = curSensor["maxH"]; SensorP s(new HeightSensor(shapes[target], minH, maxH)); sensors.push_back(s); } else if (type == "BodyAngleSensor") { double minA = curSensor["minA"], maxA = curSensor["maxA"]; SensorP s(new BodyAngleSensor(limbs[target], minA, maxA)); sensors.push_back(s); } else { cerr<<"Creature::readSensors sensor "<<i <<", unknown type: "<<type<<endl; return 0; } } catch (SettingTypeException te) { cerr<<"Creature::readSensors problem processing sensor " <<i<<endl; cerr<<" SettingTypeException: "<<((SettingException)te).what() <<", "<<te.getPath()<<endl; return 0; } catch (SettingNotFoundException te) { cerr<<"Creature::readSensors problem processing sensor " <<i<<endl; cerr<<" SettingNotFoundException: " <<((SettingException)te).what()<<", "<<te.getPath()<<endl; return 0; } catch (...) { cerr<<"Creature::readSensors problem processing limb " <<i<<endl; return 0; } } return 1; }
bool GetNumericIniSetting(char * settingName, double * result) { bool bResult = false; *result = -1; if (strlen(settingName)) { Setting* setting; if (GetIniSetting(settingName, &setting)) { double val; if (setting->Get(val)) { *result = val; bResult = true; } }; } return bResult; }
virtual void store(Setting& image_setting) { CtImage::ImageOpMode imageOpMode; m_image.getMode(imageOpMode); image_setting.set("imageOpMode",convert_2_string(imageOpMode)); // --- Roi Roi roi; m_image.getRoi(roi); Setting roi_setting = image_setting.addChild("roi"); const Point& topleft = roi.getTopLeft(); roi_setting.set("x",topleft.x); roi_setting.set("y",topleft.y); const Size& roiSize = roi.getSize(); roi_setting.set("width",roiSize.getWidth()); roi_setting.set("height",roiSize.getHeight()); // --- Bin Bin bin; m_image.getBin(bin); Setting bin_setting = image_setting.addChild("bin"); bin_setting.set("x",bin.getX()); bin_setting.set("y",bin.getY()); // --- Flip Flip flip; m_image.getFlip(flip); Setting flip_setting = image_setting.addChild("flip"); flip_setting.set("x",flip.x); flip_setting.set("y",flip.y); // --- Rotation RotationMode rMode; m_image.getRotation(rMode); image_setting.set("rotation",convert_2_string(rMode)); }
// Static parsing function idList<Setting> Setting::ParseSettingsFromDict(const idDict& dict, int level) { idList<Setting> list; // Cycle through all difficulty settings (looking for "diff_0_change_*") idStr prefix = idStr(va(PATTERN_DIFF, level)) + PREFIX_CHANGE; for (const idKeyValue* keyVal = dict.MatchPrefix(prefix); keyVal != NULL; keyVal = dict.MatchPrefix(prefix, keyVal)) { DM_LOG(LC_DIFFICULTY, LT_INFO)LOGSTRING("Parsing keyvalue: %s = %s.\r", keyVal->GetKey().c_str(), keyVal->GetValue().c_str()); // Get the index from this keyvalue (remove the prefix and convert to int) idStr key = keyVal->GetKey(); key.StripLeadingOnce(prefix); if (key.IsNumeric()) { // Extract the index int index = atoi(key); // Parse the settings with the given index Setting s; s.ParseFromDict(dict, level, index); // Check for validity and insert into map if (s.isValid) { list.Append(s); } } else { gameLocal.Warning("Found invalid difficulty settings index: %s.", keyVal->GetKey().c_str()); DM_LOG(LC_DIFFICULTY, LT_ERROR)LOGSTRING("Found invalid difficulty settings index: %s.\r", keyVal->GetKey().c_str()); } } return list; }
bool GetNumericGameSetting(char * settingName, double * result) { bool bResult = false; *result = -1; if (strlen(settingName)) { Setting* setting; GameSettingCollection* gmsts = GameSettingCollection::GetSingleton(); if (gmsts && gmsts->GetGameSetting(settingName, &setting)) { double val; if (setting->Get(val)) { *result = val; bResult = true; } }; } return bResult; }
bool sHotKeyOpts::Read(Setting& cProfile) { std::string hk("Start"); if(cProfile.exists(hk)) { const Setting& s = cProfile[hk]; s.lookupValue("Key", m_RecordStart.m_vKey); s.lookupValue("Mod", m_RecordStart.m_fsMod); } hk = "End"; if(cProfile.exists(hk)) { const Setting& s = cProfile[hk]; s.lookupValue("Key", m_RecordEnd.m_vKey); s.lookupValue("Mod", m_RecordEnd.m_fsMod); } hk = "Cancel"; if(cProfile.exists(hk)) { const Setting& s = cProfile[hk]; s.lookupValue("Key", m_RecordCancel.m_vKey); s.lookupValue("Mod", m_RecordCancel.m_fsMod); } hk = "Next"; if(cProfile.exists(hk)) { const Setting& s = cProfile[hk]; s.lookupValue("Key", m_Next.m_vKey); s.lookupValue("Mod", m_Next.m_fsMod); } hk = "Prev"; if(cProfile.exists(hk)) { const Setting& s = cProfile[hk]; s.lookupValue("Key", m_Prev.m_vKey); s.lookupValue("Mod", m_Prev.m_fsMod); } hk = "Layout"; if(cProfile.exists(hk)) { const Setting& s = cProfile[hk]; s.lookupValue("Key", m_ShowLayout.m_vKey); s.lookupValue("Mod", m_ShowLayout.m_fsMod); } hk = "Zoom"; if(cProfile.exists(hk)) { const Setting& s = cProfile[hk]; s.lookupValue("Key", m_Zoom.m_vKey); s.lookupValue("Mod", m_Zoom.m_fsMod); } bool pass = false; cProfile.lookupValue("PassThrough", pass); setPassThrough(pass); // see hook.cpp return true; }
void ReadTA(Setting& s, TextAttributes& taResult) { s.lookupValue("position", (int&)taResult.position); s.lookupValue("posType", (int&)taResult.posType); s.lookupValue("xPosRatio", taResult.xPosRatio); s.lookupValue("yPosRatio", taResult.yPosRatio); std::string text; s.lookupValue("text", text); taResult.text = text.c_str(); s.lookupValue("backgroundColor", (int&)taResult.backgroundColor); s.lookupValue("textColor", (int&)taResult.textColor); s.lookupValue("isFontSelected", taResult.isFontSelected); if (s.exists("Font")) ReadFont(s["Font"], taResult.logfont); }
int ClientExec::addInstance(const Setting &instance) { int ret; ClientInstance *ci = new ClientInstance(); string testbed_ip; string labelconf; string cmd_line; string epoch; if (instance.lookupValue("testbed_ip", testbed_ip)) { cout << "This instance will be deployed on " << testbed_ip << endl; ci->testbed_ip = testbed_ip; } else { cerr << "error no testbed_ip - don't know where to deploy this instance" << endl; return -1; } if (instance.lookupValue("labelconf", labelconf)) { ci->labelconf = labelconf; } else { cerr << "labelconf is missing from node and is mandatory for stdout file naming" << endl; return -1; } if (instance.lookupValue("cmd_line", cmd_line)) { ci->cmd_line = cmd_line; } else { cerr << "cmd_line is mandatory, what am i deploying?" << endl; } if (instance.lookupValue("epoch", epoch)) { ci->epoch = atoi(epoch.c_str()); } else { cerr << "epoch is mandatory " << endl; } instances.push_back(ci); return 0; }
//---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- bool EffectImplemented::Reload( Manager* managers, int32_t managersCount, const EFK_CHAR* path, const EFK_CHAR* materialPath ) { if(m_pManager == NULL ) return false; Setting* loader = GetSetting(); EffectLoader* eLoader = loader->GetEffectLoader(); if( loader == NULL ) return false; void* data = NULL; int32_t size = 0; if( !eLoader->Load( path, data, size ) ) return false; EFK_CHAR parentDir[512]; if( materialPath == NULL ) { GetParentDir(parentDir, path); materialPath = parentDir; } for( int32_t i = 0; i < managersCount; i++) { ((ManagerImplemented*)&(managers[i]))->BeginReloadEffect( this ); } Reset(); Load( data, size, m_maginificationExternal, materialPath ); m_pManager->EndReloadEffect( this ); for( int32_t i = 0; i < managersCount; i++) { ((ManagerImplemented*)&(managers[i]))->EndReloadEffect( this ); } return false; }
bool TeX2img::Install(HWND hwnd, MSGFUNC &msgfunc) { if(!m_doinst) { g_Setting.Log(_T("TeX2img をインストールしません.")); return true; } else g_Setting.Log(_T("TeX2img のインストールを実行.")); ablib::string dir = g_Applications.m_TeXLive.GetVar(_T("TEXDIR")); if(dir == _T("")) { g_Setting.Log(_T("TeX2img のインストール中:TEXDIR の取得に失敗しました.")); return false; } if(dir != _T("") && dir[dir.length() - 1] != '\\')dir += _T("\\"); dir += _T("bin\\win32\\"); ::CreateDirectoryReflex(dir.c_str()); msgfunc.msg(_T("TeX2img のインストール\n")); std::vector<ablib::string> dependsFiles; dependsFiles.push_back(_T("TeX2imgc.exe")); dependsFiles.push_back(_T("TeX2imgc.exe.config")); dependsFiles.push_back(_T("Azuki.dll")); dependsFiles.push_back(_T("mudraw.exe")); dependsFiles.push_back(_T("pdfiumdraw.exe")); if ( !::CopyFile((m_filedir + m_file).c_str(), (dir + _T("TeX2img.exe")).c_str(), FALSE) || !::CopyFile((m_filedir + m_file + _T(".config")).c_str(), (dir + _T("TeX2img.exe.config")).c_str(), FALSE) ){ g_Setting.Log(_T("TeX2imgのインストール:ファイルのコピーに失敗.")); } for(auto file : dependsFiles) { if(!::CopyFile((m_filedir + file).c_str(), (dir + file).c_str(), FALSE)) { g_Setting.Log(_T("TeX2imgのインストール:") + file + _T("のコピーに失敗.")); } } msgfunc.detail(_T("TeX2img をインストールしました.\n")); return TeX2img_funcs::Set( g_Applications.m_TeXLive.GetVar(_T("TEXDIR")) + _T("\\"), msgfunc.msg,msgfunc.detail, std::bind(&Setting::Log,&g_Setting,std::placeholders::_1)); }