From 0e179622780cf31802e4dec6b0d63fb3b311eaed Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Mon, 23 Sep 2013 20:13:56 +0200 Subject: [PATCH] Moved GsweAspectData to its own source files --- docs/reference/swe-glib/Makefile.am | 2 +- docs/reference/swe-glib/swe-glib-docs.xml | 1 + docs/reference/swe-glib/swe-glib-sections.txt | 17 +- src/Makefile.am | 2 + src/gswe-aspect-data-private.h | 50 ++++++ src/gswe-aspect-data.c | 164 ++++++++++++++++++ src/gswe-aspect-data.h | 52 ++++++ src/gswe-moment.c | 2 + src/gswe-types.c | 17 -- src/gswe-types.h | 24 --- src/swe-glib-private.h | 1 + src/swe-glib.c | 1 + src/swe-glib.h | 1 + 13 files changed, 289 insertions(+), 45 deletions(-) create mode 100644 src/gswe-aspect-data-private.h create mode 100644 src/gswe-aspect-data.c create mode 100644 src/gswe-aspect-data.h diff --git a/docs/reference/swe-glib/Makefile.am b/docs/reference/swe-glib/Makefile.am index d3df76a..8cf15c4 100644 --- a/docs/reference/swe-glib/Makefile.am +++ b/docs/reference/swe-glib/Makefile.am @@ -58,7 +58,7 @@ EXTRA_HFILES= # Header files or dirs to ignore when scanning. Use base file/dir names # e.g. IGNORE_HFILES=gtkdebug.h gtkintl.h private_code -IGNORE_HFILES=swe-glib-private.h gswe-enumtypes.h gswe-moon-phase-data-private.h +IGNORE_HFILES=swe-glib-private.h gswe-enumtypes.h gswe-moon-phase-data-private.h gswe-aspect-data-private.h # Images to copy into HTML directory. # e.g. HTML_IMAGES=$(top_srcdir)/gtk/stock-icons/stock_about_24.png diff --git a/docs/reference/swe-glib/swe-glib-docs.xml b/docs/reference/swe-glib/swe-glib-docs.xml index 8b6bcd8..0867198 100644 --- a/docs/reference/swe-glib/swe-glib-docs.xml +++ b/docs/reference/swe-glib/swe-glib-docs.xml @@ -20,6 +20,7 @@ SWE-GLib + diff --git a/docs/reference/swe-glib/swe-glib-sections.txt b/docs/reference/swe-glib/swe-glib-sections.txt index ec1cedf..4083d9d 100644 --- a/docs/reference/swe-glib/swe-glib-sections.txt +++ b/docs/reference/swe-glib/swe-glib-sections.txt @@ -55,6 +55,20 @@ GSWE_TYPE_MOON_PHASE_DATA gswe_moon_phase_data_get_type +
+gswe-aspect-data +GsweAspectData +gswe_aspect_data_get_planet1 +gswe_aspect_data_get_planet2 +gswe_aspect_data_get_distance +gswe_aspect_data_get_aspect +gswe_aspect_data_get_aspect_info +gswe_aspect_data_get_difference + +GSWE_TYPE_ASPECT_DATA +gswe_aspect_data_get_type +
+
gswe-timestamp GsweTimestamp @@ -116,16 +130,13 @@ GsweAntiscionAxisInfo GswePlanetData GsweCoordinates GsweHouseData -GsweAspectData GsweAntiscionData GSWE_TYPE_ANTISCION_DATA -GSWE_TYPE_ASPECT_DATA GSWE_TYPE_COORDINATES GSWE_TYPE_HOUSE_DATA GSWE_TYPE_PLANET_DATA gswe_antiscion_data_get_type -gswe_aspect_data_get_type gswe_coordinates_get_type gswe_house_data_get_type gswe_planet_data_get_type diff --git a/src/Makefile.am b/src/Makefile.am index e29af73..ef43843 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -7,6 +7,7 @@ INST_H_SRC_FILES = \ swe-glib.h \ gswe-types.h \ gswe-moon-phase-data.h \ + gswe-aspect-data.h \ gswe-moment.h \ gswe-timestamp.h @@ -19,6 +20,7 @@ libswe_glib_1_0_la_SOURCES = \ swe-glib.c \ gswe-types.c \ gswe-moon-phase-data.c \ + gswe-aspect-data.c \ gswe-moment.c \ gswe-timestamp.c \ gswe-enumtypes.c \ diff --git a/src/gswe-aspect-data-private.h b/src/gswe-aspect-data-private.h new file mode 100644 index 0000000..631a636 --- /dev/null +++ b/src/gswe-aspect-data-private.h @@ -0,0 +1,50 @@ +/* gswe-aspect-data-private.h: Private parts of GsweAspectData + * + * Copyright © 2013 Gergely Polonkai + * + * SWE-GLib is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * SWE-GLib 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this library; if not, see . + */ +#ifdef __SWE_GLIB_BUILDING__ +#ifndef __SWE_GLIB_GSWE_ASPECT_DATA_PRIVATE_H__ +#define __SWE_GLIB_GSWE_ASPECT_DATA_PRIVATE_H__ + +#include "gswe-aspect-data.h" +#include "gswe-planet-data.h" + +struct _GsweAspectData { + /* the first planet in the aspect */ + GswePlanetData *planet1; + + /* the second planet in the aspect */ + GswePlanetData *planet2; + + /* the distance between the two planets, in degrees */ + gdouble distance; + + /* the aspect between the two planets */ + GsweAspect aspect; + + /* the #GsweAspectInfo structure associated with the aspect */ + GsweAspectInfo *aspect_info; + + /* the difference in percent between an exact aspect and this given aspect */ + gdouble difference; +}; + +GsweAspectData *gswe_aspect_data_copy(GsweAspectData *aspect_data); + +#endif /* __SWE_GLIB_GSWE_ASPECT_DATA_PRIVATE_H__ */ +#else /* not defined __SWE_GLIB_BUILDING__ */ +#error __FILE__ "Can not be included, unless building SWE-GLib" +#endif /* __SWE_GLIB_BUILDING__ */ diff --git a/src/gswe-aspect-data.c b/src/gswe-aspect-data.c new file mode 100644 index 0000000..fd025f5 --- /dev/null +++ b/src/gswe-aspect-data.c @@ -0,0 +1,164 @@ +/* gswe-aspect-data.c: Aspect related data + * + * Copyright © 2013 Gergely Polonkai + * + * SWE-GLib is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * SWE-GLib 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this library; if not, see . + */ +#include + +#include "gswe-aspect-data.h" +#include "gswe-aspect-data-private.h" + +/** + * SECTION:gswe-aspect-data + * @short_description: Aspect related data + * @title: GsweAspectData + * @stability: Stable + * @include: swe-glib.h + * @see_also: #GsweAspectInfo + * + * #GsweAspectData is a structure that represents two planets relation to each + * other, like their aspect and the aspect's difference from an exact aspect. + */ +G_DEFINE_BOXED_TYPE(GsweAspectData, gswe_aspect_data, (GBoxedCopyFunc)gswe_aspect_data_copy, (GBoxedFreeFunc)g_free); + +GsweAspectData * +gswe_aspect_data_copy(GsweAspectData *aspect_data) +{ + GsweAspectData *ret; + + if (aspect_data == NULL) { + return NULL; + } + + ret = g_new0(GsweAspectData, 1); + + ret->planet1 = aspect_data->planet1; + ret->planet2 = aspect_data->planet2; + ret->distance = aspect_data->distance; + ret->aspect = aspect_data->aspect; + ret->aspect_info = aspect_data->aspect_info; + ret->difference = aspect_data->difference; + + return ret; +} + +/** + * gswe_aspect_data_get_planet1: + * @aspect_data: (in) (allow-none): a #GsweAspectData + * + * Gets the first planet in the aspect. + * + * Returns: (transfer none): The #GswePlanetData associated with the first planet + */ +GswePlanetData * +gswe_aspect_data_get_planet1(GsweAspectData *aspect_data) +{ + if (aspect_data) { + return aspect_data->planet1; + } else { + return NULL; + } +} + +/** + * gswe_aspect_data_get_planet2: + * @aspect_data: (in) (allow-none): a #GsweAspectData + * + * Gets the second planet in the aspect. + * + * Returns: (transfer none): The #GswePlanetData associated with the second planet + */ +GswePlanetData * +gswe_aspect_data_get_planet2(GsweAspectData *aspect_data) +{ + if (aspect_data) { + return aspect_data->planet2; + } else { + return NULL; + } +} + +/** + * gswe_aspect_data_get_distance: + * @aspect_data: (in) (allow-none): a #GsweAspectData + * + * Gets the exact distance between the two planets in the aspect. + * + * Returns: the distance, in degrees + */ +gdouble +gswe_aspect_data_get_distance(GsweAspectData *aspect_data) +{ + if (aspect_data) { + return aspect_data->distance; + } else { + return -1.0; + } +} + +/** + * gswe_aspect_data_get_aspect: + * @aspect_data: (in) (allow-none): a #GsweAspectData + * + * Gets the actual aspect between the two planets. + * + * Returns: the aspect ID + */ +GsweAspect +gswe_aspect_data_get_aspect(GsweAspectData *aspect_data) +{ + if (aspect_data) { + return aspect_data->aspect; + } else { + return GSWE_ASPECT_NONE; + } +} + +/** + * gswe_aspect_data_get_aspect_info: + * @aspect_data: (in) (allow-none): a #GsweAspectData + * + * Gets the the #GsweAspectInfo object for this aspect. + * + * Returns: (transfer none): a #GsweAspectInfo + */ +GsweAspectInfo * +gswe_aspect_data_get_aspect_info(GsweAspectData *aspect_data) +{ + if (aspect_data) { + return aspect_data->aspect_info; + } else { + return NULL; + } +} + +/** + * gswe_aspect_data_get_difference: + * @aspect_data: (in) (allow-none): a #GsweAspectData + * + * Gets the difference between an exact aspect and this one. + * + * Returns: the difference in pertent. + */ +gdouble +gswe_aspect_data_get_difference(GsweAspectData *aspect_data) +{ + if (aspect_data) { + return aspect_data->difference; + } else { + return -1.0; + } +} + diff --git a/src/gswe-aspect-data.h b/src/gswe-aspect-data.h new file mode 100644 index 0000000..ec9aebd --- /dev/null +++ b/src/gswe-aspect-data.h @@ -0,0 +1,52 @@ +/* gswe-aspect-data.h: Aspect related data + * + * Copyright © 2013 Gergely Polonkai + * + * SWE-GLib is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * SWE-GLib 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this library; if not, see . + */ +#ifndef __SWE_GLIB_GSWE_ASPECT_DATA_H__ +#define __SWE_GLIB_GSWE_ASPECT_DATA_H__ + +#include + +#include "gswe-types.h" +#include "gswe-aspect-info.h" +#include "gswe-planet-data.h" + +G_BEGIN_DECLS + +/** + * GsweAspectData: + * + * GsweAspectData is an opaque structure whose members + * cannot be accessed directly. + * + * Since: 1.1 + */ +typedef struct _GsweAspectData GsweAspectData; + +GType gswe_aspect_data_get_type(void); +#define GSWE_TYPE_ASPECT_DATA (gswe_aspect_data_get_type()) + +GswePlanetData *gswe_aspect_data_get_planet1(GsweAspectData *aspect_data); +GswePlanetData *gswe_aspect_data_get_planet2(GsweAspectData *aspect_data); +gdouble gswe_aspect_data_get_distance(GsweAspectData *aspect_data); +GsweAspect gswe_aspect_data_get_aspect(GsweAspectData *aspect_data); +GsweAspectInfo *gswe_aspect_data_get_aspect_info(GsweAspectData *aspect_data); +gdouble gswe_aspect_data_get_difference(GsweAspectData *aspect_data); + +G_END_DECLS + +#endif /* __SWE_GLIB_GSWE_ASPECT_DATA_H__ */ + diff --git a/src/gswe-moment.c b/src/gswe-moment.c index 1b6e5ae..5f7fa06 100644 --- a/src/gswe-moment.c +++ b/src/gswe-moment.c @@ -17,6 +17,8 @@ */ #include "swe-glib.h" #include "gswe-types.h" +#include "gswe-aspect-data.h" +#include "gswe-aspect-data-private.h" #include "gswe-moment.h" #include "swe-glib-private.h" diff --git a/src/gswe-types.c b/src/gswe-types.c index 9fe62f8..7372aed 100644 --- a/src/gswe-types.c +++ b/src/gswe-types.c @@ -64,23 +64,6 @@ gswe_house_data_copy(GsweHouseData *house_data) G_DEFINE_BOXED_TYPE(GsweHouseData, gswe_house_data, (GBoxedCopyFunc)gswe_house_data_copy, (GBoxedFreeFunc)g_free); -static GsweAspectData * -gswe_aspect_data_copy(GsweAspectData *aspect_data) -{ - GsweAspectData *ret = g_new0(GsweAspectData, 1); - - ret->planet1 = aspect_data->planet1; - ret->planet2 = aspect_data->planet2; - ret->distance = aspect_data->distance; - ret->aspect = aspect_data->aspect; - ret->aspect_info = aspect_data->aspect_info; - ret->difference = aspect_data->difference; - - return ret; -} - -G_DEFINE_BOXED_TYPE(GsweAspectData, gswe_aspect_data, (GBoxedCopyFunc)gswe_aspect_data_copy, (GBoxedFreeFunc)g_free); - static GsweAntiscionData * gswe_antiscion_data_copy(GsweAntiscionData *antiscion_data) { diff --git a/src/gswe-types.h b/src/gswe-types.h index 3add4cb..2e5fb1d 100644 --- a/src/gswe-types.h +++ b/src/gswe-types.h @@ -414,30 +414,6 @@ typedef struct { GType gswe_house_data_get_type(void); #define GSWE_TYPE_HOUSE_DATA (gswe_house_data_get_type()) -/** - * GsweAspectData: - * @planet1: the first planet in the aspect - * @planet2: the second planet in the aspect - * @distance: the distance between the two planets, in degrees - * @aspect: the aspect between the two planets - * @aspect_info: the #GsweAspectInfo structure associated with the aspect - * @difference: the difference in percent between an exact aspect and this - * given aspect - * - * Holds information about a given aspect. - */ -typedef struct { - GswePlanetData *planet1; - GswePlanetData *planet2; - gdouble distance; - GsweAspect aspect; - GsweAspectInfo *aspect_info; - gdouble difference; -} GsweAspectData; - -GType gswe_aspect_data_get_type(void); -#define GSWE_TYPE_ASPECT_DATA (gswe_aspect_data_get_type()) - /** * GsweAntiscionData: * @planet1: the first planet in the antiscion diff --git a/src/swe-glib-private.h b/src/swe-glib-private.h index d5bd40b..a6e8f76 100644 --- a/src/swe-glib-private.h +++ b/src/swe-glib-private.h @@ -20,6 +20,7 @@ #include "gswe-timestamp.h" #include "gswe-types.h" #include "gswe-moon-phase-data-private.h" +#include "gswe-aspect-data-private.h" extern gchar *gswe_ephe_path; extern GsweTimestamp *gswe_full_moon_base_date; diff --git a/src/swe-glib.c b/src/swe-glib.c index 08667e6..a8b29fc 100644 --- a/src/swe-glib.c +++ b/src/swe-glib.c @@ -21,6 +21,7 @@ #include "../swe/src/swephexp.h" #include "swe-glib.h" +#include "swe-glib-private.h" /** * SECTION:swe-glib diff --git a/src/swe-glib.h b/src/swe-glib.h index 3145d8a..beceaf0 100644 --- a/src/swe-glib.h +++ b/src/swe-glib.h @@ -20,6 +20,7 @@ #include #include "gswe-types.h" +#include "gswe-aspect-data.h" #include "gswe-timestamp.h" #include "gswe-moment.h" #include "gswe-enumtypes.h"