]> saetta.ns0.it Git - libzakgflow/commitdiff
Added prototypes of process model and instance.
authorAndrea Zagli <azagli@libero.it>
Sun, 13 Mar 2016 09:38:36 +0000 (10:38 +0100)
committerAndrea Zagli <azagli@libero.it>
Sun, 13 Mar 2016 09:38:36 +0000 (10:38 +0100)
src/Makefile.am
src/instance.c [new file with mode: 0644]
src/instance.h [new file with mode: 0644]
src/libzakgflow.h
src/model.c [new file with mode: 0644]
src/model.h [new file with mode: 0644]

index 7e2a93f48c0a873fc5b37d7cbe247bd3bdfa3437..5b9d4064c4da6564b61a559704bef96edb1c0b63 100644 (file)
@@ -2,24 +2,21 @@ LIBS = $(ZAKGFLOW_LIBS)
 
 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)"
diff --git a/src/instance.c b/src/instance.c
new file mode 100644 (file)
index 0000000..744622d
--- /dev/null
@@ -0,0 +1,130 @@
+/*
+ * 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);
+}
diff --git a/src/instance.h b/src/instance.h
new file mode 100644 (file)
index 0000000..fc8a674
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * 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__ */
index 3f1ab4d2eb2957b8da4fd88236483320097004ca..1c95e6fab0f398e0699e3b0efc829e94b46154d8 100644 (file)
@@ -20,7 +20,8 @@
 #define __LIBZAKGFLOW_H__
 
 
-#include <libzakgflow/proc.h>
+#include <libzakgflow/model.h>
+#include <libzakgflow/instance.h>
 
 
 #endif /* __LIBZAKGFLOW_H__ */
diff --git a/src/model.c b/src/model.c
new file mode 100644 (file)
index 0000000..f895434
--- /dev/null
@@ -0,0 +1,241 @@
+/*
+ * 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);
+}
diff --git a/src/model.h b/src/model.h
new file mode 100644 (file)
index 0000000..aa6f1e8
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * 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__ */