1 /****************************************************************************
2 * Familia Lignum - Genealogical program *
3 * Copyright (C) 2011-2012 Rafał Długołęcki <rafal@dlugolecki.net.pl> *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; version 2 of the License. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License along *
15 * with this program; if not, write to the Free Software Foundation, Inc., *
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
18 ****************************************************************************/
20 #ifndef _FAMILIA_INDIVIDUAL_H
21 #define _FAMILIA_INDIVIDUAL_H
28 * @file storage/individual.h
29 * @brief Code for managing individuals from the family.
34 * Structure holding individual data.
36 struct familia_individual {
37 /** Individual identifier */
40 /** Individual first name */
43 /** Individual last name */
46 /** Individual families */
47 struct familia_family ** families;
49 /** Number of families */
50 unsigned int families_no;
52 /** Parent family. Family this individual comes from. */
53 struct familia_family * parents;
56 * Birth date of individual.
57 * Could be exact date, range or unrecognized. You can find more info in
58 * gedcom-parse documentation.
60 struct date_value * birth;
64 * Creates new individual structure
65 * @return Newly allocated individual. If allocation failed, returns NULL, like
68 struct familia_individual * familia_individual_new();
71 * Frees allocated memory of the given individual
72 * @attention This function does not free memory of linked families. You have to
73 * remove them manually from @ref familia_storage, by using @ref familia_storage_free.
74 * @param individual individual to free
76 void familia_individual_free(struct familia_individual * individual);
79 * Sets first name of the given individual
80 * @param individual individual to set first name
81 * @param first_name first name to set
83 void familia_individual_set_first_name(struct familia_individual * individual, char * first_name);
86 * Gets first name of the given individual
87 * @param individual individual from whom get the first name
88 * @return individuals first name
90 char * familia_individual_get_first_name(struct familia_individual * individual);
93 * Sets last name of the given individual
94 * @param individual individual to set last name
95 * @param last_name last name to set
97 void familia_individual_set_last_name(struct familia_individual * individual, char * last_name);
100 * Gets last name of the given individual
101 * @param individual individual from whom get the last name
102 * @return individuals last name
104 char * familia_individual_get_last_name(struct familia_individual * individual);
107 * Adds family to the given individual
108 * @param individual individual to set last name
109 * @param family last name to set
111 void familia_individual_add_family(struct familia_individual * individual, struct familia_family * family);
114 * Gets family with the given id of the given individual
115 * @param individual individual from whom get the family
116 * @param id family id of the individual
117 * @return selected family or NULL if such does not exists or index is out of
120 struct familia_family * familia_individual_get_family_by_id(struct familia_individual * individual, unsigned int id);
123 * Removes family with the given id from the given individual
124 * DISCLAIMER! This function does not free memory of linked families. You have to
125 * remove them manually from storage.
126 * @param individual individual from whom family will be removed
127 * @param id family id of the individual
129 void familia_individual_remove_family_by_id(struct familia_individual * individual, unsigned int id);
132 * Sets parents family of the given individual
133 * @param individual individual to set parents
134 * @param family parents to set
136 void familia_individual_set_parents(struct familia_individual * individual, struct familia_family * family);
139 * Gets family with the given id of the given individual
140 * @param individual individual from whom get the parents
141 * @return individuals last name
143 struct familia_family * familia_individual_get_parents(struct familia_individual * individual);
146 * Removes parents from the given individual
147 * DISCLAIMER! This function does not free memory of linked family. You have to
148 * remove them manually from storage.
149 * @param individual individual from whom parents will be removed
151 void familia_individual_remove_parents(struct familia_individual * individual);
154 * Calculates family number in order
155 * @return child number of individual in the given family, -1 on error or if child does not belong to family.
157 int familia_individual_nth_child_of_family(struct familia_individual * individual, struct familia_family * family);
160 * Sets individual birth date.
161 * Date value is copied individual. Value is released on individual free().
162 * @see familia_individual_free
163 * @param individual individual to set birth date
164 * @param dv date of the birth (exact, or bounds)
165 * @return child number of individual in the given family, -1 on error or if child does not belong to family.
167 void familia_individual_set_birth_date(struct familia_individual * individual, struct date_value dv);
169 #endif /*_FAMILIA_INDIVIDUAL_H */