2013-09-22 22:03:10 +00:00
|
|
|
/* gswe-moon-phase-data.c: Moon phase representation
|
|
|
|
*
|
|
|
|
* 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 "gswe-moon-phase-data.h"
|
|
|
|
#include "gswe-moon-phase-data-private.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* SECTION:gswe-moon-phase-data
|
|
|
|
* @short_description: a structure representing the phase of the Moon
|
|
|
|
* @title: GsweMoonPhaseData
|
|
|
|
* @stability: Stable
|
2013-09-23 18:16:28 +00:00
|
|
|
* @include: swe-glib.h
|
2013-09-22 22:03:10 +00:00
|
|
|
* @see_also: #GsweMoonPhase
|
|
|
|
*
|
|
|
|
* #GsweMoonPhaseData is a structure that represents the actual phase of the
|
|
|
|
* Moon, including its illumination percentage.
|
|
|
|
*/
|
|
|
|
|
2013-09-30 20:39:46 +00:00
|
|
|
G_DEFINE_BOXED_TYPE(GsweMoonPhaseData, gswe_moon_phase_data, (GBoxedCopyFunc)gswe_moon_phase_data_ref, (GBoxedFreeFunc)gswe_moon_phase_data_unref);
|
2013-09-22 22:03:10 +00:00
|
|
|
|
2013-09-30 20:39:46 +00:00
|
|
|
/**
|
|
|
|
* gswe_moon_phase_data_new:
|
|
|
|
*
|
|
|
|
* Creates a new #GsweMoonPhaseData object with reference count set to 1.
|
|
|
|
*
|
|
|
|
* Returns: (transfer full): a new #GsweMoonPhaseData object
|
|
|
|
*/
|
2013-09-22 22:03:10 +00:00
|
|
|
GsweMoonPhaseData *
|
2013-09-30 20:39:46 +00:00
|
|
|
gswe_moon_phase_data_new(void)
|
2013-09-22 22:03:10 +00:00
|
|
|
{
|
2013-09-30 20:39:46 +00:00
|
|
|
GsweMoonPhaseData *ret;
|
2013-09-22 22:03:10 +00:00
|
|
|
|
2013-09-30 20:39:46 +00:00
|
|
|
ret = g_new0(GsweMoonPhaseData, 1);
|
|
|
|
ret->refcount = 1;
|
2013-09-22 22:03:10 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-09-30 20:39:46 +00:00
|
|
|
* gswe_moon_phase_data_ref:
|
|
|
|
* @moon_phase_data: (in): a #GsweMoonPhaseData
|
|
|
|
*
|
|
|
|
* Increases reference count on @moon_phase_data by one.
|
2013-09-22 22:03:10 +00:00
|
|
|
*
|
2013-09-30 20:39:46 +00:00
|
|
|
* Returns: (transfer none): the same #GsweMoonPhaseData
|
|
|
|
*/
|
|
|
|
GsweMoonPhaseData *
|
|
|
|
gswe_moon_phase_data_ref(GsweMoonPhaseData *moon_phase_data)
|
|
|
|
{
|
|
|
|
moon_phase_data->refcount++;
|
|
|
|
|
|
|
|
return moon_phase_data;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gswe_moon_phase_data_unref:
|
|
|
|
* @moon_phase_data: (in): a #GsweMoonPhaseData
|
|
|
|
*
|
|
|
|
* Decreases reference count on @moon_phase_data by one. If reference count drops to zero, @moon_phase_data is freed.
|
2013-09-22 22:03:10 +00:00
|
|
|
*/
|
|
|
|
void
|
2013-09-30 20:39:46 +00:00
|
|
|
gswe_moon_phase_data_unref(GsweMoonPhaseData *moon_phase_data)
|
2013-09-22 22:03:10 +00:00
|
|
|
{
|
2013-09-30 20:39:46 +00:00
|
|
|
if (--moon_phase_data->refcount == 0) {
|
|
|
|
g_free(moon_phase_data);
|
2013-09-22 22:03:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gswe_moon_phase_data_get_phase:
|
2013-09-30 20:39:46 +00:00
|
|
|
* @moon_phase_data: (in): a GsweMoonPhaseData
|
2013-09-22 22:03:10 +00:00
|
|
|
*
|
|
|
|
* Gets the phase of the Moon in the given GsweMoonPhaseData.
|
|
|
|
*
|
|
|
|
* Returns: the Moon phase
|
|
|
|
*/
|
|
|
|
GsweMoonPhase
|
|
|
|
gswe_moon_phase_data_get_phase(GsweMoonPhaseData *moon_phase_data)
|
|
|
|
{
|
2013-10-03 23:00:26 +00:00
|
|
|
return moon_phase_data->phase;
|
2013-09-22 22:03:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gswe_moon_phase_data_get_illumination:
|
2013-09-30 20:39:46 +00:00
|
|
|
* @moon_phase_data: (in): a GsweMoonPhaseData
|
2013-09-22 22:03:10 +00:00
|
|
|
*
|
|
|
|
* Gets the illumination percentage from the given GsweMoonPhaseData.
|
|
|
|
*
|
|
|
|
* Returns: the illumination percentage
|
|
|
|
*/
|
|
|
|
gdouble
|
|
|
|
gswe_moon_phase_data_get_illumination(GsweMoonPhaseData *moon_phase_data)
|
|
|
|
{
|
2013-10-03 23:00:26 +00:00
|
|
|
return moon_phase_data->illumination;
|
2013-09-22 22:03:10 +00:00
|
|
|
}
|
|
|
|
|