]> err.no Git - mapper/blobdiff - src/path.h
Include settings.h so the banner macro hildon version works.
[mapper] / src / path.h
index 7d0f0d728e308d090fa2dfeca6ea20a1758c9e26..108c25a03d27d224df914cc33139549d994b775c 100644 (file)
@@ -1,7 +1,82 @@
 #ifndef _PATH_H
 #define _PATH_H
 
+#include <glib.h>
+#include <gtk/gtk.h>
+
+#define MACRO_PATH_INIT(path) { \
+    (path).head = (path).tail = g_new0(Point, ARRAY_CHUNK_SIZE); \
+    *((path).tail) = _point_null; \
+    (path).cap = (path).head + ARRAY_CHUNK_SIZE; \
+    (path).whead = g_new0(WayPoint, ARRAY_CHUNK_SIZE); \
+    (path).wtail = (path).whead - 1; \
+    (path).wcap = (path).whead + ARRAY_CHUNK_SIZE; \
+}
+
+#define MACRO_PATH_FREE(path) if((path).head) { \
+    WayPoint *curr; \
+    g_free((path).head); \
+    (path).head = (path).tail = (path).cap = NULL; \
+    for(curr = (path).whead - 1; curr++ != (path).wtail; ) \
+        g_free(curr->desc); \
+    g_free((path).whead); \
+    (path).whead = (path).wtail = (path).wcap = NULL; \
+}
+
+#define MACRO_PATH_INCREMENT_TAIL(route) { \
+    if(++(route).tail == (route).cap) \
+        path_resize(&(route), (route).cap - (route).head + ARRAY_CHUNK_SIZE);\
+}
+
+#define MACRO_PATH_INCREMENT_WTAIL(route) { \
+    if(++(route).wtail == (route).wcap) \
+        path_wresize(&(route), \
+                (route).wcap - (route).whead + ARRAY_CHUNK_SIZE); \
+}
+
+/** A lat/lon/alt position */
+typedef struct _Position Position;
+struct _Position {
+       gdouble lat;
+       gdouble lon;
+       gfloat altitude;
+       gboolean valid;
+};
+
+/** A general definition of a point in the Mapper unit system. */
+typedef struct _Point Point;
+struct _Point {
+       guint unitx;
+       guint unity;
+       time_t time;
+       gfloat altitude;
+};
+
+/** A WayPoint, which is a Point with a description. */
+typedef struct _WayPoint WayPoint;
+struct _WayPoint {
+       Point *point;
+       gchar *desc;
+};
+
+/** A Path is a set of PathPoints and WayPoints. */
+typedef struct _Path Path;
+struct _Path {
+       Point *head;            /* points to first element in array; NULL if empty. */
+       Point *tail;            /* points to last element in array. */
+       Point *cap;             /* points after last slot in array. */
+       WayPoint *whead;        /* points to first element in array; NULL if empty. */
+       WayPoint *wtail;        /* points to last element in array. */
+       WayPoint *wcap;         /* points after last slot in array. */
+};
+
+Point _point_null;
+Position _home;
+Position _dest;
+
 void path_resize(Path *path, guint size);
 void path_wresize(Path *path, guint wsize);
 
+GtkListStore *path_generate_store(Path *path);
+
 #endif