Moved GsweAspectData to its own source files

This commit is contained in:
Gergely Polonkai 2013-09-23 21:36:26 +02:00
parent 3fd8c200e0
commit d4015cae75
10 changed files with 290 additions and 21 deletions

View File

@ -62,6 +62,7 @@ IGNORE_HFILES = \
swe-glib-private.h \
gswe-enumtypes.h \
gswe-moon-phase-data-private.h \
gswe-aspect-info-private.h \
gswe-aspect-data-private.h \
gswe-planet-data-private.h

View File

@ -22,6 +22,7 @@
<xi:include href="xml/gswe-planet-data.xml" />
<xi:include href="xml/gswe-moon-phase-data.xml"/>
<xi:include href="xml/gswe-aspect-data.xml" />
<xi:include href="xml/gswe-aspect-info.xml" />
<xi:include href="xml/swe-glib.xml"/>
<xi:include href="xml/gswe-moment.xml"/>
<xi:include href="xml/gswe-timestamp.xml"/>

View File

@ -69,6 +69,20 @@ GSWE_TYPE_PLANET_DATA
gswe_planet_data_get_type
</SECTION>
<SECTION>
<FILE>gswe-aspect-info</FILE>
GsweAspectInfo
gswe_aspect_info_get_aspect
gswe_aspect_info_get_harmonic
gswe_aspect_info_get_major
gswe_aspect_info_get_name
gswe_aspect_info_get_orb_modifier
gswe_aspect_info_get_size
<SUBSECTION Standard>
GSWE_TYPE_ASPECT_INFO
gswe_aspect_info_get_type
</SECTION>
<SECTION>
<FILE>gswe-aspect-data</FILE>
GsweAspectData
@ -139,7 +153,6 @@ GsweMoonPhase
GswePlanetInfo
GsweSignInfo
GsweHouseSystemInfo
GsweAspectInfo
GsweAntiscionAxisInfo
GsweCoordinates
GsweHouseData

View File

@ -7,6 +7,7 @@ INST_H_SRC_FILES = \
swe-glib.h \
gswe-types.h \
gswe-moon-phase-data.h \
gswe-aspect-info.h \
gswe-aspect-data.h \
gswe-planet-data.h \
gswe-moment.h \
@ -22,6 +23,7 @@ libswe_glib_1_0_la_SOURCES = \
gswe-types.c \
gswe-moon-phase-data.c \
gswe-planet-data.c \
gswe-aspect-info.c \
gswe-aspect-data.c \
gswe-moment.c \
gswe-timestamp.c \

View File

@ -0,0 +1,52 @@
/* gswe-aspect-info-private.h: Private parts of GsweAspectInfo
*
* 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_INFO_PRIVATE_H__
#define __SWE_GLIB_GSWE_ASPECT_INFO_PRIVATE_H__
#include "gswe-types.h"
#include "gswe-aspect-info.h"
struct _GsweAspectInfo {
/* the identifier of this aspect */
GsweAspect aspect;
/* the name of the aspect */
gchar *name;
/* the size of the aspect, in degrees */
guint size;
/* the modifier of the orb (the maximum allowable difference from an exact orb) */
gdouble orb_modifier;
/* shows whether this aspect is harmonic or not */
gboolean harmonic;
/* shows whether this aspect is major (Ptolemaic) or not */
gboolean major;
};
void gswe_aspect_info_free(GsweAspectInfo *aspect_info);
GsweAspectInfo *gswe_aspect_info_copy(GsweAspectInfo *aspect_info);
#endif /* __SWE_GLIB_GSWE_ASPECT_INFO_PRIVATE_H__ */
#else /* not defined __SWE_GLIB_BUILDING__ */
#error __FILE__ "Can not be included, unless building SWE-GLib"
#endif /* __SWE_GLIB_BUILDING__ */

168
src/gswe-aspect-info.c Normal file
View File

