示例#1
0
profileWidget::profileWidget(ProfileModel *profileModel, QWidget *parent) : profileWidgetUI(parent) {

  profile_model = profileModel;
  if (!profile_model) {
    qDebug() << "ProfileModel is NULL!";
    return;
  }

  listView->setModel(profile_model);
  listView->setModelColumn(1);
  listView->setIconSize(QSize(22, 22));
  connect(listView->selectionModel(), SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)), this, SLOT(_update()));
  connect(listView, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(mod_profile(const QModelIndex&)));
  connect(kpushbutton_add, SIGNAL(clicked()), this, SLOT(add_profile()));
  connect(kpushbutton_rem, SIGNAL(clicked()), this, SLOT(rem_profile()));
  connect(kpushbutton_mod, SIGNAL(clicked()), this, SLOT(mod_profile()));
  connect(kpushbutton_copy, SIGNAL(clicked()), this, SLOT(copy_profile()));
  connect(kpushbutton_load, SIGNAL(clicked()), this, SLOT(load_profiles()));
  connect(kpushbutton_save, SIGNAL(clicked()), this, SLOT(save_profiles()));
  connect(kpushbutton_init, SIGNAL(clicked()), this, SLOT(init_profiles()));

  kpushbutton_add->setIcon(QIcon::fromTheme("list-add"));
  kpushbutton_rem->setIcon(QIcon::fromTheme("list-remove"));

  kpushbutton_load->setIcon(QIcon::fromTheme("document-open"));
  kpushbutton_save->setIcon(QIcon::fromTheme("document-save"));

  kpushbutton_init->setIcon(QIcon::fromTheme("view-refresh"));

  _update();

}
示例#2
0
文件: meibo.c 项目: piiice16/ex3-3
/* ************************************************************************* *
 * 入力文字列の解析
 * ************************************************************************* */
