pyp_parameter(const double& __discount, const double& __strength) : discount(__discount), strength(__strength), discount_alpha(std::numeric_limits<double>::quiet_NaN()), discount_beta(std::numeric_limits<double>::quiet_NaN()), strength_shape(std::numeric_limits<double>::quiet_NaN()), strength_rate(std::numeric_limits<double>::quiet_NaN()) { verify_parameters(); }
pyp_parameter(const double& __discount_alpha, const double& __discount_beta, const double& __strength_shape, const double& __strength_rate) : discount(0.9), strength(1.0), discount_alpha(__discount_alpha), discount_beta(__discount_beta), strength_shape(__strength_shape), strength_rate(__strength_rate) { verify_parameters(); }
///< Parse the input arguments static int parse_args(int argc, char **argv) { FILE* fp; char *pch; int count = 0, len = 0; fp = fopen(argv[1], "r"); if (!fp) { fprintf(stderr, " [%s] [%d] idx_dir is corrupt.\n", __FILE__, __LINE__); return (-1); } char line [ 512 ]; while (fgets(line, sizeof (line), fp) != NULL) { len = strlen(line) - 1; if (line[len] == '\n') line[len] = 0; printf("input line %s\n", line); if (strcmp(line, "(global box)") == 0) { if( fgets(line, sizeof line, fp) == NULL) return (-1); len = strlen(line) - 1; if (line[len] == '\n') line[len] = 0; pch = strtok(line, " "); count = 0; while (pch != NULL) { global_box_size[count] = atoi(pch) ; count++; pch = strtok(NULL, " "); } } if (strcmp(line, "(rst agg)") == 0) { if( fgets(line, sizeof line, fp) == NULL) return (-1); len = strlen(line) - 1; if (line[len] == '\n') line[len] = 0; pch = strtok(line, " "); count = 0; while (pch != NULL) { rst_agg[count] = atoi(pch) ; count++; pch = strtok(NULL, " "); } } if (strcmp(line, "(local box)") == 0) { if( fgets(line, sizeof line, fp) == NULL) return (-1); len = strlen(line) - 1; if (line[len] == '\n') line[len] = 0; pch = strtok(line, " "); count = 0; while (pch != NULL) { local_box_size[count] = atoi(pch) ; count++; pch = strtok(NULL, " "); } } if (strcmp(line, "(restructured box size)") == 0) { if( fgets(line, sizeof line, fp) == NULL) return (-1); len = strlen(line) - 1; if (line[len] == '\n') line[len] = 0; pch = strtok(line, " "); count = 0; while (pch != NULL) { restructured_box_size[count] = atoi(pch) ; count++; pch = strtok(NULL, " "); } } if (strcmp(line, "(file name)") == 0) { if( fgets(line, sizeof line, fp) == NULL) return (-1); len = strlen(line) - 1; if (line[len] == '\n') line[len] = 0; strncpy(output_file_template, line, len); } if (strcmp(line, "(time steps)") == 0) { if( fgets(line, sizeof line, fp) == NULL) return (-1); len = strlen(line) - 1; if (line[len] == '\n') line[len] = 0; time_step_count = atoi(line); } if (strcmp(line, "(fields)") == 0) { if( fgets(line, sizeof line, fp) == NULL) return (-1); len = strlen(line) - 1; if (line[len] == '\n') line[len] = 0; variable_count= atoi(line); } if (strcmp(line, "(patch count)") == 0) { if( fgets(line, sizeof line, fp) == NULL) return (-1); len = strlen(line) - 1; if (line[len] == '\n') line[len] = 0; patch_count= atoi(line); } if (strcmp(line, "(idx count)") == 0) { if( fgets(line, sizeof line, fp) == NULL) return (-1); len = strlen(line) - 1; if (line[len] == '\n') line[len] = 0; pch = strtok(line, " "); count = 0; while (pch != NULL) { idx_count[count] = atoi(pch) ; count++; pch = strtok(NULL, " "); } } if (strcmp(line, "(debug rst:hz)") == 0) { if( fgets(line, sizeof line, fp) == NULL) return (-1); len = strlen(line) - 1; if (line[len] == '\n') line[len] = 0; pch = strtok(line, " "); count = 0; while (pch != NULL) { debug_rst_hz[count] = atoi(pch) ; count++; pch = strtok(NULL, " "); } } if (strcmp(line, "(dump agg:io)") == 0) { if( fgets(line, sizeof line, fp) == NULL) return (-1); len = strlen(line) - 1; if (line[len] == '\n') line[len] = 0; pch = strtok(line, " "); count = 0; while (pch != NULL) { dump_agg_io[count] = atoi(pch) ; count++; pch = strtok(NULL, " "); } } if (strcmp(line, "(perform rst:brst:hz:comp:agg:io)") == 0) { if( fgets(line, sizeof line, fp) == NULL) return (-1); len = strlen(line) - 1; if (line[len] == '\n') line[len] = 0; pch = strtok(line, " "); count = 0; while (pch != NULL) { perform_phases[count] = atoi(pch) ; count++; pch = strtok(NULL, " "); } } if (strcmp(line, "(compression type)") == 0) { if( fgets(line, sizeof line, fp) == NULL) return (-1); len = strlen(line) - 1; if (line[len] == '\n') line[len] = 0; compression_type= atoi(line); } if (strcmp(line, "(compression bit rate)") == 0) { if( fgets(line, sizeof line, fp) == NULL) return (-1); len = strlen(line) - 1; if (line[len] == '\n') line[len] = 0; compression_bit_rate= atoi(line); } if (strcmp(line, "(blocks per file)") == 0) { if( fgets(line, sizeof line, fp) == NULL) return (-1); len = strlen(line) - 1; if (line[len] == '\n') line[len] = 0; blocks_per_file= atoi(line); } if (strcmp(line, "(bits per block)") == 0) { if( fgets(line, sizeof line, fp) == NULL) return (-1); len = strlen(line) - 1; if (line[len] == '\n') line[len] = 0; bits_per_block = atoi(line); } if (strcmp(line, "(aggregator multiplier)") == 0) { if( fgets(line, sizeof line, fp) == NULL) return (-1); len = strlen(line) - 1; if (line[len] == '\n') line[len] = 0; aggregation_factor = atoi(line); } if (strcmp(line, "(rank z ordering)") == 0) { if( fgets(line, sizeof line, fp) == NULL) return (-1); len = strlen(line) - 1; if (line[len] == '\n') line[len] = 0; is_rank_z_ordering = atoi(line); } if (strcmp(line, "(hz from:to)") == 0) { if( fgets(line, sizeof line, fp) == NULL) return (-1); len = strlen(line) - 1; if (line[len] == '\n') line[len] = 0; pch = strtok(line, " "); count = 0; while (pch != NULL) { hz_from_to[count] = atoi(pch) ; count++; pch = strtok(NULL, " "); } } } fclose(fp); if (verify_parameters() < 0) return (-1); return (0); }
void user_daemon_t::handle_parameters(int argc, char *argv[]) { bool_t instance_specified, unit_specified; co_command_line_params_t cmdline; co_rc_t rc; rc = co_cmdline_params_alloc(&argv[1], argc-1, &cmdline); if (!CO_OK(rc)) { log("error parsing arguments\n"); throw user_daemon_exception_t(rc); } try { rc = co_cmdline_params_one_arugment_int_parameter(cmdline, "-i", &instance_specified, (int *)¶m_instance); if (!CO_OK(rc)) { syntax(); throw user_daemon_exception_t(rc); } rc = co_cmdline_params_one_arugment_int_parameter(cmdline, "-u", &unit_specified, ¶m_index); if (!CO_OK(rc)) { syntax(); throw user_daemon_exception_t(rc); } handle_extended_parameters(cmdline); rc = co_cmdline_params_check_for_no_unparsed_parameters(cmdline, PTRUE); if (!CO_OK(rc)) { syntax(); throw user_daemon_exception_t(rc); } if (!instance_specified && !unit_specified) { rc = CO_RC(OK); syntax(); throw user_daemon_exception_t(rc); } verify_parameters(); if ((param_index < 0) || (param_index >= get_unit_count())) { syntax(); log("invalid unit index: %d\n", param_index); throw user_daemon_exception_t(rc); } if (!instance_specified) { syntax(); log("coLinux instance not specificed\n"); throw user_daemon_exception_t(rc); } } catch(...) { co_cmdline_params_free(cmdline); throw; } }