parent
6d88993fa3
commit
0b15005e3a
@ -216,9 +216,13 @@ gswe_house_system_info_get_type
|
|||||||
<SECTION>
|
<SECTION>
|
||||||
<FILE>gswe-house-data</FILE>
|
<FILE>gswe-house-data</FILE>
|
||||||
GsweHouseData
|
GsweHouseData
|
||||||
gswe_house_data_get_cusp_position
|
gswe_house_data_new
|
||||||
|
gswe_house_data_ref
|
||||||
|
gswe_house_data_unref
|
||||||
gswe_house_data_get_house
|
gswe_house_data_get_house
|
||||||
|
gswe_house_data_get_cusp_position
|
||||||
gswe_house_data_get_sign
|
gswe_house_data_get_sign
|
||||||
|
gswe_house_data_get_sign_info
|
||||||
<SUBSECTION Standard>
|
<SUBSECTION Standard>
|
||||||
GSWE_TYPE_HOUSE_DATA
|
GSWE_TYPE_HOUSE_DATA
|
||||||
gswe_house_data_get_type
|
gswe_house_data_get_type
|
||||||
|
@ -29,10 +29,11 @@ struct _GsweHouseData {
|
|||||||
gdouble cusp_position;
|
gdouble cusp_position;
|
||||||
|
|
||||||
/* the #GsweSignInfo structure associated with the sign in which the house cusp is in */
|
/* the #GsweSignInfo structure associated with the sign in which the house cusp is in */
|
||||||
GsweSignInfo *sign;
|
GsweSignInfo *sign_info;
|
||||||
};
|
|
||||||
|
|
||||||
GsweHouseData *gswe_house_data_copy(GsweHouseData *house_data);
|
/* reference count */
|
||||||
|
guint refcount;
|
||||||
|
};
|
||||||
|
|
||||||
#endif /* __SWE_GLIB_GSWE_HOUSE_DATA_PRIVATE_H__ */
|
#endif /* __SWE_GLIB_GSWE_HOUSE_DATA_PRIVATE_H__ */
|
||||||
#else /* not defined __SWE_GLIB_BUILDING__ */
|
#else /* not defined __SWE_GLIB_BUILDING__ */
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
*/
|
*/
|
||||||
#include "gswe-types.h"
|
#include "gswe-types.h"
|
||||||
|
|
||||||
|
#include "swe-glib-private.h"
|
||||||
|
#include "swe-glib.h"
|
||||||
#include "gswe-house-data.h"
|
#include "gswe-house-data.h"
|
||||||
#include "gswe-house-data-private.h"
|
#include "gswe-house-data-private.h"
|
||||||
|
|
||||||
@ -31,23 +33,69 @@
|
|||||||
* #GsweHouseData is a structure that represents a house's position.
|
* #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);
|
G_DEFINE_BOXED_TYPE(GsweHouseData, gswe_house_data, (GBoxedCopyFunc)gswe_house_data_ref, (GBoxedFreeFunc)gswe_house_data_unref);
|
||||||
|
|
||||||
GsweHouseData *
|
static void
|
||||||
gswe_house_data_copy(GsweHouseData *house_data)
|
gswe_house_data_free(GsweHouseData *house_data)
|
||||||
{
|
{
|
||||||
GsweHouseData *ret = g_new0(GsweHouseData, 1);
|
if (house_data->sign_info) {
|
||||||
|
gswe_sign_info_unref(house_data->sign_info);
|
||||||
|
}
|
||||||
|
|
||||||
ret->house = house_data->house;
|
g_free(house_data);
|
||||||
ret->cusp_position = house_data->cusp_position;
|
}
|
||||||
ret->sign = house_data->sign;
|
|
||||||
|
/**
|
||||||
|
* gswe_house_data_new:
|
||||||
|
*
|
||||||
|
* Creates a new #GsweHouseData with reference count set to 1.
|
||||||
|
*
|
||||||
|
* Returns: (transfer full): a new #GsweHouseData
|
||||||
|
*/
|
||||||
|
GsweHouseData *
|
||||||
|
gswe_house_data_new(void)
|
||||||
|
{
|
||||||
|
GsweHouseData *ret;
|
||||||
|
|
||||||
|
ret = g_new0(GsweHouseData, 1);
|
||||||
|
ret->refcount = 1;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_house_data_ref:
|
||||||
|
* @house_data: a #GsweHouseData
|
||||||
|
*
|
||||||
|
* Increases reference count on @house_data by one.
|
||||||
|
*
|
||||||
|
* Returns: (transfer none): the same #GsweHouseData
|
||||||
|
*/
|
||||||
|
GsweHouseData *
|
||||||
|
gswe_house_data_ref(GsweHouseData *house_data)
|
||||||
|
{
|
||||||
|
house_data->refcount++;
|
||||||
|
|
||||||
|
return house_data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_house_data_unref:
|
||||||
|
* @house_data: a #GsweHouseData
|
||||||
|
*
|
||||||
|
* Decreases reference count on @house_data by one. If reference count drops to zero, @house_data is freed.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gswe_house_data_unref(GsweHouseData *house_data)
|
||||||
|
{
|
||||||
|
if (--house_data->refcount == 0) {
|
||||||
|
gswe_house_data_free(house_data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gswe_house_data_get_house:
|
* gswe_house_data_get_house:
|
||||||
* @house_data: (in) (allow-none): a #GsweHouseData
|
* @house_data: (in): a #GsweHouseData
|
||||||
*
|
*
|
||||||
* Gets the number of the house.
|
* Gets the number of the house.
|
||||||
*
|
*
|
||||||
@ -56,16 +104,12 @@ gswe_house_data_copy(GsweHouseData *house_data)
|
|||||||
guint
|
guint
|
||||||
gswe_house_data_get_house(GsweHouseData *house_data)
|
gswe_house_data_get_house(GsweHouseData *house_data)
|
||||||
{
|
{
|
||||||
if (house_data) {
|
return house_data->house;
|
||||||
return house_data->house;
|
|
||||||
} else {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gswe_house_data_get_cusp_position:
|
* gswe_house_data_get_cusp_position:
|
||||||
* @house_data: (in) (allow-none): a #GsweHouseData
|
* @house_data: (in): a #GsweHouseData
|
||||||
*
|
*
|
||||||
* Gets the position of the house's cusp.
|
* Gets the position of the house's cusp.
|
||||||
*
|
*
|
||||||
@ -74,28 +118,38 @@ gswe_house_data_get_house(GsweHouseData *house_data)
|
|||||||
gdouble
|
gdouble
|
||||||
gswe_house_data_get_cusp_position(GsweHouseData *house_data)
|
gswe_house_data_get_cusp_position(GsweHouseData *house_data)
|
||||||
{
|
{
|
||||||
if (house_data) {
|
return house_data->cusp_position;
|
||||||
return house_data->cusp_position;
|
|
||||||
} else {
|
|
||||||
return 0.0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gswe_house_data_get_sign:
|
* gswe_house_data_get_sign:
|
||||||
* @house_data: (in) (allow-none): a #GsweHouseData
|
* @house_data: a #GsweHouseData
|
||||||
*
|
*
|
||||||
* Gets the sign in which the house's cusp is.
|
* Gets the sign which the house's cusp is in.
|
||||||
|
*
|
||||||
|
* Returns: the GsweZodiac of the house cusp's sign
|
||||||
|
*/
|
||||||
|
GsweZodiac
|
||||||
|
gswe_house_data_get_sign(GsweHouseData *house_data)
|
||||||
|
{
|
||||||
|
if (house_data->sign_info) {
|
||||||
|
return house_data->sign_info->sign;
|
||||||
|
} else {
|
||||||
|
return GSWE_SIGN_NONE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_house_data_get_sign_info:
|
||||||
|
* @house_data: (in): a #GsweHouseData
|
||||||
|
*
|
||||||
|
* Gets the #GsweSignInfo that represents the sign which the house's cusp is in.
|
||||||
*
|
*
|
||||||
* Returns: (transfer none): a #GsweSignInfo representing the sign
|
* Returns: (transfer none): a #GsweSignInfo representing the sign
|
||||||
*/
|
*/
|
||||||
GsweSignInfo *
|
GsweSignInfo *
|
||||||
gswe_house_data_get_sign(GsweHouseData *house_data)
|
gswe_house_data_get_sign_info(GsweHouseData *house_data)
|
||||||
{
|
{
|
||||||
if (house_data) {
|
return house_data->sign_info;
|
||||||
return house_data->sign;
|
|
||||||
} else {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,9 +37,15 @@ typedef struct _GsweHouseData GsweHouseData;
|
|||||||
GType gswe_house_data_get_type(void);
|
GType gswe_house_data_get_type(void);
|
||||||
#define GSWE_TYPE_HOUSE_DATA (gswe_house_data_get_type())
|
#define GSWE_TYPE_HOUSE_DATA (gswe_house_data_get_type())
|
||||||
|
|
||||||
|
GsweHouseData *gswe_house_data_new(void);
|
||||||
|
|
||||||
|
GsweHouseData *gswe_house_data_ref(GsweHouseData *house_data);
|
||||||
|
void gswe_house_data_unref(GsweHouseData *house_data);
|
||||||
|
|
||||||
guint gswe_house_data_get_house(GsweHouseData *house_data);
|
guint gswe_house_data_get_house(GsweHouseData *house_data);
|
||||||
gdouble gswe_house_data_get_cusp_position(GsweHouseData *house_data);
|
gdouble gswe_house_data_get_cusp_position(GsweHouseData *house_data);
|
||||||
GsweSignInfo *gswe_house_data_get_sign(GsweHouseData *house_data);
|
GsweZodiac gswe_house_data_get_sign(GsweHouseData *house_data);
|
||||||
|
GsweSignInfo *gswe_house_data_get_sign_info(GsweHouseData *house_data);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
@ -201,7 +201,7 @@ gswe_moment_finalize(GObject *gobject)
|
|||||||
{
|
{
|
||||||
GsweMoment *moment = GSWE_MOMENT(gobject);
|
GsweMoment *moment = GSWE_MOMENT(gobject);
|
||||||
|
|
||||||
g_list_free_full(moment->priv->house_list, g_free);
|
g_list_free_full(moment->priv->house_list, (GDestroyNotify)gswe_house_data_unref);
|
||||||
g_list_free_full(moment->priv->planet_list, (GDestroyNotify)gswe_planet_data_unref);
|
g_list_free_full(moment->priv->planet_list, (GDestroyNotify)gswe_planet_data_unref);
|
||||||
g_list_free_full(moment->priv->aspect_list, (GDestroyNotify)gswe_aspect_data_unref);
|
g_list_free_full(moment->priv->aspect_list, (GDestroyNotify)gswe_aspect_data_unref);
|
||||||
g_list_free_full(moment->priv->antiscia_list, (GDestroyNotify)gswe_antiscion_data_unref);
|
g_list_free_full(moment->priv->antiscia_list, (GDestroyNotify)gswe_antiscion_data_unref);
|
||||||
@ -502,7 +502,7 @@ gswe_moment_calculate_house_positions(GsweMoment *moment, GError **err)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_list_free_full(moment->priv->house_list, g_free);
|
g_list_free_full(moment->priv->house_list, (GDestroyNotify)gswe_house_data_unref);
|
||||||
moment->priv->house_list = NULL;
|
moment->priv->house_list = NULL;
|
||||||
|
|
||||||
// If no house system is set, we need no calculations at all. Just leave
|
// If no house system is set, we need no calculations at all. Just leave
|
||||||
@ -535,13 +535,13 @@ gswe_moment_calculate_house_positions(GsweMoment *moment, GError **err)
|
|||||||
* this should not cause trouble yet, though) */
|
* this should not cause trouble yet, though) */
|
||||||
for (i = 12; i >= 1; i--) {
|
for (i = 12; i >= 1; i--) {
|
||||||
GsweSignInfo *sign_info;
|
GsweSignInfo *sign_info;
|
||||||
GsweHouseData *house_data = g_new0(GsweHouseData, 1);
|
GsweHouseData *house_data = gswe_house_data_new();
|
||||||
|
|
||||||
house_data->house = i;
|
house_data->house = i;
|
||||||
house_data->cusp_position = cusps[i];
|
house_data->cusp_position = cusps[i];
|
||||||
|
|
||||||
if ((sign_info = g_hash_table_lookup(gswe_sign_info_table, GINT_TO_POINTER((gint)ceilf(cusps[i] / 30.0)))) == NULL) {
|
if ((sign_info = g_hash_table_lookup(gswe_sign_info_table, GINT_TO_POINTER((gint)ceilf(cusps[i] / 30.0)))) == NULL) {
|
||||||
g_list_free_full(moment->priv->house_list, g_free);
|
g_list_free_full(moment->priv->house_list, (GDestroyNotify)gswe_house_data_unref);
|
||||||
moment->priv->house_list = NULL;
|
moment->priv->house_list = NULL;
|
||||||
moment->priv->house_revision = 0;
|
moment->priv->house_revision = 0;
|
||||||
g_set_error(err, GSWE_ERROR, GSWE_ERROR_UNKNOWN_SIGN, "Calculation brought an unknown sign");
|
g_set_error(err, GSWE_ERROR, GSWE_ERROR_UNKNOWN_SIGN, "Calculation brought an unknown sign");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user