int
parse_input (char *str) {
  char command[2];
  strncpy(command, str, 2);
  if (command[0] == '%') {
    subst(str, '\n', '\0');
    exec_command(command[1], str, str);
  } else {
    add_profile(&profile_data[nprofiles], str);
    nprofiles++;
    strcpy(str, "fileread success\n");
  }
  return 1;
}
示例#3
0
文件: mini_ghost.cpp 项目: eile/hpx
int hpx_main(boost::program_options::variables_map& vm)
{
    mini_ghost::profiling::data().time_init(hpx::util::high_resolution_timer::now() - init_start);
    hpx::util::high_resolution_timer timer_all;
    hpx::id_type    here = hpx::find_here();
    std::string     name = hpx::get_locality_name();
    p.rank = hpx::naming::get_locality_id_from_id(here);

    if(p.rank == 0)
    {
        std::cout << "mini ghost started up in " << hpx::util::high_resolution_timer::now() - init_start << " seconds.\n";
    }

    p.nranks = hpx::get_num_localities().get();

    profiling_data_sem.reset(new hpx::lcos::local::counting_semaphore(p.nranks));
    p.setup(vm);

    hpx::id_type stepper_id
        = hpx::components::new_<stepper_type>(hpx::find_here()).get();

    boost::shared_ptr<stepper_type>
        stepper(hpx::get_ptr<stepper_type>(stepper_id).get());

    stepper->init(p);
    mini_ghost::barrier_wait();
    stepper->run(p.num_spikes, p.num_tsteps);
    mini_ghost::barrier_wait();
    if (p.rank==0)
    {
        add_profile(mini_ghost::profiling::data());
        if(p.report_perf)
            mini_ghost::profiling::report(std::cout, profiling_data, p);
        else
            std::cout << "Total runtime: " << timer_all.elapsed() << "\n";
        std::ofstream fs("results.yaml");
        mini_ghost::profiling::report(fs, profiling_data, p);
        std::cout << "finalizing ...\n";
        return hpx::finalize();
    }
    else
    {
        hpx::apply(add_profile_action(), hpx::find_root_locality(), mini_ghost::profiling::data());
        return 0;
    }
}
示例#4
0
int hpx_main(boost::program_options::variables_map& vm)
{
    mini_ghost::profiling::data().time_init(
        hpx::util::high_resolution_timer::now() - init_start);

    hpx::util::high_resolution_timer timer_all;

    hpx::id_type here = hpx::find_here();
    std::string name = hpx::get_locality_name();

    p.rank = hpx::naming::get_locality_id_from_id(here);
    if(p.rank == 0)
    {
        std::cout << "mini ghost started up in "
                  << hpx::util::high_resolution_timer::now() - init_start
                  << " seconds.\n";
    }

    p.nranks = hpx::get_num_localities_sync();

    profiling_data_sem.reset(new hpx::lcos::local::counting_semaphore(p.nranks));
    p.setup(vm);

    // Create the local stepper object, retrieve the local pointer to it
    hpx::id_type stepper_id = hpx::components::new_<stepper_type>(here).get();
    boost::shared_ptr<stepper_type> stepper(
        hpx::get_ptr<stepper_type>(stepper_id).get());

    // Initialize stepper
    stepper->init(p).get();
    mini_ghost::barrier_wait();

    // Perform the actual simulation work
    stepper->run(p.num_spikes, p.num_tsteps);
    mini_ghost::barrier_wait();

    // Output various pieces of information about the run
    if (stepper->get_rank() == 0)
    {
        // Output various pieces of information about the run
        add_profile(mini_ghost::profiling::data());

        if (p.report_perf)
            mini_ghost::profiling::report(std::cout, profiling_data, p);
        else
            std::cout << "Total runtime: " << timer_all.elapsed() << "\n";

        std::ofstream fs("results.yaml");
        mini_ghost::profiling::report(fs, profiling_data, p);
        std::cout << "finalizing ...\n";

        return hpx::finalize();
    }
    else
    {
        // Send performance data from this locality to root
        hpx::apply(add_profile_action(), hpx::find_root_locality(),
            mini_ghost::profiling::data());
        return 0;
    }
}
示例#5
0
int dumpconfig(struct cmd_context *cmd, int argc, char **argv)
{
    const char *file = arg_str_value(cmd, file_ARG, NULL);
    const char *type = arg_str_value(cmd, configtype_ARG, arg_count(cmd, list_ARG) ? "list" : "current");
    struct config_def_tree_spec tree_spec = {0};
    struct dm_config_tree *cft = NULL;
    struct cft_check_handle *cft_check_handle = NULL;
    struct profile *profile = NULL;
    int r = ECMD_PROCESSED;

    tree_spec.cmd = cmd;

    if (arg_count(cmd, configtype_ARG) && arg_count(cmd, validate_ARG)) {
        log_error("Only one of --type and --validate permitted.");
        return EINVALID_CMD_LINE;
    }

    if (arg_count(cmd, configtype_ARG) && arg_count(cmd, list_ARG)) {
        log_error("Only one of --type and --list permitted.");
        return EINVALID_CMD_LINE;
    }

    if (arg_count(cmd, atversion_ARG)) {
        if (arg_count(cmd, sinceversion_ARG)) {
            log_error("Only one of --atversion and --sinceversion permitted.");
            return EINVALID_CMD_LINE;
        }

        if (!arg_count(cmd, configtype_ARG) && !arg_count(cmd, list_ARG)) {
            log_error("--atversion requires --type or --list");
            return EINVALID_CMD_LINE;
        }
    } else if (arg_count(cmd, sinceversion_ARG)) {
        if (!arg_count(cmd, configtype_ARG) || strcmp(type, "new")) {
            log_error("--sinceversion requires --type new");
            return EINVALID_CMD_LINE;
        }
    }

    if (arg_count(cmd, ignoreadvanced_ARG))
        tree_spec.ignoreadvanced = 1;

    if (arg_count(cmd, ignoreunsupported_ARG)) {
        if (arg_count(cmd, showunsupported_ARG)) {
            log_error("Only one of --ignoreunsupported and --showunsupported permitted.");
            return EINVALID_CMD_LINE;
        }
        tree_spec.ignoreunsupported = 1;
    } else if (arg_count(cmd, showunsupported_ARG)) {
        tree_spec.ignoreunsupported = 0;
    } else if (strcmp(type, "current") && strcmp(type, "diff")) {
        /*
         * By default hide unsupported settings
         * for all display types except "current"
         * and "diff".
         */
        tree_spec.ignoreunsupported = 1;
    }

    if (strcmp(type, "current") && strcmp(type, "diff")) {
        /*
         * By default hide deprecated settings
         * for all display types except "current"
         * and "diff" unless --showdeprecated is set.
         *
         * N.B. Deprecated settings are visible if
         * --atversion is used with a version that
         * is lower than the version in which the
         * setting was deprecated.
         */
        if (!arg_count(cmd, showdeprecated_ARG))
            tree_spec.ignoredeprecated = 1;
    }

    if (arg_count(cmd, ignorelocal_ARG))
        tree_spec.ignorelocal = 1;

    if (!strcmp(type, "current") || !strcmp(type, "full")) {
        if (arg_count(cmd, atversion_ARG)) {
            log_error("--atversion has no effect with --type %s", type);
            return EINVALID_CMD_LINE;
        }

        if ((arg_count(cmd, ignoreunsupported_ARG) ||
                arg_count(cmd, ignoreadvanced_ARG)) &&
                !strcmp(type, "current")) {
            /* FIXME: allow these even for --type current */
            log_error("--ignoreadvanced and --ignoreunsupported has "
                      "no effect with --type current");
            return EINVALID_CMD_LINE;
        }
    } else if (arg_count(cmd, mergedconfig_ARG)) {
        log_error("--mergedconfig has no effect without --type current or --type full");
        return EINVALID_CMD_LINE;
    }

    if (!_get_vsn(cmd, &tree_spec.version))
        return EINVALID_CMD_LINE;

    /*
     * The profile specified by --profile cmd arg is like --commandprofile,
     * but it is used just for dumping the profile content and not for
     * application.
     */
    if (arg_count(cmd, profile_ARG) &&
            (!(profile = add_profile(cmd, arg_str_value(cmd, profile_ARG, NULL), CONFIG_PROFILE_COMMAND)) ||
             !override_config_tree_from_profile(cmd, profile))) {
        log_error("Failed to load profile %s.", arg_str_value(cmd, profile_ARG, NULL));
        return ECMD_FAILED;
    }

    /*
     * Set the 'cft' to work with based on whether we need the plain
     * config tree or merged config tree cascade if --mergedconfig is used.
     */
    if ((arg_count(cmd, mergedconfig_ARG) || !strcmp(type, "full")) && cmd->cft->cascade) {
        if (!_merge_config_cascade(cmd, cmd->cft, &cft)) {
            log_error("Failed to merge configuration.");
            r = ECMD_FAILED;
            goto out;
        }
    } else
        cft = cmd->cft;
    tree_spec.current_cft = cft;

    if (arg_count(cmd, validate_ARG)) {
        if (_config_validate(cmd, cft)) {
            log_print("LVM configuration valid.");
            goto out;
        } else {
            log_error("LVM configuration invalid.");
            r = ECMD_FAILED;
            goto out;
        }
    }

    if (!strcmp(type, "list") || arg_count(cmd, list_ARG)) {
        tree_spec.type = CFG_DEF_TREE_LIST;
        if (arg_count(cmd, withcomments_ARG)) {
            log_error("--withcomments has no effect with --type list");
            return EINVALID_CMD_LINE;
        }
        /* list type does not require status check */
    } else if (!strcmp(type, "full")) {
        tree_spec.type = CFG_DEF_TREE_FULL;
        if (!_do_def_check(&tree_spec, cft, &cft_check_handle)) {
            r = ECMD_FAILED;
            goto_out;
        }
    } else if (!strcmp(type, "current")) {
        tree_spec.type = CFG_DEF_TREE_CURRENT;
        if (!_do_def_check(&tree_spec, cft, &cft_check_handle)) {
            r = ECMD_FAILED;
            goto_out;
        }
    }
    else if (!strcmp(type, "missing")) {
        tree_spec.type = CFG_DEF_TREE_MISSING;
        if (!_do_def_check(&tree_spec, cft, &cft_check_handle)) {
            r = ECMD_FAILED;
            goto_out;
        }
    }
    else if (!strcmp(type, "default")) {
        tree_spec.type = CFG_DEF_TREE_DEFAULT;
        /* default type does not require check status */
    }
    else if (!strcmp(type, "diff")) {
        tree_spec.type = CFG_DEF_TREE_DIFF;
        if (!_do_def_check(&tree_spec, cft, &cft_check_handle)) {
            r = ECMD_FAILED;
            goto_out;
        }
    }
    else if (!strcmp(type, "new")) {
        tree_spec.type = arg_count(cmd, sinceversion_ARG) ? CFG_DEF_TREE_NEW_SINCE
                         : CFG_DEF_TREE_NEW;
        /* new type does not require check status */
    }
    else if (!strcmp(type, "profilable")) {
        tree_spec.type = CFG_DEF_TREE_PROFILABLE;
        /* profilable type does not require check status */
    }
    else if (!strcmp(type, "profilable-command")) {
        tree_spec.type = CFG_DEF_TREE_PROFILABLE_CMD;
        /* profilable-command type does not require check status */
    }
    else if (!strcmp(type, "profilable-metadata")) {
        tree_spec.type = CFG_DEF_TREE_PROFILABLE_MDA;
        /* profilable-metadata  type does not require check status */
    }
    else {
        log_error("Incorrect type of configuration specified. "
                  "Expected one of: current, default, diff, full, list, missing, "
                  "new, profilable, profilable-command, profilable-metadata.");
        r = EINVALID_CMD_LINE;
        goto out;
    }

    if (arg_count(cmd, withsummary_ARG) || arg_count(cmd, list_ARG))
        tree_spec.withsummary = 1;
    if (arg_count(cmd, withcomments_ARG))
        tree_spec.withcomments = 1;
    if (arg_count(cmd, unconfigured_ARG))
        tree_spec.unconfigured = 1;

    if (arg_count(cmd, withversions_ARG))
        tree_spec.withversions = 1;

    if (arg_count(cmd, withspaces_ARG))
        tree_spec.withspaces = 1;

    if (cft_check_handle)
        tree_spec.check_status = cft_check_handle->status;

    if ((tree_spec.type != CFG_DEF_TREE_CURRENT) &&
            (tree_spec.type != CFG_DEF_TREE_DIFF) &&
            !(cft = config_def_create_tree(&tree_spec))) {
        r = ECMD_FAILED;
        goto_out;
    }

    if (!config_write(cft, &tree_spec, file, argc, argv)) {
        stack;
        r = ECMD_FAILED;
    }
out:
    if (tree_spec.current_cft && (tree_spec.current_cft != cft) &&
            (tree_spec.current_cft != cmd->cft))
        /*
         * This happens in case of CFG_DEF_TREE_FULL where we
         * have merged explicitly defined config trees and also
         * we have used default tree.
         */
        dm_config_destroy(tree_spec.current_cft);

    if (cft && (cft != cmd->cft))
        dm_config_destroy(cft);
    else if (profile)
        remove_config_tree_by_source(cmd, CONFIG_PROFILE_COMMAND);

    /*
     * The cmd->cft (the "current" tree) is destroyed
     * together with cmd context destroy...
     */

    return r;
}