swe-glib/src/gswe-house-data.c

166 lines
3.6 KiB
C
Raw Permalink Normal View History

2013-09-23 23:24:00 +00:00
/* 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 <http://www.gnu.org/licenses/>.
*/
#include "gswe-types.h"
#include "swe-glib-private.h"
#include "swe-glib.h"
2013-09-23 23:24:00 +00:00
#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.
*/
2014-07-08 08:43:54 +00:00
G_DEFINE_BOXED_TYPE(
GsweHouseData,
gswe_house_data,
(GBoxedCopyFunc)gswe_house_data_ref,
(GBoxedFreeFunc)gswe_house_data_unref
);
2013-09-23 23:24:00 +00:00
static void
gswe_house_data_free(GsweHouseData *house_data)
{
if (house_data->sign_info) {
gswe_sign_info_unref(house_data->sign_info);
}
g_free(house_data);
}
/**
* gswe_house_data_new:
*
* Creates a new #GsweHouseData with reference count set to 1.
*
* Returns: (transfer full): a new #GsweHouseData
*/
2013-09-23 23:24:00 +00:00
GsweHouseData *
gswe_house_data_new(void)
2013-09-23 23:24:00 +00:00
{
GsweHouseData *ret;
2013-09-23 23:24:00 +00:00
ret = g_new0(GsweHouseData, 1);
ret->refcount = 1;
2013-09-23 23:24:00 +00:00
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
*
2014-07-08 08:43:54 +00:00
* 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 == NULL) {
return;
}
if (--house_data->refcount == 0) {
gswe_house_data_free(house_data);
}
}
2013-09-23 23:24:00 +00:00
/**
* gswe_house_data_get_house:
* @house_data: (in): a #GsweHouseData
2013-09-23 23:24:00 +00:00
*
* Gets the number of the house.
*
* Returns: the house number
*/
guint
gswe_house_data_get_house(GsweHouseData *house_data)
{
return house_data->house;
2013-09-23 23:24:00 +00:00
}
/**
* gswe_house_data_get_cusp_position:
* @house_data: (in): a #GsweHouseData
2013-09-23 23:24:00 +00:00
*
* Gets the position of the house's cusp.
*
* Returns: the cusp position, in degrees
*/
gdouble
gswe_house_data_get_cusp_position(GsweHouseData *house_data)
{
return house_data->cusp_position;
2013-09-23 23:24:00 +00:00
}
/**
* gswe_house_data_get_sign:
* @house_data: a #GsweHouseData
2013-09-23 23:24:00 +00:00
*
* Gets the sign which the house's cusp is in.
2013-09-23 23:24:00 +00:00
*
* Returns: the GsweZodiac of the house cusp's sign
2013-09-23 23:24:00 +00:00
*/
GsweZodiac
2013-09-23 23:24:00 +00:00
gswe_house_data_get_sign(GsweHouseData *house_data)
{
if (house_data->sign_info) {
return house_data->sign_info->sign;
2013-09-23 23:24:00 +00:00
} else {
return GSWE_SIGN_NONE;
2013-09-23 23:24:00 +00:00
}
}
/**
* 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
*/
GsweSignInfo *
gswe_house_data_get_sign_info(GsweHouseData *house_data)
{
return house_data->sign_info;
}