Added debugging code for dumping data from memory using GUI.
[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 "family.h"
24
25 /**
26  * Structure holding individual data.
27  */
28 struct familia_individual {
29         /** Individual identifier */
30         unsigned int id;
31         
32         /** Individual first name */
33         char * first_name;
34         
35         /** Individual last name */
36         char * last_name;
37
38         /** Individual families */
39         struct familia_family ** families;
40
41         /** Number of families */
42         unsigned int families_no;
43
44         /** Parent family. Family this individual comes from. */
45         struct familia_family * parents;
46 };
47
48 /**
49  * Creates new individual structure
50  * @return Newly allocated individual. If allocation failed, returns NULL, like
51  *         malloc.
52  */
53 struct familia_individual * familia_individual_new();
54
55 /**
56  * Frees allocated memory of the given individual
57  * DISCLAIMER! This function does not free memory of linked families. You have to
58  * remove them manually from storage.
59  * @parameter individual to free
60  */
61 void familia_individual_free(struct familia_individual * individual);
62
63 /**
64  * Sets first name of the given individual
65  * @parameter individual to set first name
66  * @parameter first name to set
67  */
68 void familia_individual_set_first_name(struct familia_individual * individual, char * first_name);
69
70 /**
71  * Gets first name of the given individual
72  * @parameter individual from whom get the first name
73  * @return individuals first name
74  */
75 char * familia_individual_get_first_name(struct familia_individual * individual);
76
77 /**
78  * Sets last name of the given individual
79  * @parameter individual to set last name
80  * @parameter last name to set
81  */
82 void familia_individual_set_last_name(struct familia_individual * individual, char * last_name);
83
84 /**
85  * Gets last name of the given individual
86  * @parameter individual from whom get the last name
87  * @return individuals last name
88  */
89 char * familia_individual_get_last_name(struct familia_individual * individual);
90
91 /**
92  * Adds family to the given individual
93  * @parameter individual to set last name
94  * @parameter last name to set
95  */
96 void familia_individual_add_family(struct familia_individual * individual, struct familia_family * family);
97
98 /**
99  * Gets family with the given id of the given individual
100  * @parameter individual from whom get the family
101  * @parameter family id of the individual
102  * @return selected family or NULL if such does not exists or index is out of
103  *         array bounds
104  */
105 struct familia_family * familia_individual_get_family_by_id(struct familia_individual * individual, unsigned int id);
106
107 /**
108  * Removes family with the given id from the given individual
109  * DISCLAIMER! This function does not free memory of linked families. You have to
110  * remove them manually from storage.
111  * @parameter individual from whom family will be removed
112  * @parameter family id of the individual
113  */
114 void familia_individual_remove_family_by_id(struct familia_individual * individual, unsigned int id);
115
116 /**
117  * Sets parents family of the given individual
118  * @parameter individual to set parents
119  * @parameter parents to set
120  */
121 void familia_individual_set_parents(struct familia_individual * individual, struct familia_family * family);
122
123 /**
124  * Gets family with the given id of the given individual
125  * @parameter individual from whom get the family
126  * @parameter family id of the individual
127  * @return individuals last name
128  */
129 struct familia_family * familia_individual_get_parents(struct familia_individual * individual);
130
131 /**
132  * Removes parents from the given individual
133  * DISCLAIMER! This function does not free memory of linked family. You have to
134  * remove them manually from storage.
135  * @parameter individual from whom parents will be removed
136  */
137 void familia_individual_remove_parents(struct familia_individual * individual);
138
139 #endif /*_FAMILIA_INDIVIDUAL_H */