/** * Returns a text representation of this model. * * @param self the model. * @return a string. */ char * to_string (struct ergadm_model_t_ *self) { GString *s; gboolean already_names; unsigned int i; char *substring, *chararray; local_data_t *local_data; local_data = (local_data_t *) (self->model_data); s = g_string_new (NULL); g_string_sprintf (s, "<%s for ", MODEL_NAME); already_names = FALSE; for (i = 0; i < local_data->production_types->len; i++) if (local_data->production_type[i] == TRUE) { if (already_names) g_string_append_printf (s, ",%s", (char *) g_ptr_array_index (local_data->production_types, i)); else { g_string_append_printf (s, "%s", (char *) g_ptr_array_index (local_data->production_types, i)); already_names = TRUE; } } g_string_sprintfa (s, "\n appraisal (per unit)=%g\n", local_data->appraisal); g_string_sprintfa (s, " euthanasia (per animal)=%g\n", local_data->euthanasia); g_string_sprintfa (s, " indemnification (per animal)=%g\n", local_data->indemnification); g_string_sprintfa (s, " carcass-disposal (per animal)=%g\n", local_data->carcass_disposal); g_string_sprintfa (s, " cleaning-disinfecting (per unit)=%g\n", local_data->cleaning_disinfecting); substring = REL_chart_to_string (local_data->visiting); g_string_sprintfa (s, " visiting=%s\n", substring); free (substring); substring = REL_chart_to_string (local_data->testing); g_string_sprintfa (s, " testing=%s\n", substring); free (substring); g_string_sprintfa (s, " vaccination-fixed (per unit)=%g\n", local_data->vaccination_fixed); g_string_sprintfa (s, " vaccination (per animal)=%g\n", local_data->vaccination); g_string_sprintfa (s, " baseline-capacity=%u\n", local_data->baseline_capacity); g_string_sprintfa (s, " additional-vaccination (per animal)=%g>", local_data->extra_vaccination); /* don't return the wrapper object */ chararray = s->str; g_string_free (s, FALSE); return chararray; }
/** * Returns a text representation of this model. * * @param self the model. * @return a string. */ char * to_string (struct naadsm_model_t_ *self) { GString *s; gboolean already_names; unsigned int i; char *substring, *chararray; local_data_t *local_data; local_data = (local_data_t *) (self->model_data); s = g_string_new (NULL); g_string_append_printf (s, "<%s for ", MODEL_NAME); already_names = FALSE; for (i = 0; i < local_data->production_types->len; i++) if (local_data->production_type[i] == TRUE) { if (already_names) g_string_append_printf (s, ",%s", (char *) g_ptr_array_index (local_data->production_types, i)); else { g_string_append_printf (s, "%s", (char *) g_ptr_array_index (local_data->production_types, i)); already_names = TRUE; } } substring = PDF_dist_to_string (local_data->latent_period); g_string_sprintfa (s, "\n latent-period=%s\n", substring); g_free (substring); substring = PDF_dist_to_string (local_data->infectious_subclinical_period); g_string_sprintfa (s, " infectious-subclinical-period=%s\n", substring); g_free (substring); substring = PDF_dist_to_string (local_data->infectious_clinical_period); g_string_sprintfa (s, " infectious-clinical-period=%s\n", substring); g_free (substring); substring = PDF_dist_to_string (local_data->immunity_period); g_string_sprintfa (s, " immunity-period=%s", substring); g_free (substring); if (local_data->prevalence != NULL) { substring = REL_chart_to_string (local_data->prevalence); g_string_append_printf (s, "\n prevalence=%s", substring); g_free (substring); } g_string_append_c (s, '>'); /* don't return the wrapper object */ chararray = s->str; g_string_free (s, FALSE); return chararray; }