@ -0,0 +1,168 @@
/* gswe-aspect-info.c: Aspect related 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 <http://www.gnu.org/licenses/>.
*/
#include <glib-object.h>
#include "gswe-types.h"
#include "gswe-aspect-info.h"
#include "gswe-aspect-info-private.h"
void
gswe_aspect_info_free(GsweAspectInfo *aspect_info)
{
if (aspect_info) {
if (aspect_info->name) {
g_free(aspect_info->name);
}
g_free(aspect_info);
}
}
GsweAspectInfo *
gswe_aspect_info_copy(GsweAspectInfo *aspect_info)
{
GsweAspectInfo *ret;
if (aspect_info == NULL) {
return NULL;
}
ret = g_new0(GsweAspectInfo, 1);
ret->aspect = aspect_info->aspect;
ret->name = g_strdup(aspect_info->name);
ret->size = aspect_info->size;
ret->orb_modifier = aspect_info->orb_modifier;
ret->harmonic = aspect_info->harmonic;
ret->major = aspect_info->major;
return ret;
}
G_DEFINE_BOXED_TYPE(GsweAspectInfo, gswe_aspect_info, (GBoxedCopyFunc)gswe_aspect_info_copy, (GBoxedFreeFunc)gswe_aspect_info_free);
/**
* gswe_aspect_info_get_aspect:
* @aspect_info: (in) (allow-none): a #GsweAspectInfo
*
* Gets the aspect ID
*/
GsweAspect
gswe_aspect_info_get_aspect(GsweAspectInfo *aspect_info)
{
if (aspect_info) {
return aspect_info->aspect;
} else {
return GSWE_ASPECT_NONE;
}
}
/**
* gswe_aspect_info_get_name:
* @aspect_info: (in) (allow-none): a #GsweAspectInfo
*
* Gets the name of this aspect. If NLS is enabled, name is translated in
* gswe_init(), so if you switch locale in your program, it will remain in the
* old locale. The returned string should not be freed or modified. It remains
* valid until @aspect_info exists.
*
* Returns: (transfer none): the name of the aspect
*/
const gchar *
gswe_aspect_info_get_name(GsweAspectInfo *aspect_info)
{
if (aspect_info) {
return aspect_info->name;
} else {
return NULL;
}
}
/**
* gswe_aspect_info_get_size:
* @aspect_info: (in) (allow-none): a #GsweAspectInfo
*
* Gets the size of the aspect.
*
* Returns: the size of the aspect, in degrees
*/
gdouble
gswe_aspect_info_get_size(GsweAspectInfo *aspect_info)
{
if (aspect_info) {
return aspect_info->size;
} else {
return 0.0;
}
}
/**
* gswe_aspect_info_get_orb_modifier:
* @aspect_info: (in) (allow-none): a #GsweAspectInfo
*
* Gets the orb modifier of this aspect. The orb modifier is subtracted from
* the planets' orb during aspect calculation.
*
* Returns: the orb modifier, in degrees
*/
gdouble
gswe_aspect_info_get_orb_modifier(GsweAspectInfo *aspect_info)
{
if (aspect_info) {
return aspect_info->orb_modifier;
} else {
return 0.0;
}
}
/**
* gswe_aspect_info_get_harmonic:
* @aspect_info: (in) (allow-none): a #GsweAspectInfo
*
* Tells if this aspect is considered harmonic.
*
* Returns: TRUE if the aspect is harmonic; FALSE otherwise
*/
gboolean
gswe_aspect_info_get_harmonic(GsweAspectInfo *aspect_info)
{
if (aspect_info) {
return aspect_info->harmonic;
} else {
return FALSE;
}
}
/**
* gswe_aspect_info_get_major:
* @aspect_info: (in) (allow-none): a #GsweAspectInfo
*
* Gets the significance of the aspect, e.g. if its Ptolemaic or note.
*
* Returns: TRUE if the aspect is a major (Ptolemaic) one; FALSE otherwise
*/
gboolean
gswe_aspect_info_get_major(GsweAspectInfo *aspect_info)
{
if (aspect_info) {
return aspect_info->major;
} else {
return FALSE;
}
}

50
src/gswe-aspect-info.h Normal file
View File

@ -0,0 +1,50 @@
/* gswe-aspect-info.h: Aspect related 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 <http://www.gnu.org/licenses/>.
*/
#ifndef __SWE_GLIB_GSWE_ASPECT_INFO_H__
#define __SWE_GLIB_GSWE_ASPECT_INFO_H__
#include <glib-object.h>
#include "gswe-types.h"
G_BEGIN_DECLS
/**
* GsweAspectInfo:
*
* <structname>GsweAspectInfo</structname> is an opaque structure whose members
* cannot be accessed directly.
*
* Since: 1.1
*/
typedef struct _GsweAspectInfo GsweAspectInfo;
GType gswe_aspect_info_get_type(void);
#define GSWE_TYPE_ASPECT_INFO (gswe_aspect_info_get_type())
GsweAspect gswe_aspect_info_get_aspect(GsweAspectInfo *aspect_info);
const gchar *gswe_aspect_info_get_name(GsweAspectInfo *aspect_info);
gdouble gswe_aspect_info_get_size(GsweAspectInfo *aspect_info);
gdouble gswe_aspect_info_get_orb_modifier(GsweAspectInfo *aspect_info);
gboolean gswe_aspect_info_get_harmonic(GsweAspectInfo *aspect_info);
gboolean gswe_aspect_info_get_major(GsweAspectInfo *aspect_info);
G_END_DECLS
#endif /* __SWE_GLIB_GSWE_ASPECT_INFO_H__ */

View File

@ -317,26 +317,6 @@ typedef struct {
gchar *name;
} GsweHouseSystemInfo;
/**
* GsweAspectInfo:
* @aspect: the identifier of this aspect
* @name: the name of the aspect
* @size: the size of the aspect, in degrees
* @orb_modifier: the modifier of the orb (the maximum allowable difference from an exact orb)
* @harmonic: shows whether this aspect is harmonic or not
* @major: shows whether this aspect is major (Ptolemaic) or not
*
* Holds informations about the aspects known by SWE-GLib.
*/
typedef struct {
GsweAspect aspect;
gchar *name;
guint size;
guint orb_modifier;
gboolean harmonic;
gboolean major;
} GsweAspectInfo;
/**
* GsweAntiscionAxisInfo:
* @axis_id: the identifier of this mirror's axis

View File

@ -21,6 +21,7 @@
#include "gswe-types.h"
#include "gswe-moon-phase-data-private.h"
#include "gswe-planet-data-private.h"
#include "gswe-aspect-info-private.h"
#include "gswe-aspect-data-private.h"
extern gchar *gswe_ephe_path;

View File

@ -22,6 +22,7 @@
#include "gswe-types.h"
#include "gswe-moon-phase-data.h"
#include "gswe-planet-data.h"
#include "gswe-aspect-info.h"
#include "gswe-aspect-data.h"
#include "gswe-timestamp.h"
#include "gswe-moment.h"