diff --git a/docs/reference/swe-glib/Makefile.am b/docs/reference/swe-glib/Makefile.am index 703f53d..eebbb5a 100644 --- a/docs/reference/swe-glib/Makefile.am +++ b/docs/reference/swe-glib/Makefile.am @@ -69,6 +69,7 @@ IGNORE_HFILES = \ gswe-aspect-data-private.h \ gswe-antiscion-axis-info-private.h \ gswe-antiscion-data-private.h \ + gswe-house-system-info-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 f5ecd6f..06f629f 100644 --- a/docs/reference/swe-glib/swe-glib-docs.xml +++ b/docs/reference/swe-glib/swe-glib-docs.xml @@ -27,6 +27,7 @@ + diff --git a/docs/reference/swe-glib/swe-glib-sections.txt b/docs/reference/swe-glib/swe-glib-sections.txt index 7983390..83cde30 100644 --- a/docs/reference/swe-glib/swe-glib-sections.txt +++ b/docs/reference/swe-glib/swe-glib-sections.txt @@ -148,6 +148,17 @@ GSWE_TYPE_ANTISCION_DATA gswe_antiscion_data_get_type +
+gswe-house-system-info +GsweHouseSystemInfo +gswe_house_system_info_get_house_system +gswe_house_system_info_get_name +gswe_house_system_info_get_sweph_id + +GSWE_TYPE_HOUSE_SYSTEM_INFO +gswe_house_system_info_get_type +
+
gswe-timestamp GsweTimestamp @@ -201,7 +212,6 @@ GsweElement GsweQuality GsweHouseSystem GsweMoonPhase -GsweHouseSystemInfo GsweCoordinates GsweHouseData diff --git a/src/Makefile.am b/src/Makefile.am index 97408bc..b819a4c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -14,6 +14,7 @@ INST_H_SRC_FILES = \ gswe-aspect-data.h \ gswe-antiscion-axis-info.h \ gswe-antiscion-data.h \ + gswe-house-system-info.h \ gswe-moment.h \ gswe-timestamp.h \ $(NULL) @@ -34,6 +35,7 @@ libswe_glib_1_0_la_SOURCES = \ gswe-aspect-data.c \ gswe-antiscion-axis-info.c \ gswe-antiscion-data.c \ + gswe-house-system-info.c \ gswe-moment.c \ gswe-timestamp.c \ gswe-enumtypes.c \ diff --git a/src/gswe-house-system-info-private.h b/src/gswe-house-system-info-private.h new file mode 100644 index 0000000..a276d3f --- /dev/null +++ b/src/gswe-house-system-info-private.h @@ -0,0 +1,44 @@ +/* gswe-house-system-info-private.h: Private parts of GsweHouseSystemInfo + * + * 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_SYSTEM_INFO_PRIVATE_H__ +#define __SWE_GLIB_GSWE_HOUSE_SYSTEM_INFO_PRIVATE_H__ + +#include "gswe-types.h" + +#include "gswe-house-system-info.h" + +struct _GsweHouseSystemInfo { + /* the house system's ID */ + GsweHouseSystem house_system; + + /* the character value that represents this house system in the Swiss Ephemeris library */ + gchar sweph_id; + + /* the name of this house system */ + gchar *name; +}; + +GsweHouseSystemInfo *gswe_house_system_info_copy(GsweHouseSystemInfo *house_system_info); +void gswe_house_system_info_free(GsweHouseSystemInfo *house_system_info); + +#endif /* __SWE_GLIB_GSWE_HOUSE_SYSTEM_INFO_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-system-info.c b/src/gswe-house-system-info.c new file mode 100644 index 0000000..34d096f --- /dev/null +++ b/src/gswe-house-system-info.c @@ -0,0 +1,116 @@ +/* gswe-house-system-info.c: House system information + * + * 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-system-info.h" +#include "gswe-house-system-info-private.h" + +/** + * SECTION:gswe-house-system-info + * @short_description: a structure storing information about a house system + * @title: GsweHouseSystemInfo + * @stability: Stable + * @include: swe-glib.h + * + * #GsweHouseSystemInfo stores information of a house system. + */ + +G_DEFINE_BOXED_TYPE(GsweHouseSystemInfo, gswe_house_system_info, (GBoxedCopyFunc)gswe_house_system_info_copy, (GBoxedFreeFunc)gswe_house_system_info_free); + +GsweHouseSystemInfo * +gswe_house_system_info_copy(GsweHouseSystemInfo *house_system_info) +{ + GsweHouseSystemInfo *ret; + + if (house_system_info == NULL) { + return NULL; + } + + ret = g_new0(GsweHouseSystemInfo, 1); + ret->house_system = house_system_info->house_system; + ret->sweph_id = house_system_info->sweph_id; + ret->name = g_strdup(house_system_info->name); + + return ret; +} + +void +gswe_house_system_info_free(GsweHouseSystemInfo *house_system_info) +{ + if (house_system_info) { + if (house_system_info->name) { + g_free(house_system_info->name); + } + + g_free(house_system_info); + } +} + +/** + * gswe_house_system_info_get_house_system: + * @house_system_info: (in) (allow-none): a #GsweHouseSystemInfo + * + * Gets the house system ID this #GsweHouseSystemInfo represents. + * + * Returns: the house system ID + */ +GsweHouseSystem +gswe_house_system_info_get_house_system(GsweHouseSystemInfo *house_system_info) +{ + if (house_system_info) { + return house_system_info->house_system; + } else { + return GSWE_HOUSE_SYSTEM_NONE; + } +} + +/** + * gswe_house_system_info_get_sweph_id: + * @house_system_info: (in) (allow-none): a #GsweHouseSystemInfo + * + * Gets the Swiss Ephemeris ID for the house system. + * + * Returns: the character representing this house system in Swiss Ephemeris + */ +gchar +gswe_house_system_info_get_sweph_id(GsweHouseSystemInfo *house_system_info) +{ + if (house_system_info) { + return house_system_info->sweph_id; + } else { + return 0; + } +} + +/** + * gswe_house_system_info_get_name: + * @house_system_info: (in) (allow-none): a #GsweHouseSystemInfo + * + * Gets the name of the house system. + * + * Returns: (transfer none): the name of the house system + */ +const gchar * +gswe_house_system_info_get_name(GsweHouseSystemInfo *house_system_info) +{ + if (house_system_info) { + return house_system_info->name; + } else { + return NULL; + } +} + diff --git a/src/gswe-house-system-info.h b/src/gswe-house-system-info.h new file mode 100644 index 0000000..c4c9b45 --- /dev/null +++ b/src/gswe-house-system-info.h @@ -0,0 +1,47 @@ +/* gswe-house-system-info.h: House system information + * + * 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_SYSTEM_INFO_H__ +#define __SWE_GLIB_GSWE_HOUSE_SYSTEM_INFO_H__ + +#include + +#include "gswe-types.h" + +G_BEGIN_DECLS + +/** + * GsweHouseSystemInfo: + * + * GsweHouseSystemInfo is an opaque structure whose members + * cannot be accessed directly. + * + * Since: 1.1 + */ +typedef struct _GsweHouseSystemInfo GsweHouseSystemInfo; + +GType gswe_house_system_info_get_type(void); +#define GSWE_TYPE_HOUSE_SYSTEM_INFO (gswe_house_system_info_get_type()) + +GsweHouseSystem gswe_house_system_info_get_house_system(GsweHouseSystemInfo *house_system_info); +gchar gswe_house_system_info_get_sweph_id(GsweHouseSystemInfo *house_system_info); +const gchar *gswe_house_system_info_get_name(GsweHouseSystemInfo *house_system_info); + +G_END_DECLS + +#endif /* __SWE_GLIB_GSWE_HOUSE_SYSTEM_INFO_H__ */ + diff --git a/src/gswe-types.h b/src/gswe-types.h index cf94d8b..5f73d9a 100644 --- a/src/gswe-types.h +++ b/src/gswe-types.h @@ -249,20 +249,6 @@ typedef enum { GSWE_MOON_PHASE_DARK } GsweMoonPhase; -/** - * GsweHouseSystemInfo: - * @system: the house system's ID - * @sweph_id: the character value that represents this house system in the Swiss Ephemeris library - * @name: the name of this house system - * - * Holds information about house systems known by SWE-GLib. - */ -typedef struct { - GsweHouseSystem system; - gchar sweph_id; - gchar *name; -} GsweHouseSystemInfo; - /** * GsweCoordinates: * @longitude: longitude part of the coordinates diff --git a/src/swe-glib-private.h b/src/swe-glib-private.h index bd11548..a7994c0 100644 --- a/src/swe-glib-private.h +++ b/src/swe-glib-private.h @@ -27,6 +27,7 @@ #include "gswe-aspect-data-private.h" #include "gswe-antiscion-axis-info-private.h" #include "gswe-antiscion-data-private.h" +#include "gswe-house-system-info-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 9905aab..6ec2801 100644 --- a/src/swe-glib.c +++ b/src/swe-glib.c @@ -63,7 +63,7 @@ GsweTimestamp *gswe_full_moon_base_date; #define ADD_HOUSE_SYSTEM(ht, v, i, s, n) \ (v) = g_new0(GsweHouseSystemInfo, 1); \ - (v)->system = i; \ + (v)->house_system = i; \ (v)->sweph_id = s; \ (v)->name = g_strdup(n); \ g_hash_table_replace((ht), GINT_TO_POINTER(i), (v)); diff --git a/src/swe-glib.h b/src/swe-glib.h index 9a90d3f..06fd701 100644 --- a/src/swe-glib.h +++ b/src/swe-glib.h @@ -28,6 +28,7 @@ #include "gswe-aspect-data.h" #include "gswe-antiscion-axis-info.h" #include "gswe-antiscion-data.h" +#include "gswe-house-system-info.h" #include "gswe-timestamp.h" #include "gswe-moment.h" #include "gswe-enumtypes.h"