Moved GsweAspectData to its own source files

This commit is contained in:
Gergely Polonkai 2013-09-23 20:13:56 +02:00
parent 14bef9eb06
commit 0e17962278
13 changed files with 289 additions and 45 deletions

View File

@ -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

View File

@ -20,6 +20,7 @@
<title>SWE-GLib</title>
<xi:include href="xml/gswe-types.xml"/>
<xi:include href="xml/gswe-moon-phase-data.xml"/>
<xi:include href="xml/gswe-aspect-data.xml" />
<xi:include href="xml/swe-glib.xml"/>
<xi:include href="xml/gswe-moment.xml"/>
<xi:include href="xml/gswe-timestamp.xml"/>

View File

@ -55,6 +55,20 @@ GSWE_TYPE_MOON_PHASE_DATA
gswe_moon_phase_data_get_type
</SECTION>
<SECTION>
<FILE>gswe-aspect-data</FILE>
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
<SUBSECTION Standard>
GSWE_TYPE_ASPECT_DATA
gswe_aspect_data_get_type
</SECTION>
<SECTION>
<FILE>gswe-timestamp</FILE>
<TITLE>GsweTimestamp</TITLE>
@ -116,16 +130,13 @@ GsweAntiscionAxisInfo
GswePlanetData
GsweCoordinates
GsweHouseData
GsweAspectData
GsweAntiscionData
<SUBSECTION Standard>
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

View File

@ -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 \

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#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__ */

164
src/gswe-aspect-data.c Normal file
View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#include <glib-object.h>
#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;
}
}

52
src/gswe-aspect-data.h Normal file
View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#ifndef __SWE_GLIB_GSWE_ASPECT_DATA_H__
#define __SWE_GLIB_GSWE_ASPECT_DATA_H__
#include <glib-object.h>
#include "gswe-types.h"
#include "gswe-aspect-info.h"
#include "gswe-planet-data.h"
G_BEGIN_DECLS
/**
* GsweAspectData:
*
* <structname>GsweAspectData</structname> 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__ */

View File

@ -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"

View File

@ -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)
{

View File

@ -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

View File

@ -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;

View File

@ -21,6 +21,7 @@
#include "../swe/src/swephexp.h"
#include "swe-glib.h"
#include "swe-glib-private.h"
/**
* SECTION:swe-glib

View File

@ -20,6 +20,7 @@
#include <glib.h>
#include "gswe-types.h"
#include "gswe-aspect-data.h"
#include "gswe-timestamp.h"
#include "gswe-moment.h"
#include "gswe-enumtypes.h"