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_FAMILY_H
21 #define _FAMILIA_FAMILY_H
23 #include "individual.h"
25 enum FFamilyIndividualIndex {
31 * Structure holding family data.
33 struct familia_family {
34 /** Marriage identifier */
37 /** First individual of family */
38 struct familia_individual * individual1;
40 /** Second individual of family */
41 struct familia_individual * individual2;
43 /** Children of this family */
44 struct familia_individual ** children;
46 /** Number of children of this family */
47 unsigned short children_no;
51 * Creates new family structure
52 * @return Newly allocated individual.If allocation failed, returns NULL, like
55 struct familia_family * familia_family_new();
58 * Frees allocated memory of the given family
59 * DISCLAIMER! This function does not free memory of linked individuals. You have to
60 * remove them manually from storage.
61 * @parameter individual free
63 void familia_family_free(struct familia_family * family);
66 * Sets individual1 in the given family
67 * @parameter family to set the individual
68 * @parameter individual which will be set
70 void familia_family_set_individual(struct familia_family * family, struct familia_individual * individual, enum FFamilyIndividualIndex index);
73 * Gets individual from the given family
74 * @parameter family to get the individual
75 * @parameter individual index of which individual get
77 struct familia_individual * familia_family_get_individual(struct familia_family * family, enum FFamilyIndividualIndex index);
80 * Removes individual from the given family
81 * DISCLAIMER! This function does not free memory of linked individuals. You have to
82 * remove them manually from storage.
83 * @parameter family to remove the individual
84 * @parameter individual index of which individual to remove
85 * @return returns removed individual, NULL if such does not exist.
87 struct familia_individual * familia_family_remove_individual(struct familia_family * family, enum FFamilyIndividualIndex index);
90 * Adds new child in the given family
91 * Automatically sets family as parents in individual variable.
93 * @parameter family to set the individual
94 * @parameter individual which will be added
96 void familia_family_add_child(struct familia_family * family, struct familia_individual * individual);
99 * Gets the nth child from the given family
100 * Child with index = 0 is the oldest. Bigger the index, the child is younger
101 * @parameter family to get the child
102 * @parameter individual index of which individual get
103 * @return selected child. If index is bigger than child_no of the family
106 struct familia_individual * familia_family_get_child_by_id(struct familia_family * family, unsigned short index);
109 * Removes child from the given family
110 * DISCLAIMER! This function does not free memory of linked children. You have to
111 * remove them manually from storage.
112 * @parameter family to remove the child
113 * @parameter index of which child should be removed
114 * @return removed child. If such does not exist or index is bigger than child_no
115 * of the family, returns NULL.
117 struct familia_individual * familia_family_remove_child_by_id(struct familia_family * family, unsigned short index);
119 #endif /*_FAMILIA_FAMILY_H */