[gnumeric] solver: namespace improvements.
- From: Morten Welinder <mortenw src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnumeric] solver: namespace improvements.
- Date: Mon, 2 Nov 2009 02:35:12 +0000 (UTC)
commit 420cc1e9c829870c52615e80c0be7980e1f5ca8f
Author: Morten Welinder <terra gnome org>
Date: Sun Nov 1 21:34:56 2009 -0500
solver: namespace improvements.
src/sheet.c | 8 ++++----
src/solver.h | 23 +++++++++++++++--------
src/tools/solver/solver.c | 8 ++++----
3 files changed, 23 insertions(+), 16 deletions(-)
---
diff --git a/src/sheet.c b/src/sheet.c
index c867d97..38b3a16 100644
--- a/src/sheet.c
+++ b/src/sheet.c
@@ -755,7 +755,7 @@ gnm_sheet_init (Sheet *sheet)
sheet->sheet_objects = NULL;
sheet->max_object_extent.col = sheet->max_object_extent.row = 0;
- sheet->solver_parameters = solver_param_new (sheet);
+ sheet->solver_parameters = gnm_solver_param_new (sheet);
sheet->cols.max_used = -1;
sheet->cols.info = g_ptr_array_new ();
@@ -3967,7 +3967,7 @@ gnm_sheet_finalize (GObject *obj)
sheet_destroy (sheet);
- solver_param_destroy (sheet->solver_parameters);
+ gnm_solver_param_free (sheet->solver_parameters);
scenarios_free (sheet->scenarios);
dependents_invalidate_sheet (sheet, TRUE);
@@ -5509,8 +5509,8 @@ sheet_dup (Sheet const *src)
#warning selection is in view
#warning freeze/thaw is in view
- solver_param_destroy (dst->solver_parameters);
- dst->solver_parameters = solver_lp_copy (src->solver_parameters, dst);
+ gnm_solver_param_free (dst->solver_parameters);
+ dst->solver_parameters = gnm_solver_param_dup (src->solver_parameters, dst);
dst->scenarios = scenarios_dup (src->scenarios, dst);
diff --git a/src/solver.h b/src/solver.h
index b28aebc..d9d4352 100644
--- a/src/solver.h
+++ b/src/solver.h
@@ -58,6 +58,8 @@ struct _SolverParameters {
SolverOptions options;
};
+/* -------------------------------------------------------------------------- */
+
typedef enum {
SolverLE,
SolverGE,
@@ -105,6 +107,12 @@ void gnm_solver_constraint_side_as_str (SolverConstraint const *c,
GString *buf, gboolean lhs);
char *gnm_solver_constraint_as_str (SolverConstraint const *c, Sheet *sheet);
+#endif
+
+/* -------------------------------------------------------------------------- */
+
+#ifdef GNM_ENABLE_SOLVER
+
typedef enum {
SolverRunning, SolverOptimal, SolverUnbounded, SolverInfeasible,
SolverFailure, SolverMaxIterExc, SolverMaxTimeExc
@@ -240,9 +248,8 @@ gchar * solver_reports (WorkbookControl *wbc, Sheet *sheet,
gboolean limits, gboolean performance,
gboolean program, gboolean dual);
-/* Initializes the Solver's data structure containing the parameters.
- * Each sheet can currently have one copy of this data structure. */
-SolverParameters *solver_param_new (Sheet *sheet);
+/* Creates a new SolverParameters object. */
+SolverParameters *gnm_solver_param_new (Sheet *sheet);
GnmValue const *gnm_solver_param_get_input (SolverParameters const *sp);
void gnm_solver_param_set_input (SolverParameters *sp, GnmValue *v);
@@ -253,11 +260,11 @@ void gnm_solver_param_set_target (SolverParameters *sp, GnmCellRef const *cr);
GnmCell *gnm_solver_param_get_target_cell (SolverParameters const *sp);
/* Frees the memory resources in the solver parameter structure. */
-void solver_param_destroy (SolverParameters *sp);
+void gnm_solver_param_free (SolverParameters *sp);
/* Creates a copy of the Solver's data structures when a sheet is
* duplicated. */
-SolverParameters *solver_lp_copy (SolverParameters const *src_param,
+SolverParameters *gnm_solver_param_dup (SolverParameters const *src_param,
Sheet *new_sheet);
/* Frees the data structure allocated for the results. */
@@ -273,9 +280,9 @@ void solver_param_read_sax (GsfXMLIn *xin, xmlChar const **attrs);
#else /* !GNM_ENABLE_SOLVER */
-#define solver_param_new() NULL
-#define solver_lp_copy(src_param, new_sheet) NULL
-#define solver_param_destroy(param) do {} while(0)
+#define gnm_solver_param_new() NULL
+#define gnm_solver_param_dup(src_param, new_sheet) NULL
+#define gnm_solver_param_free(param) do {} while(0)
#define solver_insert_cols(sheet, col, count) do {} while(0)
#define solver_insert_rows(sheet, row, count) do {} while(0)
#define solver_delete_cols(sheet, col, count) do {} while(0)
diff --git a/src/tools/solver/solver.c b/src/tools/solver/solver.c
index 7de43d8..05d8327 100644
--- a/src/tools/solver/solver.c
+++ b/src/tools/solver/solver.c
@@ -67,7 +67,7 @@ attr_eq (const xmlChar *a, const char *s)
SolverParameters *
-solver_param_new (Sheet *sheet)
+gnm_solver_param_new (Sheet *sheet)
{
SolverParameters *res = g_new0 (SolverParameters, 1);
@@ -87,7 +87,7 @@ solver_param_new (Sheet *sheet)
}
void
-solver_param_destroy (SolverParameters *sp)
+gnm_solver_param_free (SolverParameters *sp)
{
dependent_managed_set_expr (&sp->target, NULL);
dependent_managed_set_expr (&sp->input, NULL);
@@ -1153,9 +1153,9 @@ solver (WorkbookControl *wbc, Sheet *sheet, const gchar **errmsg)
SolverParameters *
-solver_lp_copy (const SolverParameters *src_param, Sheet *new_sheet)
+gnm_solver_param_dup (const SolverParameters *src_param, Sheet *new_sheet)
{
- SolverParameters *dst_param = solver_param_new (new_sheet);
+ SolverParameters *dst_param = gnm_solver_param_new (new_sheet);
GSList *constraints;
dst_param->problem_type = src_param->problem_type;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]