/* gcalc-math-expression.c generated by valac 0.56.0, the Vala compiler
 * generated from gcalc-math-expression.vala, do not modify */

/* gcalc-math-expresion.vala
 *
 * Copyright (C) 2018  Daniel Espinosa <esodan@gmail.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.

 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
 *
 * Authors:
 *      Daniel Espinosa <esodan@gmail.com>
 */

#include "gcalc/gcalc.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include "gcalc.h"

static GType gcalc_math_expression_get_type_once (void);

/**
   * Creates a string representation of the expression
   */
gchar*
gcalc_math_expression_to_string (GCalcMathExpression* self)
{
	GCalcMathExpressionIface* _iface_;
	g_return_val_if_fail (self != NULL, NULL);
	_iface_ = GCALC_MATH_EXPRESSION_GET_INTERFACE (self);
	if (_iface_->to_string) {
		return _iface_->to_string (self);
	}
	return NULL;
}

/**
   * Solves the expression and returning a {@link MathResult}
   */
GCalcMathResult*
gcalc_math_expression_solve (GCalcMathExpression* self)
{
	GCalcMathExpressionIface* _iface_;
	g_return_val_if_fail (self != NULL, NULL);
	_iface_ = GCALC_MATH_EXPRESSION_GET_INTERFACE (self);
	if (_iface_->solve) {
		return _iface_->solve (self);
	}
	return NULL;
}

GCalcMathExpression*
gcalc_math_expression_get_parent (GCalcMathExpression* self)
{
	GCalcMathExpressionIface* _iface_;
	g_return_val_if_fail (self != NULL, NULL);
	_iface_ = GCALC_MATH_EXPRESSION_GET_INTERFACE (self);
	if (_iface_->get_parent) {
		return _iface_->get_parent (self);
	}
	return NULL;
}

void
gcalc_math_expression_set_parent (GCalcMathExpression* self,
                                  GCalcMathExpression* value)
{
	GCalcMathExpressionIface* _iface_;
	g_return_if_fail (self != NULL);
	_iface_ = GCALC_MATH_EXPRESSION_GET_INTERFACE (self);
	if (_iface_->set_parent) {
		_iface_->set_parent (self, value);
	}
}

GCalcExpressionContainer*
gcalc_math_expression_get_expressions (GCalcMathExpression* self)
{
	GCalcMathExpressionIface* _iface_;
	g_return_val_if_fail (self != NULL, NULL);
	_iface_ = GCALC_MATH_EXPRESSION_GET_INTERFACE (self);
	if (_iface_->get_expressions) {
		return _iface_->get_expressions (self);
	}
	return NULL;
}

static void
gcalc_math_expression_default_init (GCalcMathExpressionIface * iface,
                                    gpointer iface_data)
{
	/**
	   * Parent of the expression
	   */
	g_object_interface_install_property (iface, g_param_spec_object ("parent", "parent", "parent", GCALC_TYPE_MATH_EXPRESSION, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/**
	   * Child expressions
	   */
	g_object_interface_install_property (iface, g_param_spec_object ("expressions", "expressions", "expressions", GCALC_TYPE_EXPRESSION_CONTAINER, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

/**
 * A part of a math equation
 */
static GType
gcalc_math_expression_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GCalcMathExpressionIface), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gcalc_math_expression_default_init, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL };
	GType gcalc_math_expression_type_id;
	gcalc_math_expression_type_id = g_type_register_static (G_TYPE_INTERFACE, "GCalcMathExpression", &g_define_type_info, 0);
	g_type_interface_add_prerequisite (gcalc_math_expression_type_id, G_TYPE_OBJECT);
	return gcalc_math_expression_type_id;
}

GType
gcalc_math_expression_get_type (void)
{
	static volatile gsize gcalc_math_expression_type_id__once = 0;
	if (g_once_init_enter (&gcalc_math_expression_type_id__once)) {
		GType gcalc_math_expression_type_id;
		gcalc_math_expression_type_id = gcalc_math_expression_get_type_once ();
		g_once_init_leave (&gcalc_math_expression_type_id__once, gcalc_math_expression_type_id);
	}
	return gcalc_math_expression_type_id__once;
}

