AM_CPPFLAGS = $(ZAKGFLOW_CFLAGS) \
-DLOCALEDIR=\"$(localedir)\" \
- -DMODULESDIR=\""$(libdir)/$(PACKAGE)/modules"\" \
-DG_LOG_DOMAIN=\"ZakGFlow\"
lib_LTLIBRARIES = libzakgflow.la
libzakgflow_la_SOURCES = \
- commons.c
+ commons.c \
+ instance.c \
+ model.c
libzakgflow_la_LDFLAGS = -no-undefined
libzakgflow_include_HEADERS = \
libzakgflow.h \
- commons.h
+ commons.h \
+ instance.h \
+ model.h
libzakgflow_includedir = $(includedir)/libzakgflow
-
-install-exec-hook:
- mkdir -p "$(libdir)/$(PACKAGE)/modules"
-
-uninstall-hook:
- rm -rf "$(libdir)/$(PACKAGE)"
--- /dev/null
+/*
+ * Copyright (C) 2016 Andrea Zagli <azagli@libero.it>
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+ #include <config.h>
+#endif
+
+#include <glib/gi18n-lib.h>
+#include <gmodule.h>
+
+#include <libxml/xpath.h>
+
+#include "instance.h"
+
+#ifdef G_OS_WIN32
+ #include <windows.h>
+#endif
+
+static void zak_gflow_instance_class_init (ZakGFlowInstanceClass *class);
+static void zak_gflow_instance_init (ZakGFlowInstance *zak_gflow_instance);
+
+static void zak_gflow_instance_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void zak_gflow_instance_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
+
+static void zak_gflow_instance_dispose (GObject *gobject);
+static void zak_gflow_instance_finalize (GObject *gobject);
+
+typedef struct
+ {
+ } ZakGFlowInstancePrivate;
+
+G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (ZakGFlowInstance, zak_gflow_instance, G_TYPE_OBJECT)
+
+static void
+zak_gflow_instance_class_init (ZakGFlowInstanceClass *class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (class);
+
+ object_class->set_property = zak_gflow_instance_set_property;
+ object_class->get_property = zak_gflow_instance_get_property;
+ object_class->dispose = zak_gflow_instance_dispose;
+ object_class->finalize = zak_gflow_instance_finalize;
+}
+
+static void
+zak_gflow_instance_init (ZakGFlowInstance *zak_gflow_instance)
+{
+ ZakGFlowInstancePrivate *priv = zak_gflow_instance_get_instance_private (zak_gflow_instance);
+
+}
+
+/* PRIVATE */
+static void
+zak_gflow_instance_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ ZakGFlowInstance *zak_gflow_instance = (ZakGFlowInstance *)object;
+ ZakGFlowInstancePrivate *priv = zak_gflow_instance_get_instance_private (zak_gflow_instance);
+
+ switch (property_id)
+ {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+zak_gflow_instance_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ ZakGFlowInstance *zak_gflow_instance = (ZakGFlowInstance *)object;
+ ZakGFlowInstancePrivate *priv = zak_gflow_instance_get_instance_private (zak_gflow_instance);
+
+ switch (property_id)
+ {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+zak_gflow_instance_dispose (GObject *gobject)
+{
+ ZakGFlowInstance *zak_gflow_instance = (ZakGFlowInstance *)gobject;
+ ZakGFlowInstancePrivate *priv = zak_gflow_instance_get_instance_private (zak_gflow_instance);
+
+
+
+ GObjectClass *parent_class = g_type_class_peek_parent (G_OBJECT_GET_CLASS (gobject));
+ parent_class->dispose (gobject);
+}
+
+static void
+zak_gflow_instance_finalize (GObject *gobject)
+{
+ ZakGFlowInstance *zak_gflow_instance = (ZakGFlowInstance *)gobject;
+ ZakGFlowInstancePrivate *priv = zak_gflow_instance_get_instance_private (zak_gflow_instance);
+
+
+
+ GObjectClass *parent_class = g_type_class_peek_parent (G_OBJECT_GET_CLASS (gobject));
+ parent_class->finalize (gobject);
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 Andrea Zagli <azagli@libero.it>
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __ZAK_GFLOW_INSTANCE_H__
+#define __ZAK_GFLOW_INSTANCE_H__
+
+
+#include <glib-object.h>
+
+#include <libxml/tree.h>
+
+
+G_BEGIN_DECLS
+
+
+#define ZAK_GFLOW_TYPE_INSTANCE zak_gflow_instance_get_type ()
+G_DECLARE_DERIVABLE_TYPE (ZakGFlowInstance, zak_gflow_instance, ZAK_GFLOW, INSTANCE, GObject)
+
+struct _ZakGFlowInstanceClass
+{
+ GObjectClass parent_class;
+};
+
+
+
+
+G_END_DECLS
+
+
+#endif /* __ZAK_GFLOW_INSTANCE_H__ */
#define __LIBZAKGFLOW_H__
-#include <libzakgflow/proc.h>
+#include <libzakgflow/model.h>
+#include <libzakgflow/instance.h>
#endif /* __LIBZAKGFLOW_H__ */
--- /dev/null
+/*
+ * Copyright (C) 2016 Andrea Zagli <azagli@libero.it>
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+ #include <config.h>
+#endif
+
+#include <glib/gi18n-lib.h>
+#include <gmodule.h>
+
+#include <libxml/xpath.h>
+
+#include "model.h"
+
+#ifdef G_OS_WIN32
+ #include <windows.h>
+#endif
+
+static void zak_gflow_model_class_init (ZakGFlowModelClass *class);
+static void zak_gflow_model_init (ZakGFlowModel *zak_gflow_model);
+
+static void zak_gflow_model_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void zak_gflow_model_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
+
+static void zak_gflow_model_dispose (GObject *gobject);
+static void zak_gflow_model_finalize (GObject *gobject);
+
+typedef struct
+ {
+ } ZakGFlowModelPrivate;
+
+G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (ZakGFlowModel, zak_gflow_model, G_TYPE_OBJECT)
+
+#ifdef G_OS_WIN32
+static HMODULE backend_dll = NULL;
+
+BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved);
+
+BOOL WINAPI
+DllMain (HINSTANCE hinstDLL,
+ DWORD fdwReason,
+ LPVOID lpReserved)
+{
+ switch (fdwReason)
+ {
+ case DLL_MODELESS_ATTACH:
+ backend_dll = (HMODULE) hinstDLL;
+ break;
+ case DLL_THREAD_ATTACH:
+ case DLL_THREAD_DETACH:
+ case DLL_MODELESS_DETACH:
+ break;
+ }
+ return TRUE;
+}
+#endif
+
+static void
+zak_gflow_model_class_init (ZakGFlowModelClass *class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (class);
+
+ object_class->set_property = zak_gflow_model_set_property;
+ object_class->get_property = zak_gflow_model_get_property;
+ object_class->dispose = zak_gflow_model_dispose;
+ object_class->finalize = zak_gflow_model_finalize;
+}
+
+static void
+zak_gflow_model_init (ZakGFlowModel *zak_gflow_model)
+{
+ gchar *localedir;
+
+ ZakGFlowModelPrivate *priv = zak_gflow_model_get_instance_private (zak_gflow_model);
+
+#ifdef G_OS_WIN32
+
+ gchar *moddir;
+ gchar *p;
+
+ moddir = g_win32_get_package_installation_directory_of_module (backend_dll);
+
+ p = g_strrstr (moddir, g_strdup_printf ("%c", G_DIR_SEPARATOR));
+ if (p != NULL
+ && (g_ascii_strcasecmp (p + 1, "src") == 0
+ || g_ascii_strcasecmp (p + 1, ".libs") == 0))
+ {
+ localedir = g_strdup (LOCALEDIR);
+ }
+ else
+ {
+ localedir = g_build_filename (moddir, "share", "locale", NULL);
+ }
+
+ g_free (moddir);
+
+#else
+
+ localedir = g_strdup (LOCALEDIR);
+
+#endif
+
+ bindtextdomain (GETTEXT_PACKAGE, localedir);
+ textdomain (GETTEXT_PACKAGE);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+}
+
+/**
+ * zak_gflow_model_load_from_xml:
+ * @zakmodel:
+ * @xmldoc:
+ *
+ */
+gboolean
+zak_gflow_model_load_from_xml (ZakGFlowModel *zakmodel, xmlDoc *xmldoc)
+{
+ ZakGFlowModelPrivate *priv;
+ xmlNode *cur;
+ xmlNode *cur_clean;
+
+ gboolean ret;
+
+ g_return_val_if_fail (ZAK_GFLOW_IS_MODEL (zakmodel), FALSE);
+ g_return_val_if_fail (xmldoc != NULL, FALSE);
+
+ ret = FALSE;
+
+ cur = xmlDocGetRootElement (xmldoc);
+ if (cur != NULL)
+ {
+ }
+
+ return ret;
+}
+
+/**
+ * zak_gflow_model_load_from_file:
+ * @zakmodel:
+ * @filename:
+ *
+ */
+gboolean
+zak_gflow_model_load_from_file (ZakGFlowModel *zakmodel, const gchar *filename)
+{
+ xmlDoc *xdoc;
+
+ gboolean ret;
+
+ g_return_val_if_fail (ZAK_GFLOW_IS_MODEL (zakmodel), FALSE);
+ g_return_val_if_fail (filename != NULL, FALSE);
+
+ ret = FALSE;
+
+ xdoc = xmlParseFile (filename);
+ if (xdoc != NULL)
+ {
+ ret = zak_gflow_model_load_from_xml (zakmodel, xdoc);
+ }
+
+ return ret;
+}
+
+/* PRIVATE */
+static void
+zak_gflow_model_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ ZakGFlowModel *zak_gflow_model = (ZakGFlowModel *)object;
+ ZakGFlowModelPrivate *priv = zak_gflow_model_get_instance_private (zak_gflow_model);
+
+ switch (property_id)
+ {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+zak_gflow_model_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ ZakGFlowModel *zak_gflow_model = (ZakGFlowModel *)object;
+ ZakGFlowModelPrivate *priv = zak_gflow_model_get_instance_private (zak_gflow_model);
+
+ switch (property_id)
+ {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+zak_gflow_model_dispose (GObject *gobject)
+{
+ ZakGFlowModel *zak_gflow_model = (ZakGFlowModel *)gobject;
+ ZakGFlowModelPrivate *priv = zak_gflow_model_get_instance_private (zak_gflow_model);
+
+
+
+ GObjectClass *parent_class = g_type_class_peek_parent (G_OBJECT_GET_CLASS (gobject));
+ parent_class->dispose (gobject);
+}
+
+static void
+zak_gflow_model_finalize (GObject *gobject)
+{
+ ZakGFlowModel *zak_gflow_model = (ZakGFlowModel *)gobject;
+ ZakGFlowModelPrivate *priv = zak_gflow_model_get_instance_private (zak_gflow_model);
+
+
+
+ GObjectClass *parent_class = g_type_class_peek_parent (G_OBJECT_GET_CLASS (gobject));
+ parent_class->finalize (gobject);
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 Andrea Zagli <azagli@libero.it>
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __ZAK_GFLOW_MODEL_H__
+#define __ZAK_GFLOW_MODEL_H__
+
+
+#include <glib-object.h>
+
+#include <libxml/tree.h>
+
+
+#include "instance.h"
+
+
+G_BEGIN_DECLS
+
+
+#define ZAK_GFLOW_TYPE_MODEL zak_gflow_model_get_type ()
+G_DECLARE_DERIVABLE_TYPE (ZakGFlowModel, zak_gflow_model, ZAK_GFLOW, MODEL, GObject)
+
+struct _ZakGFlowModelClass
+{
+ GObjectClass parent_class;
+};
+
+
+gboolean zak_gflow_model_load_from_xml (ZakGFlowModel *model, xmlDoc *xmldoc);
+gboolean zak_gflow_model_load_from_file (ZakGFlowModel *model, const gchar *filename);
+
+ZakGFlowInstance *zak_gflow_model_start (ZakGFlowModel *model, const gchar *model_id);
+
+
+G_END_DECLS
+
+
+#endif /* __ZAK_GFLOW_MODEL_H__ */