Add gswe_find_*_info() functions to find registered Gswe*Info objects
This commit is contained in:
parent
75a9318629
commit
a50a967ad3
@ -60,6 +60,7 @@ gswe_moon_phase_data_get_type
|
||||
<SECTION>
|
||||
<FILE>gswe-sign-info</FILE>
|
||||
GsweSignInfo
|
||||
gswe_find_sign_info_by_id
|
||||
gswe_sign_info_new
|
||||
gswe_sign_info_ref
|
||||
gswe_sign_info_unref
|
||||
@ -79,6 +80,7 @@ gswe_sign_info_get_type
|
||||
<SECTION>
|
||||
<FILE>gswe-planet-info</FILE>
|
||||
GswePlanetInfo
|
||||
gswe_find_planet_info_by_id
|
||||
gswe_planet_info_new
|
||||
gswe_planet_info_ref
|
||||
gswe_planet_info_unref
|
||||
@ -122,6 +124,7 @@ gswe_planet_data_get_type
|
||||
<SECTION>
|
||||
<FILE>gswe-aspect-info</FILE>
|
||||
GsweAspectInfo
|
||||
gswe_find_aspect_info_by_id
|
||||
gswe_aspect_info_new
|
||||
gswe_aspect_info_ref
|
||||
gswe_aspect_info_unref
|
||||
@ -165,6 +168,7 @@ gswe_aspect_data_get_type
|
||||
<SECTION>
|
||||
<FILE>gswe-antiscion-axis-info</FILE>
|
||||
GsweAntiscionAxisInfo
|
||||
gswe_find_antiscion_axis_info_by_id
|
||||
gswe_antiscion_axis_info_new
|
||||
gswe_antiscion_axis_info_ref
|
||||
gswe_antiscion_axis_info_unref
|
||||
@ -206,6 +210,7 @@ gswe_antiscion_data_get_type
|
||||
<SECTION>
|
||||
<FILE>gswe-house-system-info</FILE>
|
||||
GsweHouseSystemInfo
|
||||
gswe_find_house_system_info_by_id
|
||||
gswe_house_system_info_new
|
||||
gswe_house_system_info_ref
|
||||
gswe_house_system_info_unref
|
||||
|
@ -241,3 +241,98 @@ gswe_init(void)
|
||||
gswe_init_with_dir(PKGDATADIR);
|
||||
}
|
||||
|
||||
/**
|
||||
* gswe_find_planet_info_by_id:
|
||||
* @planet: a planet ID registered with SWE-GLib
|
||||
* @err: a GError
|
||||
*
|
||||
* Find the #GswePlanetInfo record registered with the id @planet.
|
||||
*/
|
||||
GswePlanetInfo *
|
||||
gswe_find_planet_info_by_id(GswePlanet planet, GError **err)
|
||||
{
|
||||
GswePlanetInfo *ret = g_hash_table_lookup(gswe_planet_info_table, GINT_TO_POINTER(planet));
|
||||
|
||||
if (ret == NULL) {
|
||||
g_set_error(err, GSWE_ERROR, GSWE_ERROR_UNKNOWN_PLANET, "Planet %d is not registered", planet);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* gswe_find_sign_info_by_id:
|
||||
* @sign: a sign ID registered with SWE-GLib
|
||||
* @err: a GError
|
||||
*
|
||||
* Find the #GsweSignInfo record registered with the id @sign.
|
||||
*/
|
||||
GsweSignInfo *
|
||||
gswe_find_sign_info_by_id(GsweZodiac sign, GError **err)
|
||||
{
|
||||
GsweSignInfo *ret = g_hash_table_lookup(gswe_sign_info_table, GINT_TO_POINTER(sign));
|
||||
|
||||
if (ret == NULL) {
|
||||
g_set_error(err, GSWE_ERROR, GSWE_ERROR_UNKNOWN_SIGN, "Sign %d is not registered", sign);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* gswe_find_house_system_info_by_id:
|
||||
* @house_system: a house system ID registered with SWE-GLib
|
||||
* @err: a GError
|
||||
*
|
||||
* Find the #GsweHouseSystemInfo record registered with the id @house_system.
|
||||
*/
|
||||
GsweHouseSystemInfo *
|
||||
gswe_find_house_system_info_by_id(GsweHouseSystem house_system, GError **err)
|
||||
{
|
||||
GsweHouseSystemInfo *ret = g_hash_table_lookup(gswe_house_system_info_table, GINT_TO_POINTER(house_system));
|
||||
|
||||
if (ret == NULL) {
|
||||
g_set_error(err, GSWE_ERROR, GSWE_ERROR_UNKNOWN_HSYS, "House system %d is not registered", house_system);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* gswe_find_aspect_info_by_id:
|
||||
* @aspect: an aspect ID registered with SWE-GLib
|
||||
* @err: a GError
|
||||
*
|
||||
* Find the #GsweAspectInfo record registered with the id @aspect.
|
||||
*/
|
||||
GsweAspectInfo *
|
||||
gswe_find_aspect_info_by_id(GsweAspect aspect, GError **err)
|
||||
{
|
||||
GsweAspectInfo *ret = g_hash_table_lookup(gswe_aspect_info_table, GINT_TO_POINTER(aspect));
|
||||
|
||||
if (ret == NULL) {
|
||||
g_set_error(err, GSWE_ERROR, GSWE_ERROR_UNKNOWN_ASPECT, "Aspect system %d is not registered", aspect);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* gswe_find_antiscion_axis_info_by_id:
|
||||
* @antiscion_axis: an antiscion axis ID registered with SWE-GLib
|
||||
* @err: a GError
|
||||
*
|
||||
* Find the #GsweAntiscionAxisInfo record registered with the id @antiscion_axis.
|
||||
*/
|
||||
GsweAntiscionAxisInfo *
|
||||
gswe_find_antiscion_axis_info_by_id(GsweAntiscionAxis antiscion_axis, GError **err)
|
||||
{
|
||||
GsweAntiscionAxisInfo *ret = g_hash_table_lookup(gswe_antiscion_axis_info_table, GINT_TO_POINTER(antiscion_axis));
|
||||
|
||||
if (ret == NULL) {
|
||||
g_set_error(err, GSWE_ERROR, GSWE_ERROR_UNKNOWN_ANTISCION_AXIS, "Antiscion axis system %d is not registered", antiscion_axis);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -47,6 +47,7 @@
|
||||
* @GSWE_ERROR_UNKNOWN_PLANET: the referenced planet was not added with
|
||||
* gswe_moment_add_planet()
|
||||
* @GSWE_ERROR_UNKNOWN_ANTISCION_AXIS: the given axis is unknown to SWE-GLib
|
||||
* @GSWE_ERROR_UNKNOWN_ASPECT: the given aspect is unknown to SWE-GLib
|
||||
*
|
||||
* Error codes returned by the SWE-GLib functions.
|
||||
*/
|
||||
@ -61,6 +62,7 @@ typedef enum {
|
||||
GSWE_ERROR_UNKNOWN_SIGN,
|
||||
GSWE_ERROR_UNKNOWN_PLANET,
|
||||
GSWE_ERROR_UNKNOWN_ANTISCION_AXIS,
|
||||
GSWE_ERROR_UNKNOWN_ASPECT,
|
||||
} GsweError;
|
||||
|
||||
/**
|
||||
@ -74,6 +76,11 @@ typedef enum {
|
||||
GQuark gswe_error_quark(void);
|
||||
|
||||
void gswe_init();
|
||||
GswePlanetInfo *gswe_find_planet_info_by_id(GswePlanet planet, GError **err);
|
||||
GsweSignInfo *gswe_find_sign_info_by_id(GsweZodiac sign, GError **err);
|
||||
GsweHouseSystemInfo *gswe_find_house_system_info_by_id(GsweHouseSystem house_system, GError **err);
|
||||
GsweAspectInfo *gswe_find_aspect_info_by_id(GsweAspect aspect, GError **err);
|
||||
GsweAntiscionAxisInfo *gswe_find_antiscion_axis_info_by_id(GsweAntiscionAxis antiscion_axis, GError **err);
|
||||
|
||||
#endif /* __SWE_GLIB_H__ */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user