//////////////////////////////////////////// // ParamsFcstInOut.cc // // TDRP C++ code file for class 'ParamsFcstInOut'. // // This file has been automatically // generated by TDRP, do not modify. // ///////////////////////////////////////////// /** * * @file Params.cc * * @class Params * * This class is automatically generated by the Table * Driven Runtime Parameters (TDRP) system * * @note Source is automatically generated from * paramdef file at compile time, do not modify * since modifications will be overwritten. * * * @author Automatically generated * */ using namespace std; #include "ParamsFcstInOut.hh" #include //////////////////////////////////////////// // Default constructor // ParamsFcstInOut::ParamsFcstInOut() { // zero out table memset(_table, 0, sizeof(_table)); // zero out members memset(&_start_, 0, &_end_ - &_start_); // class name _className = "ParamsFcstInOut"; // initialize table _init(); // set members tdrpTable2User(_table, &_start_); _exitDeferred = false; } //////////////////////////////////////////// // Copy constructor // ParamsFcstInOut::ParamsFcstInOut(const ParamsFcstInOut& source) { // sync the source object source.sync(); // zero out table memset(_table, 0, sizeof(_table)); // zero out members memset(&_start_, 0, &_end_ - &_start_); // class name _className = "ParamsFcstInOut"; // copy table tdrpCopyTable((TDRPtable *) source._table, _table); // set members tdrpTable2User(_table, &_start_); _exitDeferred = false; } //////////////////////////////////////////// // Destructor // ParamsFcstInOut::~ParamsFcstInOut() { // free up freeAll(); } //////////////////////////////////////////// // Assignment // void ParamsFcstInOut::operator=(const ParamsFcstInOut& other) { // sync the other object other.sync(); // free up any existing memory freeAll(); // zero out table memset(_table, 0, sizeof(_table)); // zero out members memset(&_start_, 0, &_end_ - &_start_); // copy table tdrpCopyTable((TDRPtable *) other._table, _table); // set members tdrpTable2User(_table, &_start_); _exitDeferred = other._exitDeferred; } //////////////////////////////////////////// // loadFromArgs() // // Loads up TDRP using the command line args. // // Check usage() for command line actions associated with // this function. // // argc, argv: command line args // // char **override_list: A null-terminated list of overrides // to the parameter file. // An override string has exactly the format of an entry // in the parameter file itself. // // char **params_path_p: // If this is non-NULL, it is set to point to the path // of the params file used. // // bool defer_exit: normally, if the command args contain a // print or check request, this function will call exit(). // If defer_exit is set, such an exit is deferred and the // private member _exitDeferred is set. // Use exidDeferred() to test this flag. // // Returns 0 on success, -1 on failure. // int ParamsFcstInOut::loadFromArgs(int argc, char **argv, char **override_list, char **params_path_p, bool defer_exit) { int exit_deferred; if (_tdrpLoadFromArgs(argc, argv, _table, &_start_, override_list, params_path_p, _className, defer_exit, &exit_deferred)) { return (-1); } else { if (exit_deferred) { _exitDeferred = true; } return (0); } } //////////////////////////////////////////// // loadApplyArgs() // // Loads up TDRP using the params path passed in, and applies // the command line args for printing and checking. // // Check usage() for command line actions associated with // this function. // // const char *param_file_path: the parameter file to be read in // // argc, argv: command line args // // char **override_list: A null-terminated list of overrides // to the parameter file. // An override string has exactly the format of an entry // in the parameter file itself. // // bool defer_exit: normally, if the command args contain a // print or check request, this function will call exit(). // If defer_exit is set, such an exit is deferred and the // private member _exitDeferred is set. // Use exidDeferred() to test this flag. // // Returns 0 on success, -1 on failure. // int ParamsFcstInOut::loadApplyArgs(const char *params_path, int argc, char **argv, char **override_list, bool defer_exit) { int exit_deferred; if (tdrpLoadApplyArgs(params_path, argc, argv, _table, &_start_, override_list, _className, defer_exit, &exit_deferred)) { return (-1); } else { if (exit_deferred) { _exitDeferred = true; } return (0); } } //////////////////////////////////////////// // isArgValid() // // Check if a command line arg is a valid TDRP arg. // bool ParamsFcstInOut::isArgValid(const char *arg) { return (tdrpIsArgValid(arg)); } //////////////////////////////////////////// // load() // // Loads up TDRP for a given class. // // This version of load gives the programmer the option to load // up more than one class for a single application. It is a // lower-level routine than loadFromArgs, and hence more // flexible, but the programmer must do more work. // // const char *param_file_path: the parameter file to be read in. // // char **override_list: A null-terminated list of overrides // to the parameter file. // An override string has exactly the format of an entry // in the parameter file itself. // // expand_env: flag to control environment variable // expansion during tokenization. // If TRUE, environment expansion is set on. // If FALSE, environment expansion is set off. // // Returns 0 on success, -1 on failure. // int ParamsFcstInOut::load(const char *param_file_path, char **override_list, int expand_env, int debug) { if (tdrpLoad(param_file_path, _table, &_start_, override_list, expand_env, debug)) { return (-1); } else { return (0); } } //////////////////////////////////////////// // loadFromBuf() // // Loads up TDRP for a given class. // // This version of load gives the programmer the option to // load up more than one module for a single application, // using buffers which have been read from a specified source. // // const char *param_source_str: a string which describes the // source of the parameter information. It is used for // error reporting only. // // char **override_list: A null-terminated list of overrides // to the parameter file. // An override string has exactly the format of an entry // in the parameter file itself. // // const char *inbuf: the input buffer // // int inlen: length of the input buffer // // int start_line_num: the line number in the source which // corresponds to the start of the buffer. // // expand_env: flag to control environment variable // expansion during tokenization. // If TRUE, environment expansion is set on. // If FALSE, environment expansion is set off. // // Returns 0 on success, -1 on failure. // int ParamsFcstInOut::loadFromBuf(const char *param_source_str, char **override_list, const char *inbuf, int inlen, int start_line_num, int expand_env, int debug) { if (tdrpLoadFromBuf(param_source_str, _table, &_start_, override_list, inbuf, inlen, start_line_num, expand_env, debug)) { return (-1); } else { return (0); } } //////////////////////////////////////////// // loadDefaults() // // Loads up default params for a given class. // // See load() for more detailed info. // // Returns 0 on success, -1 on failure. // int ParamsFcstInOut::loadDefaults(int expand_env) { if (tdrpLoad(NULL, _table, &_start_, NULL, expand_env, FALSE)) { return (-1); } else { return (0); } } //////////////////////////////////////////// // sync() // // Syncs the user struct data back into the parameter table, // in preparation for printing. // // This function alters the table in a consistent manner. // Therefore it can be regarded as const. // void ParamsFcstInOut::sync(void) const { tdrpUser2Table(_table, (char *) &_start_); } //////////////////////////////////////////// // print() // // Print params file // // The modes supported are: // // PRINT_SHORT: main comments only, no help or descriptions // structs and arrays on a single line // PRINT_NORM: short + descriptions and help // PRINT_LONG: norm + arrays and structs expanded // PRINT_VERBOSE: long + private params included // void ParamsFcstInOut::print(FILE *out, tdrp_print_mode_t mode) { tdrpPrint(out, _table, _className, mode); } //////////////////////////////////////////// // checkAllSet() // // Return TRUE if all set, FALSE if not. // // If out is non-NULL, prints out warning messages for those // parameters which are not set. // int ParamsFcstInOut::checkAllSet(FILE *out) { return (tdrpCheckAllSet(out, _table, &_start_)); } ////////////////////////////////////////////////////////////// // checkIsSet() // // Return TRUE if parameter is set, FALSE if not. // // int ParamsFcstInOut::checkIsSet(const char *paramName) { return (tdrpCheckIsSet(paramName, _table, &_start_)); } //////////////////////////////////////////// // freeAll() // // Frees up all TDRP dynamic memory. // void ParamsFcstInOut::freeAll(void) { tdrpFreeAll(_table, &_start_); } //////////////////////////////////////////// // usage() // // Prints out usage message for TDRP args as passed // in to loadFromArgs(). // void ParamsFcstInOut::usage(ostream &out) { out << "TDRP args: [options as below]\n" << " [ -params path ] specify params file path\n" << " [ -check_params] check which params are not set\n" << " [ -print_params [mode]] print parameters\n" << " using following modes, default mode is 'norm'\n" << " short: main comments only, no help or descr\n" << " structs and arrays on a single line\n" << " norm: short + descriptions and help\n" << " long: norm + arrays and structs expanded\n" << " verbose: long + private params included\n" << " short_expand: short with env vars expanded\n" << " norm_expand: norm with env vars expanded\n" << " long_expand: long with env vars expanded\n" << " verbose_expand: verbose with env vars expanded\n" << " [ -tdrp_debug] debugging prints for tdrp\n" << " [ -tdrp_usage] print this usage\n"; } //////////////////////////////////////////// // arrayRealloc() // // Realloc 1D array. // // If size is increased, the values from the last array // entry is copied into the new space. // // Returns 0 on success, -1 on error. // int ParamsFcstInOut::arrayRealloc(const char *param_name, int new_array_n) { if (tdrpArrayRealloc(_table, &_start_, param_name, new_array_n)) { return (-1); } else { return (0); } } //////////////////////////////////////////// // array2DRealloc() // // Realloc 2D array. // // If size is increased, the values from the last array // entry is copied into the new space. // // Returns 0 on success, -1 on error. // int ParamsFcstInOut::array2DRealloc(const char *param_name, int new_array_n1, int new_array_n2) { if (tdrpArray2DRealloc(_table, &_start_, param_name, new_array_n1, new_array_n2)) { return (-1); } else { return (0); } } //////////////////////////////////////////// // _init() // // Class table initialization function. // // void ParamsFcstInOut::_init() { TDRPtable *tt = _table; // Parameter 'Comment 0' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = COMMENT_TYPE; tt->param_name = tdrpStrDup("Comment 0"); tt->comment_hdr = tdrpStrDup("Fcst Params"); tt->comment_text = tdrpStrDup("--------data values for input and output--------------------\n--------projection file specification ----------------------"); tt++; // Parameter 'Comment 1' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = COMMENT_TYPE; tt->param_name = tdrpStrDup("Comment 1"); tt->comment_hdr = tdrpStrDup("description of params"); tt->comment_text = tdrpStrDup("Inputs/outputs share the same parameters:\nname = simple name for this data\ndescription = description of how its used in the app\nurl = where data comes from or is written\nfield = field name\nunits = data units\nremap = TRUE if grid should be remapped to the ConvWx projection for read\ndelta_minutes = minutes between obs data\nlt_hour0 = hour of 0th lead time\nlt_hour1 = hour of last lead time\nlt_delta_hours = hours between lead times\n"); tt++; // Parameter 'fcst_input' // ctype is '_fcst_data_t' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = STRUCT_TYPE; tt->param_name = tdrpStrDup("fcst_input"); tt->descr = tdrpStrDup("input fcst data"); tt->help = tdrpStrDup("forecast data input"); tt->array_offset = (char *) &_fcst_input - &_start_; tt->array_n_offset = (char *) &fcst_input_n - &_start_; tt->is_array = TRUE; tt->array_len_fixed = FALSE; tt->array_elem_size = sizeof(fcst_data_t); tt->array_n = 0; tt->struct_def.name = tdrpStrDup("fcst_data_t"); tt->struct_def.nfields = 10; tt->struct_def.fields = (struct_field_t *) tdrpMalloc(tt->struct_def.nfields * sizeof(struct_field_t)); tt->struct_def.fields[0].ftype = tdrpStrDup("string"); tt->struct_def.fields[0].fname = tdrpStrDup("name"); tt->struct_def.fields[0].ptype = STRING_TYPE; tt->struct_def.fields[0].rel_offset = (char *) &_fcst_input->name - (char *) _fcst_input; tt->struct_def.fields[1].ftype = tdrpStrDup("string"); tt->struct_def.fields[1].fname = tdrpStrDup("description"); tt->struct_def.fields[1].ptype = STRING_TYPE; tt->struct_def.fields[1].rel_offset = (char *) &_fcst_input->description - (char *) _fcst_input; tt->struct_def.fields[2].ftype = tdrpStrDup("string"); tt->struct_def.fields[2].fname = tdrpStrDup("url"); tt->struct_def.fields[2].ptype = STRING_TYPE; tt->struct_def.fields[2].rel_offset = (char *) &_fcst_input->url - (char *) _fcst_input; tt->struct_def.fields[3].ftype = tdrpStrDup("string"); tt->struct_def.fields[3].fname = tdrpStrDup("field"); tt->struct_def.fields[3].ptype = STRING_TYPE; tt->struct_def.fields[3].rel_offset = (char *) &_fcst_input->field - (char *) _fcst_input; tt->struct_def.fields[4].ftype = tdrpStrDup("string"); tt->struct_def.fields[4].fname = tdrpStrDup("units"); tt->struct_def.fields[4].ptype = STRING_TYPE; tt->struct_def.fields[4].rel_offset = (char *) &_fcst_input->units - (char *) _fcst_input; tt->struct_def.fields[5].ftype = tdrpStrDup("double"); tt->struct_def.fields[5].fname = tdrpStrDup("lt_hour0"); tt->struct_def.fields[5].ptype = DOUBLE_TYPE; tt->struct_def.fields[5].rel_offset = (char *) &_fcst_input->lt_hour0 - (char *) _fcst_input; tt->struct_def.fields[6].ftype = tdrpStrDup("double"); tt->struct_def.fields[6].fname = tdrpStrDup("lt_hour1"); tt->struct_def.fields[6].ptype = DOUBLE_TYPE; tt->struct_def.fields[6].rel_offset = (char *) &_fcst_input->lt_hour1 - (char *) _fcst_input; tt->struct_def.fields[7].ftype = tdrpStrDup("double"); tt->struct_def.fields[7].fname = tdrpStrDup("lt_delta_hours"); tt->struct_def.fields[7].ptype = DOUBLE_TYPE; tt->struct_def.fields[7].rel_offset = (char *) &_fcst_input->lt_delta_hours - (char *) _fcst_input; tt->struct_def.fields[8].ftype = tdrpStrDup("boolean"); tt->struct_def.fields[8].fname = tdrpStrDup("remap"); tt->struct_def.fields[8].ptype = BOOL_TYPE; tt->struct_def.fields[8].rel_offset = (char *) &_fcst_input->remap - (char *) _fcst_input; tt->struct_def.fields[9].ftype = tdrpStrDup("int"); tt->struct_def.fields[9].fname = tdrpStrDup("gt_delta_minutes"); tt->struct_def.fields[9].ptype = INT_TYPE; tt->struct_def.fields[9].rel_offset = (char *) &_fcst_input->gt_delta_minutes - (char *) _fcst_input; tt->n_struct_vals = 0; tt->struct_vals = (tdrpVal_t *) tdrpMalloc(tt->n_struct_vals * sizeof(tdrpVal_t)); tt++; // Parameter 'fcst_output' // ctype is '_fcst_data_t' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = STRUCT_TYPE; tt->param_name = tdrpStrDup("fcst_output"); tt->descr = tdrpStrDup("output fcst data"); tt->help = tdrpStrDup("forecast data output"); tt->array_offset = (char *) &_fcst_output - &_start_; tt->array_n_offset = (char *) &fcst_output_n - &_start_; tt->is_array = TRUE; tt->array_len_fixed = FALSE; tt->array_elem_size = sizeof(fcst_data_t); tt->array_n = 0; tt->struct_def.name = tdrpStrDup("fcst_data_t"); tt->struct_def.nfields = 10; tt->struct_def.fields = (struct_field_t *) tdrpMalloc(tt->struct_def.nfields * sizeof(struct_field_t)); tt->struct_def.fields[0].ftype = tdrpStrDup("string"); tt->struct_def.fields[0].fname = tdrpStrDup("name"); tt->struct_def.fields[0].ptype = STRING_TYPE; tt->struct_def.fields[0].rel_offset = (char *) &_fcst_output->name - (char *) _fcst_output; tt->struct_def.fields[1].ftype = tdrpStrDup("string"); tt->struct_def.fields[1].fname = tdrpStrDup("description"); tt->struct_def.fields[1].ptype = STRING_TYPE; tt->struct_def.fields[1].rel_offset = (char *) &_fcst_output->description - (char *) _fcst_output; tt->struct_def.fields[2].ftype = tdrpStrDup("string"); tt->struct_def.fields[2].fname = tdrpStrDup("url"); tt->struct_def.fields[2].ptype = STRING_TYPE; tt->struct_def.fields[2].rel_offset = (char *) &_fcst_output->url - (char *) _fcst_output; tt->struct_def.fields[3].ftype = tdrpStrDup("string"); tt->struct_def.fields[3].fname = tdrpStrDup("field"); tt->struct_def.fields[3].ptype = STRING_TYPE; tt->struct_def.fields[3].rel_offset = (char *) &_fcst_output->field - (char *) _fcst_output; tt->struct_def.fields[4].ftype = tdrpStrDup("string"); tt->struct_def.fields[4].fname = tdrpStrDup("units"); tt->struct_def.fields[4].ptype = STRING_TYPE; tt->struct_def.fields[4].rel_offset = (char *) &_fcst_output->units - (char *) _fcst_output; tt->struct_def.fields[5].ftype = tdrpStrDup("double"); tt->struct_def.fields[5].fname = tdrpStrDup("lt_hour0"); tt->struct_def.fields[5].ptype = DOUBLE_TYPE; tt->struct_def.fields[5].rel_offset = (char *) &_fcst_output->lt_hour0 - (char *) _fcst_output; tt->struct_def.fields[6].ftype = tdrpStrDup("double"); tt->struct_def.fields[6].fname = tdrpStrDup("lt_hour1"); tt->struct_def.fields[6].ptype = DOUBLE_TYPE; tt->struct_def.fields[6].rel_offset = (char *) &_fcst_output->lt_hour1 - (char *) _fcst_output; tt->struct_def.fields[7].ftype = tdrpStrDup("double"); tt->struct_def.fields[7].fname = tdrpStrDup("lt_delta_hours"); tt->struct_def.fields[7].ptype = DOUBLE_TYPE; tt->struct_def.fields[7].rel_offset = (char *) &_fcst_output->lt_delta_hours - (char *) _fcst_output; tt->struct_def.fields[8].ftype = tdrpStrDup("boolean"); tt->struct_def.fields[8].fname = tdrpStrDup("remap"); tt->struct_def.fields[8].ptype = BOOL_TYPE; tt->struct_def.fields[8].rel_offset = (char *) &_fcst_output->remap - (char *) _fcst_output; tt->struct_def.fields[9].ftype = tdrpStrDup("int"); tt->struct_def.fields[9].fname = tdrpStrDup("gt_delta_minutes"); tt->struct_def.fields[9].ptype = INT_TYPE; tt->struct_def.fields[9].rel_offset = (char *) &_fcst_output->gt_delta_minutes - (char *) _fcst_output; tt->n_struct_vals = 0; tt->struct_vals = (tdrpVal_t *) tdrpMalloc(tt->n_struct_vals * sizeof(tdrpVal_t)); tt++; // Parameter 'projection_param_file' // ctype is 'char*' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = STRING_TYPE; tt->param_name = tdrpStrDup("projection_param_file"); tt->descr = tdrpStrDup("projection params"); tt->help = tdrpStrDup("params with projection information"); tt->val_offset = (char *) &projection_param_file - &_start_; tt->single_val.s = tdrpStrDup("ConvWx_projection.params"); tt++; // Parameter 'Comment 2' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = COMMENT_TYPE; tt->param_name = tdrpStrDup("Comment 2"); tt->comment_hdr = tdrpStrDup("End of Fcst Params"); tt->comment_text = tdrpStrDup(""); tt++; // trailing entry has param_name set to NULL tt->param_name = NULL; return; }