Added reading date from the GEDCOM file and storing it in individual.
[familia.git] / src / storage / individual.h
1 /****************************************************************************
2  *  Familia Lignum - Genealogical program                                   *
3  *  Copyright (C) 2011-2012 Rafał Długołęcki <rafal@dlugolecki.net.pl>      *
4  *                                                                          *
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.                 *
8  *                                                                          *
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.                            *
13  *                                                                          *
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.             *
17  *                                                                          *
18  ****************************************************************************/
19
20 #ifndef _FAMILIA_INDIVIDUAL_H
21 #define _FAMILIA_INDIVIDUAL_H
22
23 #include <gedcom.h>
24
25 #include "family.h"
26
27 /**
28  * @file storage/individual.h
29  * @brief Code for managing individuals from the family.
30  *
31  */
32
33 /**
34  * Structure holding individual data.
35  */
36 struct familia_individual {
37         /** Individual identifier */
38         unsigned int id;
39
40         /** Individual first name */
41         char * first_name;
42
43         /** Individual last name */
44         char * last_name;
45
46         /** Individual families */
47         struct familia_family ** families;
48
49         /** Number of families */
50         unsigned int families_no;
51
52         /** Parent family. Family this individual comes from. */
53         struct familia_family * parents;
54
55         /**
56          * Birth date of individual.
57          * Could be exact date, range or unrecognized. You can find more info in
58          * gedcom-parse documentation.
59          */
60         struct date_value * birth;
61 };
62
63 /**
64  * Creates new individual structure
65  * @return Newly allocated individual. If allocation failed, returns NULL, like
66  *         malloc.
67  */
68 struct familia_individual * familia_individual_new();
69
70 /**
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
75  */
76 void familia_individual_free(struct familia_individual * individual);
77
78 /**
79  * Sets first name of the given individual
80  * @param individual individual to set first name
81  * @param first_name first name to set
82  */
83 void familia_individual_set_first_name(struct familia_individual * individual, char * first_name);
84
85 /**
86  * Gets first name of the given individual
87  * @param individual individual from whom get the first name
88  * @return individuals first name
89  */
90 char * familia_individual_get_first_name(struct familia_individual * individual);
91
92 /**
93  * Sets last name of the given individual
94  * @param individual individual to set last name
95  * @param last_name last name to set
96  */
97 void familia_individual_set_last_name(struct familia_individual * individual, char * last_name);
98
99 /**
100  * Gets last name of the given individual
101  * @param individual individual from whom get the last name
102  * @return individuals last name
103  */
104 char * familia_individual_get_last_name(struct familia_individual * individual);
105
106 /**
107  * Adds family to the given individual
108  * @param individual individual to set last name
109  * @param family last name to set
110  */
111 void familia_individual_add_family(struct familia_individual * individual, struct familia_family * family);
112
113 /**
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
118  *         array bounds
119  */
120 struct familia_family * familia_individual_get_family_by_id(struct familia_individual * individual, unsigned int id);
121
122 /**
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
128  */
129 void familia_individual_remove_family_by_id(struct familia_individual * individual, unsigned int id);
130
131 /**
132  * Sets parents family of the given individual
133  * @param individual individual to set parents
134  * @param family parents to set
135  */
136 void familia_individual_set_parents(struct familia_individual * individual, struct familia_family * family);
137
138 /**
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
142  */
143 struct familia_family * familia_individual_get_parents(struct familia_individual * individual);
144
145 /**
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
150  */
151 void familia_individual_remove_parents(struct familia_individual * individual);
152
153 /**
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.
156  */
157 int familia_individual_nth_child_of_family(struct familia_individual * individual, struct familia_family * family);
158
159 /**
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.
166  */
167 void familia_individual_set_birth_date(struct familia_individual * individual, struct date_value dv);
168
169 #endif /*_FAMILIA_INDIVIDUAL_H */