From 9ee5569bb118940d9831c0e9b8c181719add5780 Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Tue, 24 Sep 2013 01:24:00 +0200 Subject: [PATCH] Moved GsweHouseData to its own sources --- docs/reference/swe-glib/Makefile.am | 1 + docs/reference/swe-glib/swe-glib-docs.xml | 1 + docs/reference/swe-glib/swe-glib-sections.txt | 14 ++- src/Makefile.am | 2 + src/gswe-house-data-private.h | 41 +++++++ src/gswe-house-data.c | 101 ++++++++++++++++++ src/gswe-house-data.h | 47 ++++++++ src/gswe-types.c | 14 --- src/gswe-types.h | 19 ---- src/swe-glib-private.h | 1 + src/swe-glib.h | 1 + 11 files changed, 206 insertions(+), 36 deletions(-) create mode 100644 src/gswe-house-data-private.h create mode 100644 src/gswe-house-data.c create mode 100644 src/gswe-house-data.h diff --git a/docs/reference/swe-glib/Makefile.am b/docs/reference/swe-glib/Makefile.am index eebbb5a..a6be21c 100644 --- a/docs/reference/swe-glib/Makefile.am +++ b/docs/reference/swe-glib/Makefile.am @@ -70,6 +70,7 @@ IGNORE_HFILES = \ gswe-antiscion-axis-info-private.h \ gswe-antiscion-data-private.h \ gswe-house-system-info-private.h \ + gswe-house-data-private.h \ $(NULL) # Images to copy into HTML directory. diff --git a/docs/reference/swe-glib/swe-glib-docs.xml b/docs/reference/swe-glib/swe-glib-docs.xml index 06f629f..6542d99 100644 --- a/docs/reference/swe-glib/swe-glib-docs.xml +++ b/docs/reference/swe-glib/swe-glib-docs.xml @@ -28,6 +28,7 @@ + diff --git a/docs/reference/swe-glib/swe-glib-sections.txt b/docs/reference/swe-glib/swe-glib-sections.txt index 83cde30..dcf4f09 100644 --- a/docs/reference/swe-glib/swe-glib-sections.txt +++ b/docs/reference/swe-glib/swe-glib-sections.txt @@ -159,6 +159,17 @@ GSWE_TYPE_HOUSE_SYSTEM_INFO gswe_house_system_info_get_type +
+gswe-house-data +GsweHouseData +gswe_house_data_get_cusp_position +gswe_house_data_get_house +gswe_house_data_get_sign + +GSWE_TYPE_HOUSE_DATA +gswe_house_data_get_type +
+
gswe-timestamp GsweTimestamp @@ -213,12 +224,9 @@ GsweQuality GsweHouseSystem GsweMoonPhase GsweCoordinates -GsweHouseData GSWE_TYPE_COORDINATES -GSWE_TYPE_HOUSE_DATA gswe_coordinates_get_type -gswe_house_data_get_type
diff --git a/src/Makefile.am b/src/Makefile.am index b819a4c..3e34dc0 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -15,6 +15,7 @@ INST_H_SRC_FILES = \ gswe-antiscion-axis-info.h \ gswe-antiscion-data.h \ gswe-house-system-info.h \ + gswe-house-data.h \ gswe-moment.h \ gswe-timestamp.h \ $(NULL) @@ -36,6 +37,7 @@ libswe_glib_1_0_la_SOURCES = \ gswe-antiscion-axis-info.c \ gswe-antiscion-data.c \ gswe-house-system-info.c \ + gswe-house-data.c \ gswe-moment.c \ gswe-timestamp.c \ gswe-enumtypes.c \ diff --git a/src/gswe-house-data-private.h b/src/gswe-house-data-private.h new file mode 100644 index 0000000..98fe5dd --- /dev/null +++ b/src/gswe-house-data-private.h @@ -0,0 +1,41 @@ +/* gswe-house-data-private.h: Private parts of GsweHouseData + * + * 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_HOUSE_DATA_PRIVATE_H__ +#define __SWE_GLIB_GSWE_HOUSE_DATA_PRIVATE_H__ + +#include "gswe-house-data.h" + +struct _GsweHouseData { + /* the number of the house (usually in the range [1;12]. Sometimes may be [1;36]) */ + guint house; + + /* the position of the house's cusp on the sky */ + gdouble cusp_position; + + /* the #GsweSignInfo structure associated with the sign in which the house cusp is in */ + GsweSignInfo *sign; +}; + +GsweHouseData *gswe_house_data_copy(GsweHouseData *house_data); + +#endif /* __SWE_GLIB_GSWE_HOUSE_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-house-data.c b/src/gswe-house-data.c new file mode 100644 index 0000000..254ef93 --- /dev/null +++ b/src/gswe-house-data.c @@ -0,0 +1,101 @@ +/* gswe-house-data.c: House 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 "gswe-types.h" + +#include "gswe-house-data.h" +#include "gswe-house-data-private.h" + +/** + * SECTION:gswe-house-data + * @short_description: a structure representing a house's position-related data + * @title: GsweHouseData + * @stability: Stable + * @include: swe-glib.h + * @see_also: #GsweHouseSystemInfo + * + * #GsweHouseData is a structure that represents a house's position. + */ + +G_DEFINE_BOXED_TYPE(GsweHouseData, gswe_house_data, (GBoxedCopyFunc)gswe_house_data_copy, (GBoxedFreeFunc)g_free); + +GsweHouseData * +gswe_house_data_copy(GsweHouseData *house_data) +{ + GsweHouseData *ret = g_new0(GsweHouseData, 1); + + ret->house = house_data->house; + ret->cusp_position = house_data->cusp_position; + ret->sign = house_data->sign; + + return ret; +} + +/** + * gswe_house_data_get_house: + * @house_data: (in) (allow-none): a #GsweHouseData + * + * Gets the number of the house. + * + * Returns: the house number + */ +guint +gswe_house_data_get_house(GsweHouseData *house_data) +{ + if (house_data) { + return house_data->house; + } else { + return 0; + } +} + +/** + * gswe_house_data_get_cusp_position: + * @house_data: (in) (allow-none): a #GsweHouseData + * + * Gets the position of the house's cusp. + * + * Returns: the cusp position, in degrees + */ +gdouble +gswe_house_data_get_cusp_position(GsweHouseData *house_data) +{ + if (house_data) { + return house_data->cusp_position; + } else { + return 0.0; + } +} + +/** + * gswe_house_data_get_sign: + * @house_data: (in) (allow-none): a #GsweHouseData + * + * Gets the sign in which the house's cusp is. + * + * Returns: (transfer none): a #GsweSignInfo representing the sign + */ +GsweSignInfo * +gswe_house_data_get_sign(GsweHouseData *house_data) +{ + if (house_data) { + return house_data->sign; + } else { + return NULL; + } +} + diff --git a/src/gswe-house-data.h b/src/gswe-house-data.h new file mode 100644 index 0000000..93285d0 --- /dev/null +++ b/src/gswe-house-data.h @@ -0,0 +1,47 @@ +/* gswe-house-data.h: House 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_HOUSE_DATA_H__ +#define __SWE_GLIB_GSWE_HOUSE_DATA_H__ + +#include + +#include "gswe-sign-info.h" + +G_BEGIN_DECLS + +/** + * GsweHouseData: + * + * GsweHouseData is an opaque structure whose members + * cannot be accessed directly. + * + * Since: 1.1 + */ +typedef struct _GsweHouseData GsweHouseData; + +GType gswe_house_data_get_type(void); +#define GSWE_TYPE_HOUSE_DATA (gswe_house_data_get_type()) + +guint gswe_house_data_get_house(GsweHouseData *house_data); +gdouble gswe_house_data_get_cusp_position(GsweHouseData *house_data); +GsweSignInfo *gswe_house_data_get_sign(GsweHouseData *house_data); + +G_END_DECLS + +#endif /* __SWE_GLIB_GSWE_HOUSE_DATA_H__ */ + diff --git a/src/gswe-types.c b/src/gswe-types.c index 47124fa..8184d3a 100644 --- a/src/gswe-types.c +++ b/src/gswe-types.c @@ -32,17 +32,3 @@ gswe_coordinates_copy(GsweCoordinates *coordinates) G_DEFINE_BOXED_TYPE(GsweCoordinates, gswe_coordinates, (GBoxedCopyFunc)gswe_coordinates_copy, (GBoxedFreeFunc)g_free); -static GsweHouseData * -gswe_house_data_copy(GsweHouseData *house_data) -{ - GsweHouseData *ret = g_new0(GsweHouseData, 1); - - ret->house = house_data->house; - ret->cusp_position = house_data->cusp_position; - ret->sign = house_data->sign; - - return ret; -} - -G_DEFINE_BOXED_TYPE(GsweHouseData, gswe_house_data, (GBoxedCopyFunc)gswe_house_data_copy, (GBoxedFreeFunc)g_free); - diff --git a/src/gswe-types.h b/src/gswe-types.h index 5f73d9a..7c74c15 100644 --- a/src/gswe-types.h +++ b/src/gswe-types.h @@ -266,24 +266,5 @@ typedef struct _GsweCoordinates { GType gswe_coordinates_get_type(void); #define GSWE_TYPE_COORDINATES (gswe_coordinates_get_type()) -/** - * GsweHouseData: - * @house: the number of the house (usually in the range [1;12]. Sometimes may - * be [1;36]. - * @cusp_position: the position of the house's cusp on the sky - * @sign: the #GsweSignInfo structure associated with the sign in which the - * house cusp is in - * - * Holds information of a given house. - */ -typedef struct { - guint house; - gdouble cusp_position; - GsweSignInfo *sign; -} GsweHouseData; - -GType gswe_house_data_get_type(void); -#define GSWE_TYPE_HOUSE_DATA (gswe_house_data_get_type()) - #endif /* __SWE_GLIB_GSWE_TYPES_H__ */ diff --git a/src/swe-glib-private.h b/src/swe-glib-private.h index a7994c0..7071ea4 100644 --- a/src/swe-glib-private.h +++ b/src/swe-glib-private.h @@ -28,6 +28,7 @@ #include "gswe-antiscion-axis-info-private.h" #include "gswe-antiscion-data-private.h" #include "gswe-house-system-info-private.h" +#include "gswe-house-data-private.h" extern gchar *gswe_ephe_path; extern GsweTimestamp *gswe_full_moon_base_date; diff --git a/src/swe-glib.h b/src/swe-glib.h index 06fd701..88ae53f 100644 --- a/src/swe-glib.h +++ b/src/swe-glib.h @@ -29,6 +29,7 @@ #include "gswe-antiscion-axis-info.h" #include "gswe-antiscion-data.h" #include "gswe-house-system-info.h" +#include "gswe-house-data.h" #include "gswe-timestamp.h" #include "gswe-moment.h" #include "gswe-enumtypes.h"