/* Loads a boolean parameter */ int load_builtin_param_bool(const char * name, void * engine_val, short int flags, int init_val, const char * alt_name) { param_t * param; value_t iv, ub, lb; iv.int_val = init_val; ub.int_val = TRUE; lb.int_val = FALSE; param = create_param(name, P_TYPE_BOOL, flags, engine_val, NULL, iv, ub, lb); if (param == NULL) { return OUTOFMEM_ERROR; } if (insert_builtin_param(param) < 0) { free_param(param); return ERROR; } if (alt_name != NULL) { insert_param_alt_name(param, alt_name); } return SUCCESS; }
/* Loads a double parameter into the builtin database */ int load_builtin_param_double(const char * name, void * engine_val, void * matrix, short int flags, double init_val, double upper_bound, double lower_bound, const char * alt_name) { param_t * param = NULL; value_t iv, ub, lb; iv.double_val = init_val; ub.double_val = upper_bound; lb.double_val = lower_bound; /* Create new parameter of type double */ if (PARAM_DEBUG == 2) { printf("load_builtin_param_double: (name \"%s\") (alt_name = \"%s\") ", name, alt_name); fflush(stdout); } if ((param = create_param(name, P_TYPE_DOUBLE, flags, engine_val, matrix, iv, ub, lb)) == NULL) { return OUTOFMEM_ERROR; } if (PARAM_DEBUG == 2) { printf("created..."); fflush(stdout); } /* Insert the paremeter into the database */ if (insert_builtin_param(param) < 0) { free_param(param); return ERROR; } if (PARAM_DEBUG == 2) { printf("inserted..."); fflush(stdout); } /* If this parameter has an alternate name, insert it into the database as link */ if (alt_name != NULL) { insert_param_alt_name(param, alt_name); if (PARAM_DEBUG == 2) { printf("alt_name inserted..."); fflush(stdout); } } if (PARAM_DEBUG == 2) printf("finished\n"); /* Finished, return success */ return SUCCESS; }
/* Loads a integer parameter into the builtin database */ int BuiltinParams::load_builtin_param_int(const std::string & name, void * engine_val, short int flags, int init_val, int upper_bound, int lower_bound, const std::string &alt_name) { Param * param; CValue iv, ub, lb; iv.int_val = init_val; ub.int_val = upper_bound; lb.int_val = lower_bound; // normalize to lower case as milkdrop scripts depend on this std::string lowerName(name); std::transform(lowerName.begin(), lowerName.end(), lowerName.begin(), tolower); param = new Param(lowerName, P_TYPE_INT, flags, engine_val, NULL, iv, ub, lb); if (param == NULL) { return PROJECTM_OUTOFMEM_ERROR; } if (insert_builtin_param( param ) < 0) { delete param; return PROJECTM_ERROR; } if (alt_name != "") { std::string alt_lower_name(alt_name); std::transform(alt_lower_name.begin(), alt_lower_name.end(), alt_lower_name.begin(), tolower); insert_param_alt_name(param,alt_lower_name); } return PROJECTM_SUCCESS; }
/* Loads a boolean parameter */ int BuiltinParams::load_builtin_param_bool(const std:: string & name, void * engine_val, short int flags, int init_val, const std::string &alt_name) { Param * param; CValue iv, ub, lb; iv.int_val = init_val; ub.int_val = TRUE; lb.int_val = false; std::string lowerName(name); std::transform(lowerName.begin(), lowerName.end(), lowerName.begin(), tolower); param = new Param(lowerName, P_TYPE_BOOL, flags, engine_val, NULL, iv, ub, lb); if (param == NULL) { return PROJECTM_OUTOFMEM_ERROR; } if (insert_builtin_param(param) < 0) { delete param; return PROJECTM_ERROR; } if (alt_name != "") { std::string alt_lower_name(alt_name); std::transform(alt_lower_name.begin(), alt_lower_name.end(), alt_lower_name.begin(), tolower); insert_param_alt_name(param,alt_lower_name); } return PROJECTM_SUCCESS; }
/* Loads a float parameter into the builtin database */ int BuiltinParams::load_builtin_param_float(const std::string & name, void * engine_val, void * matrix, short int flags, float init_val, float upper_bound, float lower_bound, const std::string & alt_name) { Param * param = NULL; CValue iv, ub, lb; iv.float_val = init_val; ub.float_val = upper_bound; lb.float_val = lower_bound; /* Create new parameter of type float */ if (BUILTIN_PARAMS_DEBUG == 2) { printf("load_builtin_param_float: (name \"%s\") (alt_name = \"%s\") ", name.c_str(), alt_name.c_str()); fflush(stdout); } std::string lowerName(name); std::transform(lowerName.begin(), lowerName.end(), lowerName.begin(), tolower); if ((param = new Param(lowerName, P_TYPE_DOUBLE, flags, engine_val, matrix, iv, ub, lb)) == NULL) { return PROJECTM_OUTOFMEM_ERROR; } if (BUILTIN_PARAMS_DEBUG == 2) { printf("created..."); fflush(stdout); } /* Insert the paremeter into the database */ if (insert_builtin_param( param ) < 0) { delete param; return PROJECTM_ERROR; } if (BUILTIN_PARAMS_DEBUG == 2) { printf("inserted..."); fflush(stdout); } /* If this parameter has an alternate name, insert it into the database as link */ if (alt_name != "") { std::string alt_lower_name(alt_name); std::transform(alt_lower_name.begin(), alt_lower_name.end(), alt_lower_name.begin(), tolower); insert_param_alt_name(param,alt_lower_name); if (BUILTIN_PARAMS_DEBUG == 2) { printf("alt_name inserted..."); fflush(stdout); } } if (BUILTIN_PARAMS_DEBUG == 2) printf("finished\n"); /* Finished, return success */ return PROJECTM_SUCCESS; }