void ThemeModel::reload() { reset(); clearThemeList(); // get all desktop themes QStringList themes = KGlobal::dirs()->findAllResources("data", "aurorae/themes/*/metadata.desktop", KStandardDirs::NoDuplicates); foreach(const QString &theme, themes) { int themeSepIndex = theme.lastIndexOf('/', -1); QString themeRoot = theme.left(themeSepIndex); int themeNameSepIndex = themeRoot.lastIndexOf('/', -1); QString packageName = themeRoot.right(themeRoot.length() - themeNameSepIndex - 1); KDesktopFile df(theme); QString name = df.readName(); if (name.isEmpty()) { name = packageName; } QString comment = df.readComment(); QString author = df.desktopGroup().readEntry("X-KDE-PluginInfo-Author", QString()); QString email = df.desktopGroup().readEntry("X-KDE-PluginInfo-Email", QString()); QString version = df.desktopGroup().readEntry("X-KDE-PluginInfo-Version", QString()); QString license = df.desktopGroup().readEntry("X-KDE-PluginInfo-License", QString()); QString website = df.desktopGroup().readEntry("X-KDE-PluginInfo-Website", QString()); Plasma::FrameSvg *svg = new Plasma::FrameSvg(this); QString svgFile = themeRoot + "/decoration.svg"; if (QFile::exists(svgFile)) { svg->setImagePath(svgFile); } else { svg->setImagePath(svgFile + 'z'); } svg->setEnabledBorders(Plasma::FrameSvg::AllBorders); ThemeConfig *config = new ThemeConfig(); KConfig conf("aurorae/themes/" + packageName + '/' + packageName + "rc", KConfig::FullConfig, "data"); config->load(&conf); // buttons QHash<QString, Plasma::FrameSvg*> *buttons = new QHash<QString, Plasma::FrameSvg*>(); initButtonFrame("minimize", packageName, buttons); initButtonFrame("maximize", packageName, buttons); initButtonFrame("restore", packageName, buttons); initButtonFrame("close", packageName, buttons); initButtonFrame("alldesktops", packageName, buttons); initButtonFrame("keepabove", packageName, buttons); initButtonFrame("keepbelow", packageName, buttons); initButtonFrame("shade", packageName, buttons); initButtonFrame("help", packageName, buttons); ThemeInfo info; info.package = packageName; info.description = comment; info.author = author; info.email = email; info.version = version; info.website = website; info.license = license; info.svg = svg; info.themeRoot = themeRoot; info.themeConfig = config; info.buttons = buttons; m_themes[name] = info; }
int main(int ac, char **av) { int opt; const char *name; const char *configname = conf_get_configname(); struct stat tmpstat; setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); while ((opt = getopt(ac, av, "osdD:nmyrh")) != -1) { switch (opt) { case 'o': input_mode = ask_silent; break; case 's': input_mode = ask_silent; sync_kconfig = 1; break; case 'd': input_mode = set_default; break; case 'D': input_mode = set_default; defconfig_file = optarg; break; case 'n': input_mode = set_no; break; case 'm': input_mode = set_mod; break; case 'y': input_mode = set_yes; break; case 'r': { struct timeval now; unsigned int seed; /* * Use microseconds derived seed, * compensate for systems where it may be zero */ gettimeofday(&now, NULL); seed = (unsigned int)((now.tv_sec + 1) * (now.tv_usec + 1)); srand(seed); input_mode = set_random; break; } case 'h': printf(_("See README for usage info\n")); exit(0); break; default: fprintf(stderr, _("See README for usage info\n")); exit(1); } } if (ac == optind) { printf(_("%s: Kconfig file missing\n"), av[0]); exit(1); } name = av[optind]; conf_parse(name); //zconfdump(stdout); if (sync_kconfig) { if (stat(configname, &tmpstat)) { fprintf(stderr, _("***\n" "*** You have not yet configured!\n" "*** (missing .config file)\n" "***\n" "*** Please run some configurator (e.g. \"make oldconfig\" or\n" "*** \"make menuconfig\" or \"make xconfig\").\n" "***\n")); exit(1); } } switch (input_mode) { case set_default: if (!defconfig_file) defconfig_file = conf_get_default_confname(); if (conf_read(defconfig_file)) { printf(_("***\n" "*** Can't find default configuration \"%s\"!\n" "***\n"), defconfig_file); exit(1); } break; case ask_silent: case ask_all: case ask_new: conf_read(NULL); break; case set_no: case set_mod: case set_yes: case set_random: name = getenv("KCONFIG_ALLCONFIG"); if (name && !stat(name, &tmpstat)) { conf_read_simple(name, S_DEF_USER); break; } switch (input_mode) { case set_no: name = "allno.config"; break; case set_mod: name = "allmod.config"; break; case set_yes: name = "allyes.config"; break; case set_random: name = "allrandom.config"; break; default: break; } if (!stat(name, &tmpstat)) conf_read_simple(name, S_DEF_USER); else if (!stat("all.config", &tmpstat)) conf_read_simple("all.config", S_DEF_USER); break; default: break; } if (sync_kconfig) { if (conf_get_changed()) { name = getenv("KCONFIG_NOSILENTUPDATE"); if (name && *name) { fprintf(stderr, _("\n*** configuration requires explicit update.\n\n")); return 1; } } valid_stdin = isatty(0) && isatty(1) && isatty(2); } switch (input_mode) { case set_no: conf_set_all_new_symbols(def_no); break; case set_yes: conf_set_all_new_symbols(def_yes); break; case set_mod: conf_set_all_new_symbols(def_mod); break; case set_random: conf_set_all_new_symbols(def_random); break; case set_default: conf_set_all_new_symbols(def_default); break; case ask_new: case ask_all: rootEntry = &rootmenu; conf(&rootmenu); input_mode = ask_silent; /* fall through */ case ask_silent: /* Update until a loop caused no more changes */ do { conf_cnt = 0; check_conf(&rootmenu); } while (conf_cnt); break; } if (sync_kconfig) { /* silentoldconfig is used during the build so we shall update autoconf. * All other commands are only used to generate a config. */ if (conf_get_changed() && conf_write(NULL)) { fprintf(stderr, _("\n*** Error during writing of the configuration.\n\n")); exit(1); } if (conf_write_autoconf()) { fprintf(stderr, _("\n*** Error during update of the configuration.\n\n")); return 1; } } else { if (conf_write(NULL)) { fprintf(stderr, _("\n*** Error during writing of the configuration.\n\n")); exit(1); } } return 0; }
static void conf(struct menu *menu) { struct dialog_list_item *active_item = NULL; struct menu *submenu; const char *prompt = menu_get_prompt(menu); struct symbol *sym; char active_entry[40]; int stat, type; unlink("lxdialog.scrltmp"); active_entry[0] = 0; while (1) { indent = 0; child_count = 0; current_menu = menu; cdone(); cinit(); build_conf(menu); if (!child_count) break; if (menu == &rootmenu) { cmake(); cprint_tag(":"); cprint_name("--- "); cmake(); cprint_tag("L"); cprint_name("Load an Alternate Configuration File"); cmake(); cprint_tag("S"); cprint_name("Save Configuration to an Alternate File"); } dialog_clear(); stat = dialog_menu(prompt ? prompt : "Main Menu", menu_instructions, rows, cols, rows - 10, active_entry, item_no, items); if (stat < 0) return; if (stat == 1 || stat == 255) break; active_item = first_sel_item(item_no, items); if (!active_item) continue; active_item->selected = 0; strncpy(active_entry, active_item->tag, sizeof(active_entry)); active_entry[sizeof(active_entry)-1] = 0; type = active_entry[0]; if (!type) continue; sym = NULL; submenu = NULL; if (sscanf(active_entry + 1, "%p", &submenu) == 1) sym = submenu->sym; switch (stat) { case 0: switch (type) { case 'm': if (single_menu_mode) submenu->data = (void *) (long) !submenu->data; else conf(submenu); break; case 't': if (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes) conf_choice(submenu); else if (submenu->prompt->type == P_MENU) conf(submenu); break; case 's': conf_string(submenu); break; case 'L': conf_load(); break; case 'S': conf_save(); break; } break; case 2: if (sym) show_help(submenu); else show_readme(); break; case 3: if (type == 't') { if (sym_set_tristate_value(sym, yes)) break; if (sym_set_tristate_value(sym, mod)) show_textbox(NULL, setmod_text, 6, 74); } break; case 4: if (type == 't') sym_set_tristate_value(sym, no); break; case 5: if (type == 't') sym_set_tristate_value(sym, mod); break; case 6: if (type == 't') sym_toggle_tristate_value(sym); else if (type == 'm') conf(submenu); break; } } }
void TileOpDriver::apply(QString in, vector<Envelope> envelopes, double buffer, QString out) { // create a job pp::Job job; job.setVerbose(Log::getInstance().getLevel() <= Log::Debug); // set the name job.setName("TileOpDriver"); // be nice and don't start the reduce tasks until most of the map tasks are done. job.getConfiguration().setDouble("mapred.reduce.slowstart.completed.maps", 0.98); // set the input/output pp::Hdfs fs; job.setInput(fs.getAbsolutePath(in.toStdString())); job.setOutput(fs.getAbsolutePath(out.toStdString())); if (_op == 0) { throw HootException("You must specify an operation."); } stringstream ss; ObjectOutputStream oos(ss); oos.writeObject(*_op); oos.flush(); LOG_INFO("oos size: " << ss.str().size()); job.getConfiguration().setBytes(TileOpReducer::opKey(), ss.str()); job.getConfiguration().set(TileOpMapper::envelopesKey(), _toString(envelopes)); job.getConfiguration().set(TileOpMapper::replacementsKey(), fs.getAbsolutePath(in.toStdString())); job.getConfiguration().setDouble(TileOpMapper::maxWaySizeKey(), buffer); job.getConfiguration().setDouble(TileOpMapper::bufferKey(), buffer); // read the max ids from in and write them to the configuration MapStats stats; stats.readDir(in); stats.write(job.getConfiguration()); // setup the mapper and reducer classes. job.setMapperClass(TileOpMapper::className()); job.setReducerClass(TileOpReducer::className()); job.setInputFormatClass(PbfInputFormat::className()); job.setRecordReaderClass(PbfRecordReader::className()); job.setRecordWriterClass(PbfRecordWriter::className()); // Adds all libraries in this directory to the job. job.addLibraryDirs(conf().getList("hoot.hadoop.libpath", "${HOOT_HOME}/lib/;${HOOT_HOME}/local/lib/;${HADOOP_HOME}/c++/Linux-amd64-64/lib/;" "${HOOT_HOME}/pretty-pipes/lib/")); LOG_INFO("Hoot home: " << conf().getString("foo", "${HOOT_HOME}")); const std::vector<std::string>& dirs = job.getLibraryDirs(); for (size_t i = 0; i < dirs.size(); i++) { LOG_INFO("lib dir: " << dirs[i]); } job.addFile(ConfPath::search("hoot.json").toStdString()); // if GDAL isn't installed on all nodes, then we'll need to copy over the projection info. QString gdalData = QString(getenv("GDAL_DATA")); if (gdalData != "") { QDir gdalDir(gdalData); if (gdalDir.exists() == false) { LOG_WARN("Could not find GDAL_DIR: " << gdalData); } else { QStringList filters; filters << "*.csv"; QFileInfoList fil = gdalDir.entryInfoList(filters, QDir::Files); for (int i = 0; i < fil.size(); i++) { LOG_INFO("Adding GDAL_DATA file: " << fil[i].absoluteFilePath()); job.addFile(fil[i].absoluteFilePath().toStdString()); } } } // This library will be used to provide mapper/reducer classes and anything else referenced // by the factory. job.addPlugin(getenv("HOOT_HOME") + string("/lib/libHootHadoop.so.1")); // serialize all the configuration settings. job.getConfiguration().set(settingsConfKey().toStdString(), conf().toString().toUtf8().constData()); _addDefaultJobSettings(job); QStringList fileDeps = conf().getList(fileDepsKey(), QStringList()); for (int i = 0; i < fileDeps.size(); i++) { job.addFile(fileDeps[i].toStdString()); } // conflation runs can go for a _long_ time. Setting timeout to 6 hours. job.getConfiguration().setInt("mapred.task.timeout", 6 * 3600 * 1000); // run the job. job.run(); }
static int conf_choice(struct menu *menu) { struct symbol *sym, *def_sym; struct menu *child; int type; bool is_new; sym = menu->sym; type = sym_get_type(sym); is_new = !sym_has_value(sym); if (sym_is_changable(sym)) { conf_sym(menu); sym_calc_value(sym); switch (sym_get_tristate_value(sym)) { case no: return 1; case mod: return 0; case yes: break; } } else { switch (sym_get_tristate_value(sym)) { case no: return 1; case mod: printf("%*s%s\n", indent - 1, "", _(menu_get_prompt(menu))); return 0; case yes: break; } } while (1) { int cnt, def; printf("%*s%s\n", indent - 1, "", _(menu_get_prompt(menu))); def_sym = sym_get_choice_value(sym); cnt = def = 0; line[0] = 0; for (child = menu->list; child; child = child->next) { if (!menu_is_visible(child)) continue; if (!child->sym) { printf("%*c %s\n", indent, '*', _(menu_get_prompt(child))); continue; } cnt++; if (child->sym == def_sym) { def = cnt; printf("%*c", indent, '>'); } else printf("%*c", indent, ' '); printf(" %d. %s", cnt, _(menu_get_prompt(child))); if (child->sym->name) printf(" (%s)", child->sym->name); if (!sym_has_value(child->sym)) printf(_(" (NEW)")); printf("\n"); } printf(_("%*schoice"), indent - 1, ""); if (cnt == 1) { printf("[1]: 1\n"); goto conf_childs; } printf("[1-%d", cnt); if (menu_has_help(menu)) printf("?"); printf("]: "); switch (input_mode) { case ask_new: case ask_silent: if (!is_new) { cnt = def; printf("%d\n", cnt); break; } check_stdin(); case ask_all: fflush(stdout); fgets(line, 128, stdin); strip(line); if (line[0] == '?') { printf("\n%s\n", get_help(menu)); continue; } if (!line[0]) cnt = def; else if (isdigit(line[0])) cnt = atoi(line); else continue; break; default: break; } conf_childs: for (child = menu->list; child; child = child->next) { if (!child->sym || !menu_is_visible(child)) continue; if (!--cnt) break; } if (!child) continue; if (line[strlen(line) - 1] == '?') { printf("\n%s\n", get_help(child)); continue; } sym_set_choice_value(sym, child->sym); for (child = child->list; child; child = child->next) { indent += 2; conf(child); indent -= 2; } return 1; } }
int main(int ac, char **av) { int i = 1; const char *name; struct stat tmpstat; if (ac > i && av[i][0] == '-') { switch (av[i++][1]) { case 'o': input_mode = ask_new; break; case 's': input_mode = ask_silent; valid_stdin = isatty(0); //bbox: && isatty(1) && isatty(2); break; case 'd': input_mode = set_default; break; case 'D': input_mode = set_default; defconfig_file = av[i++]; if (!defconfig_file) { printf(_("%s: No default config file specified\n"), av[0]); exit(1); } break; case 'n': input_mode = set_no; break; case 'm': input_mode = set_mod; break; case 'y': input_mode = set_yes; break; case 'r': input_mode = set_random; srandom(time(NULL)); break; case 'h': case '?': fprintf(stderr, "See README for usage info\n"); exit(0); } } name = av[i]; if (!name) { printf(_("%s: Kconfig file missing\n"), av[0]); } conf_parse(name); //zconfdump(stdout); switch (input_mode) { case set_default: if (!defconfig_file) defconfig_file = conf_get_default_confname(); if (conf_read(defconfig_file)) { printf("***\n" "*** Can't find default configuration \"%s\"!\n" "***\n", defconfig_file); exit(1); } break; case ask_silent: if (stat(".config", &tmpstat)) { printf(_("***\n" "*** You have not yet configured Open Switch Solution!\n" "***\n" "*** Please run some configurator (e.g. \"make oldconfig\" or\n" "*** \"make menuconfig\" or \"make defconfig\").\n" "***\n")); exit(1); } case ask_all: case ask_new: conf_read(NULL); break; case set_no: case set_mod: case set_yes: case set_random: name = getenv("KCONFIG_ALLCONFIG"); if (name && !stat(name, &tmpstat)) { conf_read_simple(name); break; } switch (input_mode) { case set_no: name = "allno.config"; break; case set_mod: name = "allmod.config"; break; case set_yes: name = "allyes.config"; break; case set_random: name = "allrandom.config"; break; default: break; } if (!stat(name, &tmpstat)) conf_read_simple(name); else if (!stat("all.config", &tmpstat)) conf_read_simple("all.config"); break; default: break; } if (input_mode != ask_silent) { rootEntry = &rootmenu; conf(&rootmenu); if (input_mode == ask_all) { input_mode = ask_silent; valid_stdin = 1; } } do { conf_cnt = 0; check_conf(&rootmenu); } while (conf_cnt); if (conf_write(NULL)) { fprintf(stderr, _("\n*** Error during writing of the configuration.\n\n")); return 1; } return 0; }
RemoveTagVisitor::RemoveTagVisitor() { setConfiguration(conf()); }
int main(int argc, char* args[]) { if (argc < 2) { cout << "no input file.\n"; return -1; } test::inner_test::test_conf conf(args[1]); assert(conf.int_val()==-123); assert(conf.bool_val()==false); assert(conf.week_val()==test::inner_test::test_conf::SUN); assert(!conf.has_string_val()); assert(conf.has_real_val()); assert(conf.real_val()==-32134.5643); assert(conf.string_list().size()==3); assert(conf.string_list()[0]=="foo"); assert(conf.string_list()[1]=="bar"); assert(conf.string_list()[2]=="baz"); vector<string> string0_list_val(1,"foo"); assert(conf.set_string0_list(string0_list_val)==false); assert(conf.string0_list().size()==0); vector<int> int1_list_val(5); assert(conf.set_int1_list(int1_list_val)==false); assert(conf.int1_list().size()==1); assert(conf.int1_list()[0]==10); vector<int> int1_list_val2; int1_list_val2.push_back(3); assert(conf.set_int1_list(int1_list_val2)==true); assert(conf.int1_list().size()==1); assert(conf.int1_list()[0]==3); assert(conf.set("int1_list={1}")==true); assert(conf.int1_list().size()==1); assert(conf.int1_list()[0]==1); assert(conf.bool9_list().size()==9); assert(conf.bool9_list()[8]==true); assert(conf.real_llist().size()==5); assert(conf.real_llist()[3].size()==0); assert(conf.real_llist()[4][2]==1323.0); assert(boost::get<1>(conf.stri_list()[1])==-1234); assert(boost::get<0>(conf.rib_tuple())==1.234); assert(boost::get<1>(conf.rib_tuple())==5); assert(boost::get<2>(conf.rib_tuple())==true); assert(boost::get<0>(boost::get<0>(conf.string_tuple()))=="hoge"); assert(boost::get<0>(conf.week_fruits())==test::inner_test::test_conf::MON); assert(boost::get<1>(conf.week_fruits()).size()==4); assert(boost::get<1>(conf.week_fruits())[0]==test::inner_test::test_conf::Apple); assert(!conf.has_int_defval()); assert(!conf.has_int_defval2()); assert(conf.int_defval()==5); assert(conf.int_defval2()==0); assert(conf.bool_defval()==true); assert(conf.bool_defval2()==false); assert(conf.string_defval()=="hello"); assert(conf.string_defval2()==""); assert(conf.real_defval()==1.0123); assert(conf.real_defval2()==0.0); assert(boost::get<0>(conf.rib_tuple_def())==-3.14); assert(boost::get<1>(conf.rib_tuple_def())==5); assert(boost::get<2>(conf.rib_tuple_def())==false); assert(conf.stri_list_def().size()==3); assert(boost::get<0>(conf.stri_list_def()[1])=="hoge"); assert(boost::get<1>(conf.stri_list_def()[2])==1234); time_t t_ = 0; struct tm t = *localtime(&t_); assert(tm_equal(t,conf.date_value())); t.tm_year = 2003-1900; t.tm_mon = 12-1; t.tm_mday = 31; t.tm_hour = 0; t.tm_min = 0; t.tm_sec = 0; assert(tm_equal(t,conf.date_value2())); t.tm_year = 2008-1900; t.tm_mon = 1-1; t.tm_mday = 3; t.tm_hour = 17; t.tm_min = 20; t.tm_sec = 0; assert(tm_equal(t,conf.date_value3())); t.tm_year = 1972-1900; t.tm_mon = 9-1; t.tm_mday = 24; t.tm_hour = 5; t.tm_min = 12; t.tm_sec = 30; assert(tm_equal(t,conf.date_value4())); assert(conf.ipv4_value().s_addr==0); assert(conf.ipv4_value2().s_addr==inet_addr("192.168.0.1")); assert(conf.ipv4_value3().s_addr==inet_addr("4.3.2.1")); struct in6_addr ipv6 = {{{0}}}; assert(ipv6_equal(ipv6,conf.ipv6_value())); inet_pton(AF_INET6, "dead:beaf::1", &ipv6); assert(ipv6_equal(ipv6,conf.ipv6_value2())); inet_pton(AF_INET6, "dead:1234:ffff:ffff:2311:1111:0000:0232", &ipv6); assert(ipv6_equal(ipv6,conf.ipv6_value3())); inet_pton(AF_INET6, "::", &ipv6); assert(ipv6_equal(ipv6,conf.ipv6_value4())); inet_pton(AF_INET6, "::1", &ipv6); assert(ipv6_equal(ipv6,conf.ipv6_value5())); inet_pton(AF_INET6, "1:2:3::", &ipv6); assert(ipv6_equal(ipv6,conf.ipv6_value6())); inet_pton(AF_INET6, "1:2:3:4:5:6:7:8", &ipv6); assert(ipv6_equal(ipv6,conf.ipv6_value7())); // test set method conf.set_int_val(321); assert(conf.int_val()==321); assert(conf.string_val()==""); conf.set_string_val("hoge"); assert(conf.string_val()=="hoge"); assert(conf.set_uint_ranval3(123)==true); assert(conf.uint_ranval3()==123); assert(conf.set_uint_ranval3(11)==false); assert(conf.uint_ranval3()==123); vector<tuple<string,int> > stri_list_def_val; assert(conf.set_stri_list_def(stri_list_def_val)==false); assert(conf.stri_list_def().size()==3); // test general setter assert(conf.set("uint_ranval3 = 200;")==true); assert(conf.uint_ranval3()==200); assert(conf.set("uint_ranval3 = 150; string_val = \"foo\"")==true); assert(conf.uint_ranval3()==150); assert(conf.string_val()=="foo"); assert(conf.set("int_val=1;")==true); assert(conf.int_val()==1); // 範囲外のデータはセットできない assert(conf.set("uint_ranval3 = 0; int_val=-123;")==false); assert(conf.uint_ranval3()==150); assert(conf.int_val()==1); // const項目はsetできない assert(conf.set("ipv4_value=1.2.3.4")==false); assert(conf.ipv4_value().s_addr==0); // default値のチェック assert(conf.int_ranval4()==3); assert(conf.int_ranval5()==0); assert(conf.int_ranval6()==-10); // range_vals: real[32.5~100.3],uint[100 ~ ],int[~-10] = 32.5, 100, -30; assert(boost::get<0>(conf.range_vals())==32.5); assert(boost::get<1>(conf.range_vals())==100); assert(boost::get<2>(conf.range_vals())==-30); assert(conf.set_range_vals(boost::make_tuple(double(0.0),(unsigned int)100,int(-20)))==false); // ranval_list:list[2]<int[-10~10]> { vector<int> ranval_list_val = conf.ranval_list(); assert(ranval_list_val.size()==2); assert(ranval_list_val[0] = 3); assert(ranval_list_val[1] = -4); ranval_list_val[1] = 100; // 配列要素の範囲違反 assert(conf.set_ranval_list(ranval_list_val)==false); } { // 配列の長さが違反 vector<int> ranval_list_val(3); assert(conf.set_ranval_list(ranval_list_val)==false); } conf.dump(cout); return 0; }
shared_ptr<OsmMap> PertyMatchScorer::_combineMapsAndPrepareForConflation( shared_ptr<OsmMap> referenceMap, const QString perturbedMapInputPath) { LOG_DEBUG("Combining the reference and perturbed data into a single file ..."); // QFileInfo fileInfo(perturbedMapInputPath); // QString combinedOutputPath = fileInfo.path() + "/ref-after-combination.osm"; // LOG_DEBUG("saving a debug copy to " << combinedOutputPath << " ..."); shared_ptr<OsmMap> combinedMap(referenceMap); OsmUtils::loadMap(combinedMap, perturbedMapInputPath, false, Status::Unknown2); LOG_VARD(combinedMap->getNodeMap().size()); LOG_VARD(combinedMap->getWays().size()); if (Log::getInstance().getLevel() <= Log::Debug) { TagCountVisitor tagCountVisitor; combinedMap->visitRo(tagCountVisitor); const long numTotalTags = (long)tagCountVisitor.getStat(); LOG_VARD(numTotalTags); } // shared_ptr<OsmMap> combinedMapCopy(combinedMap); // MapProjector::reprojectToWgs84(combinedMapCopy); // OsmUtils::saveMap(combinedMapCopy, combinedOutputPath); // LOG_DEBUG("Preparing the reference data for conflation ..."); // QString combinedOutputPath2 = fileInfo.path() + "/ref-after-prep.osm"; // LOG_DEBUG("saving a debug copy to " << combinedOutputPath2 << " ..."); MatchScoringMapPreparer().prepMap(combinedMap, true); LOG_VARD(combinedMap->getNodeMap().size()); LOG_VARD(combinedMap->getWays().size()); if (Log::getInstance().getLevel() <= Log::Debug) { TagCountVisitor tagCountVisitor; combinedMap->visitRo(tagCountVisitor); const long numTotalTags = (long)tagCountVisitor.getStat(); LOG_VARD(numTotalTags); } // shared_ptr<OsmMap> combinedMapCopy2(combinedMap); // MapProjector::reprojectToWgs84(combinedMapCopy2); // OsmUtils::saveMap(combinedMapCopy2, combinedOutputPath2); if (_applyRubberSheet) { // LOG_DEBUG("Applying rubber sheet to pre-conflated data to move perturbed data towards " << // "reference data ..."); // QString combinedOutputPath3 = fileInfo.path() + "/ref-after-rubber-sheet.osm"; // LOG_DEBUG("saving a debug copy to " << combinedOutputPath3 << " ..."); //move Unknown2 toward Unknown1 conf().set(RubberSheet::refKey(), true); shared_ptr<RubberSheet> rubberSheetOp(new RubberSheet()); rubberSheetOp->apply(combinedMap); LOG_VARD(combinedMap->getNodeMap().size()); LOG_VARD(combinedMap->getWays().size()); if (Log::getInstance().getLevel() <= Log::Debug) { TagCountVisitor tagCountVisitor; combinedMap->visitRo(tagCountVisitor); const long numTotalTags = (long)tagCountVisitor.getStat(); LOG_VARD(numTotalTags); } // shared_ptr<OsmMap> combinedMapCopy3(combinedMapCopy2); // MapProjector::reprojectToWgs84(combinedMapCopy3); // OsmUtils::saveMap(combinedMapCopy3, combinedOutputPath3); } return combinedMap; }
HighwaySnapMergerCreator::HighwaySnapMergerCreator() { setConfiguration(conf()); }
int main(int argc, char *argv[]) { if (argc >= 4) { std::vector<std::string> texture; texture.push_back("wall"); texture.push_back("snakepart-left"); texture.push_back("snakepart-right"); texture.push_back("snakepart-top"); texture.push_back("snakepart-bottom"); texture.push_back("snakepart-queue-left"); texture.push_back("snakepart-queue-right"); texture.push_back("snakepart-queue-top"); texture.push_back("snakepart-queue-bottom"); texture.push_back("snake-left"); texture.push_back("snake-right"); texture.push_back("snake-top"); texture.push_back("snake-bottom"); texture.push_back("snakepart-top-right"); texture.push_back("snakepart-right-top"); texture.push_back("snakepart-top-left"); texture.push_back("snakepart-left-top"); texture.push_back("snake"); texture.push_back("floor"); texture.push_back("food"); try { Config conf(10,10, texture, "./ressource/", 1, 1, 500000, argv[3]); Map map(&conf, (argc >= 5 ? argv[4] : "./ressource/map/map-1.conf")); Engine eng(argv[3]); eng.init(conf); eng.run(map); } catch (LibraryLoadError &e) { std::cerr << "Library Error : " << e.what() << std::endl; } catch (ConfigLoadError &e) { std::cerr << "Configuration Error : " << e.what() << std::endl; } catch (TextureError &e) { std::cerr << "Texture Error : " << e.what() << std::endl; } catch (...) { std::cerr << "Unexcepted Error occurred" << std::endl; } return (0); } std::cout << "Usage: " << argv[0] << " width height lib.so" << std::endl; return (1); }
int main(int argc, char **argv) { /* Parse command line arguments. */ int c = 0, li = 0; int daemonize = 0; const char *config_fn = CONF_DEFAULT_FILE; const char *config_db = NULL; const char *daemon_root = "/"; /* Long options. */ struct option opts[] = { {"config", required_argument, 0, 'c' }, {"confdb", required_argument, 0, 'C' }, {"daemonize", optional_argument, 0, 'd'}, {"version", no_argument, 0, 'V'}, {"help", no_argument, 0, 'h'}, {0, 0, 0, 0} }; while ((c = getopt_long(argc, argv, "c:C:dVh", opts, &li)) != -1) { switch (c) { case 'c': config_fn = optarg; break; case 'C': config_db = optarg; break; case 'd': daemonize = 1; if (optarg) { daemon_root = optarg; } break; case 'V': printf("%s, version %s\n", "Knot DNS", PACKAGE_VERSION); return EXIT_SUCCESS; case 'h': case '?': help(); return EXIT_SUCCESS; default: help(); return EXIT_FAILURE; } } /* Check for non-option parameters. */ if (argc - optind > 0) { help(); return EXIT_FAILURE; } /* Now check if we want to daemonize. */ if (daemonize) { if (make_daemon(1, 0) != 0) { fprintf(stderr, "Daemonization failed, shutting down...\n"); return EXIT_FAILURE; } } /* Clear file creation mask. */ umask(0); /* Setup base signal handling. */ setup_signals(); /* Initialize cryptographic backend. */ dnssec_crypto_init(); atexit(dnssec_crypto_cleanup); /* Initialize pseudorandom number generator. */ srand(time(NULL)); /* POSIX 1003.1e capabilities. */ setup_capabilities(); /* Default logging to std out/err. */ log_init(); /* Open configuration. */ conf_t *new_conf = NULL; if (config_db == NULL) { int ret = conf_new(&new_conf, conf_scheme, NULL); if (ret != KNOT_EOK) { log_fatal("failed to initialize configuration database " "(%s)", knot_strerror(ret)); log_close(); return EXIT_FAILURE; } /* Import the configuration file. */ ret = conf_import(new_conf, config_fn, true); if (ret != KNOT_EOK) { log_fatal("failed to load configuration file (%s)", knot_strerror(ret)); conf_free(new_conf, false); log_close(); return EXIT_FAILURE; } new_conf->filename = strdup(config_fn); } else { /* Open configuration database. */ int ret = conf_new(&new_conf, conf_scheme, config_db); if (ret != KNOT_EOK) { log_fatal("failed to open configuration database '%s' " "(%s)", config_db, knot_strerror(ret)); log_close(); return EXIT_FAILURE; } } /* Run post-open config operations. */ int res = conf_post_open(new_conf); if (res != KNOT_EOK) { log_fatal("failed to use configuration (%s)", knot_strerror(res)); conf_free(new_conf, false); log_close(); return EXIT_FAILURE; } conf_update(new_conf); /* Initialize logging subsystem. */ log_reconfigure(conf(), NULL); /* Initialize server. */ server_t server; res = server_init(&server, conf_bg_threads(conf())); if (res != KNOT_EOK) { log_fatal("failed to initialize server (%s)", knot_strerror(res)); conf_free(conf(), false); log_close(); return EXIT_FAILURE; } /* Reconfigure server interfaces. * @note This MUST be done before we drop privileges. */ server_reconfigure(conf(), &server); log_info("configured %zu zones", conf_id_count(conf(), C_ZONE)); /* Alter privileges. */ int uid, gid; if (conf_user(conf(), &uid, &gid) != KNOT_EOK || log_update_privileges(uid, gid) != KNOT_EOK || proc_update_privileges(uid, gid) != KNOT_EOK) { log_fatal("failed to drop privileges"); server_deinit(&server); conf_free(conf(), false); log_close(); return EXIT_FAILURE; } /* Check and create PID file. */ long pid = (long)getpid(); char *pidfile = NULL; if (daemonize) { pidfile = pid_check_and_create(); if (pidfile == NULL) { server_deinit(&server); conf_free(conf(), false); log_close(); return EXIT_FAILURE; } log_info("PID stored in '%s'", pidfile); if (chdir(daemon_root) != 0) { log_warning("failed to change working directory to %s", daemon_root); } else { log_info("changed directory to %s", daemon_root); } } /* Now we're going multithreaded. */ rcu_register_thread(); /* Populate zone database. */ log_info("loading zones"); server_update_zones(conf(), &server); /* Check number of loaded zones. */ if (knot_zonedb_size(server.zone_db) == 0) { log_warning("no zones loaded"); } /* Start it up. */ log_info("starting server"); conf_val_t async_val = conf_get(conf(), C_SRV, C_ASYNC_START); res = server_start(&server, conf_bool(&async_val)); if (res != KNOT_EOK) { log_fatal("failed to start server (%s)", knot_strerror(res)); server_deinit(&server); rcu_unregister_thread(); pid_cleanup(pidfile); log_close(); conf_free(conf(), false); return EXIT_FAILURE; } if (daemonize) { log_info("server started as a daemon, PID %ld", pid); } else { log_info("server started in the foreground, PID %ld", pid); init_signal_started(); } /* Start the event loop. */ event_loop(&server); /* Teardown server and configuration. */ server_deinit(&server); /* Free configuration. */ conf_free(conf(), false); /* Unhook from RCU. */ rcu_unregister_thread(); /* Cleanup PID file. */ pid_cleanup(pidfile); log_info("shutting down"); log_close(); return EXIT_SUCCESS; }
/** * Gmsh file contains a list of nodes and their coordinates, along with * a list of elements and those nodes which define them. We read in and * store the list of nodes in #m_node and store the list of elements in * #m_element. Each new element is supplied with a list of entries from * #m_node which defines the element. Finally some mesh statistics are * printed. * * @param pFilename Filename of Gmsh file to read. */ void InputVtk::Process() { if (m_mesh->m_verbose) { cout << "InputVtk: Start reading file..." << endl; } vtkPolyDataReader *vtkMeshReader = vtkPolyDataReader::New(); vtkMeshReader->SetFileName(m_config["infile"].as<string>().c_str()); vtkMeshReader->Update(); vtkPolyData *vtkMesh = vtkMeshReader->GetOutput(); vtkPoints *vtkPoints = vtkMesh->GetPoints(); const int numCellTypes = 3; vtkCellArray* vtkCells[numCellTypes]; LibUtilities::ShapeType vtkCellTypes[numCellTypes]; int vtkNumPoints[numCellTypes]; vtkCells[0] = vtkMesh->GetPolys(); vtkCells[1] = vtkMesh->GetStrips(); vtkCells[2] = vtkMesh->GetLines(); vtkCellTypes[0] = LibUtilities::eTriangle; vtkCellTypes[1] = LibUtilities::eTriangle; vtkCellTypes[2] = LibUtilities::eSegment; vtkNumPoints[0] = 3; vtkNumPoints[1] = 3; vtkNumPoints[2] = 2; vtkIdType npts; vtkIdType *pts = 0; double p[3]; for (int i = 0; i < vtkPoints->GetNumberOfPoints(); ++i) { vtkPoints->GetPoint(i, p); if ((p[0] * p[0]) > 0.000001 && m_mesh->m_spaceDim < 1) { m_mesh->m_spaceDim = 1; } if ((p[1] * p[1]) > 0.000001 && m_mesh->m_spaceDim < 2) { m_mesh->m_spaceDim = 2; } if ((p[2] * p[2]) > 0.000001 && m_mesh->m_spaceDim < 3) { m_mesh->m_spaceDim = 3; } m_mesh->m_node.push_back(boost::shared_ptr<Node>(new Node(i, p[0], p[1], p[2]))); } for (int c = 0; c < numCellTypes; ++c) { vtkCells[c]->InitTraversal(); for (int i = 0; vtkCells[c]->GetNextCell(npts, pts); ++i) { for (int j = 0; j < npts - vtkNumPoints[c] + 1; ++j) { // Create element tags vector<int> tags; tags.push_back(0); // composite tags.push_back(vtkCellTypes[c]); // element type // Read element node list vector<NodeSharedPtr> nodeList; for (int k = j; k < j + vtkNumPoints[c]; ++k) { nodeList.push_back(m_mesh->m_node[pts[k]]); } // Create element ElmtConfig conf(vtkCellTypes[c],1,false,false); ElementSharedPtr E = GetElementFactory(). CreateInstance(vtkCellTypes[c], conf,nodeList,tags); // Determine mesh expansion dimension if (E->GetDim() > m_mesh->m_expDim) { m_mesh->m_expDim = E->GetDim(); } m_mesh->m_element[E->GetDim()].push_back(E); } } } ProcessVertices(); ProcessEdges(); ProcessFaces(); ProcessElements(); ProcessComposites(); }
void setUp() { conf().set(ConfigOptions::getStatsTranslateScriptKey(), "${HOOT_HOME}/translations/HootTest.js"); }
int main (int argc, char ** argv) { if(argc <= 2){ throw std::runtime_error("No parameters given. Usage: " + usage(argv[0])); } //Parse all parameters std::map<std::string, std::string> parameter_name_value_map; bool parse_succeeded = Utils::parseParamters(argc, argv, parameter_name_value_map); if(!parse_succeeded){ throw std::runtime_error("Mangled command line arguments. " + usage(argv[0])); } //check if we found a config file. if(parameter_name_value_map.count("conf") == 0){ throw std::runtime_error("No config file was given" + usage(argv[0])); } std::string config_file = parameter_name_value_map["conf"]; parameter_name_value_map.erase("conf"); Utils::Config conf(config_file, parameter_name_value_map); Utils::RgbLabelConversion label_converter(conf.getJsonValueAsString(conf.get<std::string>("color_coding_key"))); Utils::DataLoader dl(conf); libf::DataStorage::ptr d = dl.loadAllTrainingData("train_images", conf.get<bool>("vccs_rectification")); std::map<int,int> dist; for(int a = 0; a < d->getSize(); a++){ dist[d->getClassLabel(a)]++; } for(auto b : dist){ std::cout <<b.first << " "<< b.second << std::endl; } std::cout << d->getSize() << std::endl; libf::RandomForestLearner<libf::DecisionTreeLearner> forestLearner; forestLearner.getTreeLearner().setNumFeatures(ceil(sqrt(d->getDimensionality()))); forestLearner.getTreeLearner().setMinSplitExamples(conf.get<int>("min_split_samples")); forestLearner.getTreeLearner().setNumBootstrapExamples(d->getSize()); forestLearner.getTreeLearner().setUseBootstrap(true); //forestLearner.getTreeLearner().setUseClassFrequencies(true); forestLearner.getTreeLearner().setMaxDepth(conf.get<int>("max_depth")); forestLearner.setNumTrees(conf.get<int>("number_trees")); forestLearner.setNumThreads(8); auto state = forestLearner.createState(); libf::ConsoleGUI<decltype(state)> gui(state); auto forest = forestLearner.learn(d, state); std::filebuf fb; if (fb.open (conf.getPath("model_path"),std::ios::out)){ std::ostream os(&fb); forest->write(os); } fb.close(); gui.join(); return 0; }
static void conf(struct menu *menu) { struct menu *submenu; const char *prompt = menu_get_prompt(menu); struct symbol *sym; char active_entry[40]; int stat, type, i; unlink("lxdialog.scrltmp"); active_entry[0] = 0; while (1) { cprint_init(); cprint("--title"); cprint("%s", prompt ? prompt : _("Main Menu")); cprint("--menu"); cprint(_(menu_instructions)); cprint("%d", rows); cprint("%d", cols); cprint("%d", rows - 10); cprint("%s", active_entry); current_menu = menu; build_conf(menu); if (!child_count) break; if (menu == &rootmenu) { cprint(":"); cprint("--- "); cprint("L"); cprint(_(" Load an Alternate Configuration File")); cprint("S"); cprint(_(" Save Configuration to an Alternate File")); } stat = exec_conf(); if (stat < 0) continue; if (stat == 1 || stat == 255) break; type = input_buf[0]; if (!type) continue; for (i = 0; input_buf[i] && !isspace(input_buf[i]); i++) ; if (i >= sizeof(active_entry)) i = sizeof(active_entry) - 1; input_buf[i] = 0; strcpy(active_entry, input_buf); sym = NULL; submenu = NULL; if (sscanf(input_buf + 1, "%p", &submenu) == 1) sym = submenu->sym; switch (stat) { case 0: switch (type) { case 'm': if (single_menu_mode) submenu->data = (void *) (long) !submenu->data; else conf(submenu); break; case 't': if (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes) conf_choice(submenu); else if (submenu->prompt->type == P_MENU) conf(submenu); break; case 's': conf_string(submenu); break; case 'L': conf_load(); break; case 'S': conf_save(); break; } break; case 2: if (sym) show_help(submenu); else show_helptext("README", _(mconf_readme)); break; case 3: if (type == 't') { if (sym_set_tristate_value(sym, yes)) break; if (sym_set_tristate_value(sym, mod)) show_textbox(NULL, setmod_text, 6, 74); } break; case 4: if (type == 't') sym_set_tristate_value(sym, no); break; case 5: if (type == 't') sym_set_tristate_value(sym, mod); break; case 6: if (type == 't') sym_toggle_tristate_value(sym); else if (type == 'm') conf(submenu); break; case 7: search_conf(); break; } } }
SearchRadiusCalculator::SearchRadiusCalculator() { setConfiguration(conf()); }
static int conf_choice(struct menu *menu) { struct symbol *sym, *def_sym; struct menu *cmenu, *def_menu; const char *help; int type, len; bool is_new; sym = menu->sym; type = sym_get_type(sym); is_new = !sym_has_value(sym); if (sym_is_changable(sym)) { conf_sym(menu); sym_calc_value(sym); switch (sym_get_tristate_value(sym)) { case no: return 1; case mod: return 0; case yes: break; } } else { sym->def = sym->curr; if (S_TRI(sym->curr) == mod) { printf("%*s%s\n", indent - 1, "", menu_get_prompt(menu)); return 0; } } while (1) { printf("%*s%s ", indent - 1, "", menu_get_prompt(menu)); def_sym = sym_get_choice_value(sym); def_menu = NULL; for (cmenu = menu->list; cmenu; cmenu = cmenu->next) { if (!menu_is_visible(cmenu)) continue; printo(menu_get_prompt(cmenu)); if (cmenu->sym == def_sym) def_menu = cmenu; } printo(NULL); if (def_menu) printf("[%s] ", menu_get_prompt(def_menu)); else { printf("\n"); return 1; } switch (input_mode) { case ask_new: case ask_silent: case ask_all: if (is_new) sym->flags |= SYMBOL_NEW; conf_askvalue(sym, menu_get_prompt(def_menu)); strip(line); break; default: line[0] = 0; printf("\n"); } if (line[0] == '?' && !line[1]) { help = nohelp_text; if (menu->sym->help) help = menu->sym->help; printf("\n%s\n", help); continue; } if (line[0]) { len = strlen(line); line[len] = 0; def_menu = NULL; for (cmenu = menu->list; cmenu; cmenu = cmenu->next) { if (!cmenu->sym || !menu_is_visible(cmenu)) continue; if (!strncasecmp(line, menu_get_prompt(cmenu), len)) { def_menu = cmenu; break; } } } if (def_menu) { sym_set_choice_value(sym, def_menu->sym); if (def_menu->list) { indent += 2; conf(def_menu->list); indent -= 2; } return 1; } } }
void labelprint_set_dialog::test_labelprint() { QSettings conf(CommonHeader::com_ini_filepath, QSettings::IniFormat); QString baudrate_value = ui->comboBox_labelprint_baudrate->currentText(); QString printcount = "1"; QString printtype = ui->comboBox_labelprint_printtype->currentText(); QString font_key = ui->comboBox_labelprint_font->currentText(); QString onebartype_key = ui->comboBox_labelprint_onebartype->currentText(); QString printpathtype = ui->comboBox_labelprint_printpathtype->currentText(); QString printpath = ui->comboBox_labelprint_printpath->currentText(); bool smartprint=conf.value("label_print/smartprint", true).toBool(); int wide_width=ui->spinBox_wide->value(); int narrow_width=ui->spinBox_narrow->value(); //! 获取打印接口类型; 并且打开打印机 Printer_POS_Virtual *toprinter=0; toprinter=CommonHeader::get_variantprinter(printpath,CommonHeader::creat_baudrates().key(baudrate_value)); if(toprinter==0){ uinormal_message::warning(this, tr("标价签:"), tr("标价签错误:")+"no printer is selected!"); return; } if(!toprinter->tryOpen(printpath)){ uinormal_message::warning(this, tr("标价签:"), tr("标价签错误:")+toprinter->lastError()); return; } //! 开始执行 QString test_text = ui->lineEdit_labelprint_test_text->text(); QString test_barcode = ui->lineEdit_labelprint_test_barcode->text(); switch(CommonHeader::creat_printtypes().indexOf(printtype)){ case 0://! POSTEK Q8/200 测试通过 字体随意 串口成功9600 { Printer_POSTEK printer; QString onebartype = Printer_POSTEK::oneBarType_of_POSTEK().value(onebartype_key); QString font = Printer_POSTEK::textfont_of_POSTEK().value(font_key); if(font.isEmpty()) font = font_key; //若是没有在原字体里找到,则是新定义字体 QString ins; ins += printer.drawText(test_text, 20, 20,font,Printer_POSTEK::ROTATE_0); ins += printer.drawOneCode(test_barcode,20,100,onebartype,20, Printer_POSTEK::ROTATE_0, wide_width, narrow_width); toprinter->write(printer.toPrint(ins, printcount.toInt(),248,40)); } break; case 1://! TSC TTP-244 PLUS 测试通过 字体FONT001 串口成功9600 提示: toprint的高度不能为0,会认为时无限大 { printer_TSC_TTP_244_PLUS printer; QString onebartype = printer_TSC_TTP_244_PLUS::oneBarType_of_TSC().value(onebartype_key); QString font = printer_TSC_TTP_244_PLUS::textfont_of_TSC().value(font_key); if(font.isEmpty()) font = font_key; //若是没有在原字体里找到,则是新定义字体 QString ins; ins += printer.drawText(test_text, 20, 20,font); ins += printer.drawOneCode(test_barcode,20,100,onebartype,41, printer_TSC_TTP_244_PLUS::ROTATE_0, wide_width, narrow_width); toprinter->write(printer.toPrint(ins, printcount.toInt(),"30",0,"40")); } break; case 2://! SC2100(商超专用)测试通过 无串口 { /*由于flash大小有限,需要外置sd卡才可以打印中文,这儿暂时不做*/ Printer_ARGOX_PPLA printer; QString onebartype = Printer_ARGOX_PPLA::oneBarType_of_PPLA().value(onebartype_key); QString font = Printer_ARGOX_PPLA::textfont_of_PPLA().value(font_key); if(font.isEmpty()) font = font_key; //若是没有在原字体里找到,则是新定义字体 QString ins; ins += printer.drawText(test_text, 20, 20,font); ins += printer.drawOneCode(test_barcode,20,100,onebartype,41, Printer_ARGOX_PPLA::ROTATE_0, wide_width, narrow_width); toprinter->write(printer.toPrint(ins, printcount.toInt())); } break; case 3://! ARGOX CP-2140 字体966 串口打印失败 9600 无效 { Printer_ARGOX_PPLB printer; QString onebartype = Printer_ARGOX_PPLB::oneBarType_of_PPLB().value(onebartype_key); QString font = Printer_ARGOX_PPLB::textfont_of_PPLB().value(font_key); if(font.isEmpty()) font = font_key; //若是没有在原字体里找到,则是新定义字体 QString ins; ins += printer.drawText(test_text, 20, 20,font); ins += printer.drawOneCode(test_barcode,20,100,onebartype,41, Printer_ARGOX_PPLB::ROTATE_0, wide_width, narrow_width); toprinter->write(printer.toPrint(ins, printcount.toInt())); } break; case 4://! 佳博GP-3120TN 测试通过 字体FONT001 串口成功9600 提示: toprint的高度不能为0,会认为时无限大 case 5:// 佳博GP-3150TIN { Printer_GAINSCHA printer; QString onebartype = Printer_GAINSCHA::oneBarType_of_GAINSCHA().value(onebartype_key); QString font = Printer_GAINSCHA::textfont_of_GAINSCHA().value(font_key); if(font.isEmpty()) font = font_key; //若是没有在原字体里找到,则是新定义字体 QString ins; QString height=smartprint?"0":"30"; ins += printer.drawText(test_text, 20, 20,font); ins += printer.drawOneCode(test_barcode,20,100,onebartype); ins += printer.drawOneCode(test_barcode,20,100,onebartype,41, Printer_GAINSCHA::ROTATE_0, wide_width, narrow_width); toprinter->write(printer.toPrint(ins, printcount.toInt(),height,0,QString::number(40))); } break; case 6://佳博GP-2120TF { Printer_GAINSCHA_2120TF printer; QString onebartype = Printer_GAINSCHA_2120TF::oneBarType_of_GAINSCHA().value(onebartype_key); QString font = Printer_GAINSCHA_2120TF::textfont_of_GAINSCHA().value(font_key); if(font.isEmpty()) font = font_key; //若是没有在原字体里找到,则是新定义字体 QString ins; float height=smartprint?0:(30*1.0/25.4); float width=40*1.0/25.4; ins += printer.drawText(test_text, 20, 20,font); ins += printer.drawOneCode(test_barcode,20,100,onebartype); ins += printer.drawOneCode(test_barcode,20,100,onebartype,41, Printer_GAINSCHA_2120TF::ROTATE_0, wide_width, narrow_width); toprinter->write(printer.toPrint(ins, printcount.toInt(),height,0,width)); } break; } toprinter->close(); delete toprinter; }
int main(int ac, char **av) { const char *name; struct stat tmpstat; if (ac > 1 && av[1][0] == '-') { switch (av[1][1]) { case 'o': input_mode = ask_new; break; case 's': input_mode = ask_silent; valid_stdin = isatty(0) && isatty(1) && isatty(2); break; case 'd': input_mode = set_default; break; case 'n': input_mode = set_no; break; case 'm': input_mode = set_mod; break; case 'y': input_mode = set_yes; break; case 'r': input_mode = set_random; srandom(time(NULL)); break; case 'x': return mconf_main(ac-1, av + 1); case 'h': case '?': printf("%s [-o|-s] config\n", av[0]); exit(0); } name = av[2]; } else name = av[1]; conf_parse(name); //zconfdump(stdout); switch (input_mode) { case set_default: name = conf_get_default_confname(); if (conf_read(name)) { printf("***\n" "*** Can't find default configuration \"%s\"!\n" "***\n", name); exit(1); } break; case ask_silent: if (stat(".config", &tmpstat)) { printf("***\n" "*** You have not yet configured your kernel!\n" "***\n" "*** Please run some configurator (e.g. \"make oldconfig\" or\n" "*** \"make menuconfig\" or \"make xconfig\").\n" "***\n"); exit(1); } case ask_all: case ask_new: conf_read(NULL); break; default: break; } if (input_mode != ask_silent) { rootEntry = &rootmenu; conf(&rootmenu); if (input_mode == ask_all) { input_mode = ask_silent; valid_stdin = 1; } } do { conf_cnt = 0; check_conf(&rootmenu); } while (conf_cnt); conf_write(NULL); return 0; }
Path findProjectRoot(const Path &path, ProjectRootMode mode) { if (!path.isAbsolute()) error() << "GOT BAD PATH" << path; assert(path.isAbsolute()); const Map<String, String> config = rtagsConfig(path); { const Path project = config.value("project"); if (!project.isEmpty() && project.isDir()) return project.ensureTrailingSlash(); } static const Path home = Path::home(); if (mode == SourceRoot) { const Entry before[] = { { "GTAGS", 0 }, { "CMakeLists.txt", 0 }, { "configure", 0 }, { ".git", 0 }, { ".svn", 0 }, { "*.pro", Wildcard }, { "scons.1", 0 }, { "*.scons", Wildcard }, { "SConstruct", 0 }, { "autogen.*", Wildcard }, { "GNUMakefile*", Wildcard }, { "INSTALL*", Wildcard }, { "README*", Wildcard }, { "compile_commands.json", 0 }, { 0, 0 } }; { const Path ret = checkEntries(before, path, home); if (!ret.isEmpty()) return ret; } } { const Path configStatus = findAncestor(path, "config.status", 0); if (!configStatus.isEmpty()) { if (mode == BuildRoot) return configStatus; FILE *f = fopen((configStatus + "config.status").constData(), "r"); Path ret; if (f) { char line[1024]; enum { MaxLines = 10 }; for (int i=0; i<MaxLines; ++i) { int r = Rct::readLine(f, line, sizeof(line)); if (r == -1) break; char *configure = strstr(line, "/configure "); if (configure) { char *end = configure + 10; while (--configure >= line) { Path conf(configure, end - configure); if (!conf.isAbsolute()) conf.resolve(); if (conf.isFile()) { ret = conf.parentDir(); if (ret == home) ret.clear(); break; } } } if (!ret.isEmpty()) break; } fclose(f); if (!ret.isEmpty()) return ret; } } } { const Path cmakeCache = findAncestor(path, "CMakeCache.txt", 0); if (!cmakeCache.isEmpty()) { if (mode == BuildRoot) return cmakeCache; FILE *f = fopen((cmakeCache + "Makefile").constData(), "r"); bool makefile = true; if (!f) { f = fopen((cmakeCache + "build.ninja").constData(), "r"); makefile = false; } if (f) { Path ret; char line[1024]; enum { MaxLines = 256 }; for (int i=0; i<MaxLines; ++i) { int r = Rct::readLine(f, line, sizeof(line)); if (r == -1) { break; } if (makefile) { if (!strncmp(line, "CMAKE_SOURCE_DIR", 16)) { char *dir = line + 16; while (*dir && (*dir == ' ' || *dir == '=')) ++dir; if (dir != home) { ret = dir; ret += '/'; if (!Path(ret + "CMakeLists.txt").isFile()) ret.clear(); } break; } } else if (!strncmp(line, "# Write statements declared in CMakeLists.txt:", 46)) { r = Rct::readLine(f, line, sizeof(line)); ++i; if (r != -1) { ret = line + 2; if (ret.exists()) { ret = ret.parentDir(); } else { ret.clear(); break; } } } } fclose(f); if (!ret.isEmpty()) return ret; } } } const Entry after[] = { { "build.ninja", 0 }, { "Makefile*", Wildcard }, { 0, 0 } }; { const Path ret = checkEntries(after, path, home); if (!ret.isEmpty()) return ret; } if (mode == BuildRoot) return findProjectRoot(path, SourceRoot); return Path(); }
int main(int argc, char **argv) { int arg, refresh_interval, i; struct timeval t1, t2; time_t elapsed_time; first_run = 1; refresh_interval = 1000; while((arg = getopt(argc, argv, "t:h"))!=-1) { switch(arg) { case 't': if((sscanf(optarg, "%d", &refresh_interval))) refresh_interval = refresh_interval*1000; else { fprintf(stderr, "Update interval must be an integer value\n"); print_usage(1); return 1; } break; case 'h': print_usage(0); return 0; break; case '?': if(isprint(optopt)) { print_usage(1); return 1; } else printf("Unknown error parsing command line arguments: 0x%08x\n", optopt); break; default: break; } } for(i=optind; i<argc; i++) printf("Useless command line argument: %s\n", argv[i]); printf("{\"version\":1}\n"); printf("[[],\n"); conf(); while(1) { gettimeofday(&t1, NULL); fflush(stdout); printf("[\n"); update(); printf("{\"full_text\":\"\"}"); printf("],\n"); gettimeofday(&t2, NULL); elapsed_time = ((t2.tv_sec-t1.tv_sec)*1000)+((t2.tv_usec-t1.tv_usec)/1000); if(elapsed_time<refresh_interval) usleep((useconds_t)(refresh_interval-elapsed_time)*1000); } return 0; }
/** * Load and parse xml from path. Initialize XmlConf member variables from xml. * @param path to use for initializing conf */ void digidoc::XmlConf::init(const std::string& path) throw(IOException) { pkcs12Disable = false; DEBUG("digidoc::XmlConf::init(%s)", path.c_str()); try { std::auto_ptr< ::Configuration > conf( configuration (path, xml_schema::Flags::dont_initialize)); Configuration::ParamSequence paramSeq = conf->param(); for( Configuration::ParamSequence::const_iterator it = paramSeq.begin(); it != paramSeq.end(); it++) { if(DIGEST_URI.compare(it->name()) == 0) { digestUri = *it; } else if(MANIFEST_XSD_PATH.compare(it->name()) == 0) { manifestXsdPath = *it; } else if(XADES_XSD_PATH.compare(it->name()) == 0) { xadesXsdPath = *it; } else if(DSIG_XSD_PATH.compare(it->name()) == 0) { dsigXsdPath = *it; } else if(PKCS11_DRIVER_PATH.compare(it->name()) == 0) { pkcs11DriverPath = *it; } else if(CERT_STORE_PATH.compare(it->name()) == 0) { certStorePath = *it; } else if(PROXY_HOST.compare(it->name()) == 0) { proxyHost = *it; } else if(PROXY_PORT.compare(it->name()) == 0) { proxyPort = *it; } else if(PROXY_USER.compare(it->name()) == 0) { proxyUser = *it; } else if(PROXY_PASS.compare(it->name()) == 0) { proxyPass = *it; } else if(PKCS12_CERT.compare(it->name()) == 0) { pkcs12Cert = *it; } else if(PKCS12_PASS.compare(it->name()) == 0) { pkcs12Pass = *it; } else if(PKCS12_DISABLE.compare(it->name()) == 0) { pkcs12Disable = (*it).compare("true") == 0; } else { WARN("Unknown configuration parameter %s", it->name().c_str()); } } std::string conf_fullpath = getDefaultConfDir(); if( !conf_fullpath.empty() ) conf_fullpath += "/"; Configuration::OcspSequence ocspSeq = conf->ocsp(); for( Configuration::OcspSequence::const_iterator it = ocspSeq.begin(); it != ocspSeq.end(); ++it) { OCSPConf o; o.issuer = it->issuer(); o.url = it->url(); o.cert = it->cert(); o.cert.insert(0, conf_fullpath); ocsp.push_back(o); } } catch(const xml_schema::Exception& e) { std::ostringstream oss; oss << e; THROW_IOEXCEPTION("Failed to parse configuration: %s", oss.str().c_str()); } }
static void conf(struct menu *menu) { struct menu *submenu; const char *prompt = menu_get_prompt(menu); struct symbol *sym; struct menu *active_menu = NULL; int res; int s_scroll = 0; while (1) { item_reset(); current_menu = menu; build_conf(menu); if (!child_count) break; if (menu == &rootmenu) { item_make("--- "); item_set_tag(':'); item_make(_(" Load an Alternate Configuration File")); item_set_tag('L'); item_make(_(" Save an Alternate Configuration File")); item_set_tag('S'); } dialog_clear(); res = dialog_menu(prompt ? _(prompt) : _("Main Menu"), _(menu_instructions), active_menu, &s_scroll); if (res == 1 || res == KEY_ESC || res == -ERRDISPLAYTOOSMALL) break; if (!item_activate_selected()) continue; if (!item_tag()) continue; submenu = item_data(); active_menu = item_data(); if (submenu) sym = submenu->sym; else sym = NULL; switch (res) { case 0: switch (item_tag()) { case 'm': if (single_menu_mode) submenu->data = (void *) (long) !submenu->data; else conf(submenu); break; case 't': if (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes) conf_choice(submenu); else if (submenu->prompt->type == P_MENU) conf(submenu); break; case 's': conf_string(submenu); break; case 'L': conf_load(); break; case 'S': conf_save(); break; } break; case 2: if (sym) show_help(submenu); else show_helptext(_("README"), _(mconf_readme)); break; case 3: if (item_is_tag('t')) { if (sym_set_tristate_value(sym, yes)) break; if (sym_set_tristate_value(sym, mod)) show_textbox(NULL, setmod_text, 6, 74); } break; case 4: if (item_is_tag('t')) sym_set_tristate_value(sym, no); break; case 5: if (item_is_tag('t')) sym_set_tristate_value(sym, mod); break; case 6: if (item_is_tag('t')) sym_toggle_tristate_value(sym); else if (item_is_tag('m')) conf(submenu); break; case 7: search_conf(); break; case 8: show_all_options = !show_all_options; break; } } }
static void conf(struct menu *menu) { struct symbol *sym; struct property *prop; struct menu *child; if (!menu_is_visible(menu)) return; sym = menu->sym; prop = menu->prompt; if (prop) { const char *prompt; switch (prop->type) { case P_MENU: if (input_mode == ask_silent && rootEntry != menu) { check_conf(menu); return; } case P_COMMENT: prompt = menu_get_prompt(menu); if (prompt) printf("%*c\n%*c %s\n%*c\n", indent, '*', indent, '*', _(prompt), indent, '*'); default: ; } } if (!sym) goto conf_childs; if (sym_is_choice(sym)) { conf_choice(menu); if (sym->curr.tri != mod) return; goto conf_childs; } switch (sym->type) { case S_INT: case S_HEX: case S_STRING: conf_string(menu); break; default: conf_sym(menu); break; } conf_childs: if (sym) indent += 2; for (child = menu->list; child; child = child->next) conf(child); if (sym) indent -= 2; }
int main(int ac, char **av) { int saved_x, saved_y; char *mode; int res; setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); conf_parse(av[1]); conf_read(NULL); mode = getenv("MENUCONFIG_MODE"); if (mode) { if (!strcasecmp(mode, "single_menu")) single_menu_mode = 1; } initscr(); getyx(stdscr, saved_y, saved_x); if (init_dialog(NULL)) { fprintf(stderr, N_("Your display is too small to run Menuconfig!\n")); fprintf(stderr, N_("It must be at least 19 lines by 80 columns.\n")); return 1; } set_config_filename(conf_get_configname()); do { conf(&rootmenu); dialog_clear(); if (conf_get_changed()) res = dialog_yesno(NULL, _("Do you wish to save your " "new build configuration?\n" "<ESC><ESC> to continue."), 6, 60); else res = -1; } while (res == KEY_ESC); end_dialog(saved_x, saved_y); switch (res) { case 0: if (conf_write(filename)) { fprintf(stderr, _("\n\n" "Error during writing of the build configuration.\n" "Your build configuration changes were NOT saved." "\n\n")); return 1; } case -1: printf(_("\n\n" "*** End of Kiwi build configuration.\n" "*** Execute 'scons' to build or try 'scons -h'." "\n\n")); break; default: fprintf(stderr, _("\n\n" "Your build configuration changes were NOT saved." "\n\n")); } return 0; }
int main(int argc, char *argv[]) { plan(8*6 + 4); /* exec_query = 6 TAP tests */ knot_mm_t mm; mm_ctx_mempool(&mm, MM_DEFAULT_BLKSIZE); /* Create processing context. */ knot_layer_t proc; memset(&proc, 0, sizeof(knot_layer_t)); proc.mm = &mm; /* Create fake server environment. */ server_t server; int ret = create_fake_server(&server, proc.mm); ok(ret == KNOT_EOK, "ns: fake server initialization"); zone_t *zone = knot_zonedb_find(server.zone_db, ROOT_DNAME); /* Prepare. */ knot_pkt_t *query = knot_pkt_new(NULL, KNOT_WIRE_MAX_PKTSIZE, proc.mm); /* Create query processing parameter. */ struct sockaddr_storage ss; memset(&ss, 0, sizeof(struct sockaddr_storage)); sockaddr_set(&ss, AF_INET, "127.0.0.1", 53); struct process_query_param param = {0}; param.remote = &ss; param.server = &server; /* Query processor (CH zone) */ knot_layer_begin(&proc, NS_PROC_QUERY, ¶m); knot_pkt_clear(query); knot_pkt_put_question(query, IDSERVER_DNAME, KNOT_CLASS_CH, KNOT_RRTYPE_TXT); exec_query(&proc, "CH TXT", query, KNOT_RCODE_NOERROR); /* Query processor (valid input). */ knot_layer_reset(&proc); knot_pkt_clear(query); knot_pkt_put_question(query, ROOT_DNAME, KNOT_CLASS_IN, KNOT_RRTYPE_SOA); exec_query(&proc, "IN/root", query, KNOT_RCODE_NOERROR); /* Query processor (-1 bytes, not enough data). */ knot_layer_reset(&proc); query->size -= 1; exec_query(&proc, "IN/few-data", query, KNOT_RCODE_FORMERR); query->size += 1; /* Query processor (+1 bytes trailing). */ knot_layer_reset(&proc); query->wire[query->size] = '\1'; /* Initialize the "garbage" value. */ query->size += 1; exec_query(&proc, "IN/trail-garbage", query, KNOT_RCODE_FORMERR); query->size -= 1; /* Forge NOTIFY query from SOA query. */ knot_layer_reset(&proc); knot_wire_set_opcode(query->wire, KNOT_OPCODE_NOTIFY); exec_query(&proc, "IN/notify", query, KNOT_RCODE_NOTAUTH); /* Forge AXFR query. */ knot_layer_reset(&proc); knot_pkt_clear(query); knot_pkt_put_question(query, ROOT_DNAME, KNOT_CLASS_IN, KNOT_RRTYPE_AXFR); exec_query(&proc, "IN/axfr", query, KNOT_RCODE_NOTAUTH); /* Forge IXFR query (badly formed, no SOA in AUTHORITY section). */ knot_layer_reset(&proc); knot_pkt_clear(query); knot_pkt_put_question(query, ROOT_DNAME, KNOT_CLASS_IN, KNOT_RRTYPE_IXFR); exec_query(&proc, "IN/ixfr-formerr", query, KNOT_RCODE_FORMERR); /* Forge IXFR query (well formed). */ knot_layer_reset(&proc); knot_pkt_clear(query); knot_pkt_put_question(query, ROOT_DNAME, KNOT_CLASS_IN, KNOT_RRTYPE_IXFR); /* Append SOA RR. */ knot_rrset_t soa_rr = node_rrset(zone->contents->apex, KNOT_RRTYPE_SOA); knot_pkt_begin(query, KNOT_AUTHORITY); knot_pkt_put(query, KNOT_COMPR_HINT_NONE, &soa_rr, 0); exec_query(&proc, "IN/ixfr", query, KNOT_RCODE_NOTAUTH); /* \note Tests below are not possible without proper zone and zone data. */ /* #189 Process UPDATE query. */ /* #189 Process AXFR client. */ /* #189 Process IXFR client. */ /* Query processor (smaller than DNS header, ignore). */ knot_layer_reset(&proc); knot_pkt_clear(query); knot_pkt_put_question(query, ROOT_DNAME, KNOT_CLASS_IN, KNOT_RRTYPE_SOA); size_t orig_query_size = query->size; query->size = KNOT_WIRE_HEADER_SIZE - 1; int state = knot_layer_consume(&proc, query); ok(state == KNOT_STATE_NOOP, "ns: IN/less-than-header query ignored"); query->size = orig_query_size; /* Query processor (response, ignore). */ knot_layer_reset(&proc); knot_wire_set_qr(query->wire); state = knot_layer_consume(&proc, query); ok(state == KNOT_STATE_NOOP, "ns: IN/less-than-header query ignored"); /* Finish. */ state = knot_layer_finish(&proc); ok(state == KNOT_STATE_NOOP, "ns: processing end" ); /* Cleanup. */ mp_delete((struct mempool *)mm.ctx); server_deinit(&server); conf_free(conf()); return 0; }
void PluginManager::Load() { wxString ext; #if defined(__WXGTK__) ext = wxT("so"); #elif defined(__WXMAC__) ext = wxT("dylib"); #else ext = wxT("dll"); #endif wxString fileSpec(wxT("*.") + ext); clConfig conf("plugins.conf"); conf.ReadItem(&m_pluginsData); // set the managers // this code assures us that the shared objects will see the same instances as the application // does LanguageST::Get()->SetTagsManager(GetTagsManager()); TagsManagerST::Get()->SetLanguage(LanguageST::Get()); // Plugin loading policy CodeLiteApp* app = static_cast<CodeLiteApp*>(GetTheApp()); CodeLiteApp::PluginPolicy pp = app->GetPluginLoadPolicy(); wxArrayString allowedPlugins; if(pp == CodeLiteApp::PP_None) { return; } else if(pp == CodeLiteApp::PP_FromList) allowedPlugins = app->GetAllowedPlugins(); wxString pluginsDir = clStandardPaths::Get().GetPluginsDirectory(); if(wxDir::Exists(pluginsDir)) { // get list of dlls wxArrayString files; wxDir::GetAllFiles(pluginsDir, &files, fileSpec, wxDIR_FILES); // Sort the plugins by A-Z std::sort(files.begin(), files.end()); for(size_t i = 0; i < files.GetCount(); i++) { wxString fileName(files.Item(i)); #if defined(__WXMSW__) && !defined(NDEBUG) // Under MSW loading a release plugin while in debug mode will cause a crash if(!fileName.EndsWith("-dbg.dll")) { continue; } #elif defined(__WXMSW__) // filter debug plugins if(fileName.EndsWith("-dbg.dll")) { continue; } #endif #ifdef __WXGTK__ wxFileName fnDLL(fileName); if(fnDLL.GetFullName().StartsWith("lib")) { // don't attempt to load a library continue; } #endif clDynamicLibrary* dl = new clDynamicLibrary(); if(!dl->Load(fileName)) { CL_ERROR(wxT("Failed to load plugin's dll: ") + fileName); if(!dl->GetError().IsEmpty()) { CL_ERROR(dl->GetError()); } wxDELETE(dl); continue; } bool success(false); GET_PLUGIN_INFO_FUNC pfnGetPluginInfo = (GET_PLUGIN_INFO_FUNC)dl->GetSymbol(wxT("GetPluginInfo"), &success); if(!success) { wxDELETE(dl); continue; } // load the plugin version method // if the methods does not exist, handle it as if it has value of 100 (lowest version API) int interface_version(100); GET_PLUGIN_INTERFACE_VERSION_FUNC pfnInterfaceVersion = (GET_PLUGIN_INTERFACE_VERSION_FUNC)dl->GetSymbol(wxT("GetPluginInterfaceVersion"), &success); if(success) { interface_version = pfnInterfaceVersion(); } else { CL_WARNING(wxT("Failed to find GetPluginInterfaceVersion() in dll: ") + fileName); if(!dl->GetError().IsEmpty()) { CL_WARNING(dl->GetError()); } } if(interface_version != PLUGIN_INTERFACE_VERSION) { CL_WARNING(wxString::Format(wxT("Version interface mismatch error for plugin '%s'. Plugin's interface " "version is '%d', CodeLite interface version is '%d'"), fileName.c_str(), interface_version, PLUGIN_INTERFACE_VERSION)); wxDELETE(dl); continue; } // Check if this dll can be loaded PluginInfo* pluginInfo = pfnGetPluginInfo(); wxString pname = pluginInfo->GetName(); pname.MakeLower().Trim().Trim(false); // Check the policy if(pp == CodeLiteApp::PP_FromList && allowedPlugins.Index(pname) == wxNOT_FOUND) { // Policy is set to 'from list' and this plugin does not match any plugins from // the list, don't allow it to be loaded wxDELETE(dl); continue; } // If the plugin does not exist in the m_pluginsData, assume its the first time we see it bool firstTimeLoading = (m_pluginsData.GetPlugins().count(pluginInfo->GetName()) == 0); // Add the plugin information m_pluginsData.AddPlugin((*pluginInfo)); if(firstTimeLoading && pluginInfo->HasFlag(PluginInfo::kDisabledByDefault)) { m_pluginsData.DisablePlugin(pluginInfo->GetName()); wxDELETE(dl); continue; } // Can we load it? if(!m_pluginsData.CanLoad(*pluginInfo)) { CL_WARNING(wxT("Plugin ") + pluginInfo->GetName() + wxT(" is not enabled")); wxDELETE(dl); continue; } // try and load the plugin GET_PLUGIN_CREATE_FUNC pfn = (GET_PLUGIN_CREATE_FUNC)dl->GetSymbol(wxT("CreatePlugin"), &success); if(!success) { CL_WARNING(wxT("Failed to find CreatePlugin() in dll: ") + fileName); if(!dl->GetError().IsEmpty()) { CL_WARNING(dl->GetError()); } m_pluginsData.DisablePlugin(pluginInfo->GetName()); continue; } // Construct the plugin IPlugin* plugin = pfn((IManager*)this); CL_DEBUG(wxT("Loaded plugin: ") + plugin->GetLongName()); m_plugins[plugin->GetShortName()] = plugin; // Load the toolbar clToolBar* tb = plugin->CreateToolBar(clMainFrame::Get()->GetDockingManager().GetManagedWindow()); if(tb) { // When using AUI toolbars, use our own custom art-provider tb->SetArtProvider(new CLMainAuiTBArt()); clMainFrame::Get()->GetDockingManager().AddPane(tb, wxAuiPaneInfo() .Name(plugin->GetShortName()) .LeftDockable(true) .RightDockable(true) .Caption(plugin->GetShortName()) .ToolbarPane() .Top() .Position(999)); // Add menu entry at the 'View->Toolbars' menu for this toolbar wxMenuItem* item = clMainFrame::Get()->GetMenuBar()->FindItem(XRCID("toolbars_menu")); if(item) { wxMenu* submenu = NULL; submenu = item->GetSubMenu(); // add the new toolbar entry at the end of this menu int id = wxNewId(); wxString text(plugin->GetShortName()); wxMenuItem* newItem = new wxMenuItem(submenu, id, text, wxEmptyString, wxITEM_CHECK); submenu->Append(newItem); clMainFrame::Get()->RegisterToolbar(id, plugin->GetShortName()); } } // Keep the dynamic load library m_dl.push_back(dl); } clMainFrame::Get()->GetDockingManager().Update(); // Let the plugins plug their menu in the 'Plugins' menu at the menu bar // the create menu will be placed as a sub menu of the 'Plugin' menu wxMenu* pluginsMenu = NULL; wxMenuItem* menuitem = clMainFrame::Get()->GetMenuBar()->FindItem(XRCID("manage_plugins"), &pluginsMenu); if(pluginsMenu && menuitem) { std::map<wxString, IPlugin*>::iterator iter = m_plugins.begin(); for(; iter != m_plugins.end(); ++iter) { IPlugin* plugin = iter->second; plugin->CreatePluginMenu(pluginsMenu); } } // save the plugins data conf.WriteItem(&m_pluginsData); } // Now that all the plugins are loaded, load from the configuration file // list of visible tabs static wxArrayString DefaultArray; if(DefaultArray.IsEmpty()) { DefaultArray.Add("NOT-FOUND"); } DetachedPanesInfo dpi; GetConfigTool()->ReadObject(wxT("DetachedPanesList"), &dpi); const wxArrayString& detachedPanes = dpi.GetPanes(); { // Hide workspace tabs const wxArrayString& tabs = GetWorkspaceTabs(); wxArrayString visibleTabs = clConfig::Get().Read("VisibleWorkspaceTabs", DefaultArray); if(!((visibleTabs.size() == 1) && (visibleTabs.Item(0) == "NOT-FOUND"))) { for(size_t i = 0; i < tabs.size(); ++i) { if((visibleTabs.Index(tabs.Item(i)) == wxNOT_FOUND) && (detachedPanes.Index(tabs.Item(i)) == wxNOT_FOUND)) { // hidden tab - post an event clCommandEvent eventHide(wxEVT_SHOW_WORKSPACE_TAB); eventHide.SetSelected(false).SetString(tabs.Item(i)); EventNotifier::Get()->AddPendingEvent(eventHide); } } } } { // Hide output tabs const wxArrayString& tabs = GetOutputTabs(); wxArrayString visibleTabs = clConfig::Get().Read("VisibleOutputTabs", DefaultArray); if(!((visibleTabs.size() == 1) && (visibleTabs.Item(0) == "NOT-FOUND"))) { for(size_t i = 0; i < tabs.size(); ++i) { if((visibleTabs.Index(tabs.Item(i)) == wxNOT_FOUND) && (detachedPanes.Index(tabs.Item(i)) == wxNOT_FOUND)) { // hidden tab - post an event clCommandEvent eventHide(wxEVT_SHOW_OUTPUT_TAB); eventHide.SetSelected(false).SetString(tabs.Item(i)); EventNotifier::Get()->AddPendingEvent(eventHide); } } } } }
const cv::Mat& PaintNodesDriver::calculateDensity(const Envelope& e, double pixelSize, QString input) { Hdfs fs; if (fs.exists(input.toStdString()) == false) { throw HootException("Input file does not exist."); } _width = ceil(e.getWidth() / pixelSize) + 1; _height = ceil(e.getHeight() / pixelSize) + 1; QString cacheName = QString("%1/density-%2x%3").arg(input).arg(_width).arg(_height); // if we've already calculated and cached the values. if (fs.exists(cacheName.toStdString())) { LOG_INFO("Loading cache file " << cacheName); LOG_INFO("If you want to recalculate the cache then run this first: "); LOG_INFO(" hadoop fs -rmr " << cacheName); _loadOutputDir(cacheName); } else { // create a job Job job; // set the name job.setName("Paint Nodes " + input.toStdString()); fs.mkdirs("tmp"); QString output = "tmp/" + QUuid::createUuid().toString().replace("{", "").replace("}", "") + "-PaintNodes"; // set the input/output job.setInput(input.toStdString()); job.setOutput(output.toStdString()); // be nice and don't start the reduce tasks until most of the map tasks are done. job.getConfiguration().setDouble("mapred.reduce.slowstart.completed.maps", 0.98); job.getConfiguration().set("hoot.envelope", MapStats::toString(e)); job.getConfiguration().setDouble("hoot.pixel.size", pixelSize); // setup the mapper and reducer classes. job.setMapperClass(PaintNodesMapper::className()); job.setReducerClass(PaintNodesReducer::className()); job.setInputFormatClass(PbfInputFormat::className()); job.setRecordReaderClass(PbfRecordReader::className()); job.setRecordWriterClass(CppSeqFileRecordWriter::className()); // Adds all libraries in this directory to the job. job.addLibraryDirs(conf().getList("hoot.hadoop.libpath", "${HOOT_HOME}/lib/;${HOOT_HOME}/local/lib/;${HADOOP_HOME}/c++/Linux-amd64-64/lib/;" "${HOOT_HOME}/pretty-pipes/lib/")); job.addFile(ConfPath::search("hoot.json").toStdString()); // This library will be used to provide mapper/reducer classes and anything else referenced // by the factory. job.addPlugin(getenv("HOOT_HOME") + string("/lib/libHootHadoop.so.1")); _addDefaultJobSettings(job); // run the job. job.run(); _loadOutputDir(output); // if the input is a directory if (fs.getFileStatus(input.toStdString()).isDir()) { // store the density info for later use. fs.rename(output.toStdString(), cacheName.toStdString()); } else { fs.deletePath(output.toStdString(), true); } } return _c; }
void PHPConfigurationData::Save() { clConfig conf("php.conf"); conf.WriteItem( this ); }