Added po configurations.
[familia.git] / src / storage / storage.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_STORAGE_H
21 #define _FAMILIA_STORAGE_H
22
23 #include "individual.h"
24 #include "family.h"
25
26 /**
27  * @file storage.h
28  * @brief Data storage code.
29  *
30  * All loaded objects and basic operations on them.
31  */
32
33 /**
34  * Enumeration of object types allowed to store.
35  */
36 enum familia_storage_type {
37         FS_INDIVIDUAL,
38         FS_FAMILY
39 };
40
41 /**
42  * Structure for holding loaded file contents
43  */
44 struct familia_storage {
45         /**
46          * Dynamically allocated array of loaded individuals
47          */
48         struct familia_individual ** individuals;
49
50         /** Number of allocated individuals */
51         unsigned int individuals_no;
52
53         /**
54          * Dynamically allocated array of loaded families
55          */
56         struct familia_family ** families;
57
58         /** Number of allocated families */
59         unsigned int families_no;
60 };
61
62
63 /**
64  * Gets currently loaded storage structure.
65  * @return storage to set as a current one
66  */
67 struct familia_storage * familia_storage_get_current();
68
69 /**
70  * Sets storage structure as a currently loaded one.
71  * @parameter storage to set as a current one
72  */
73 void familia_storage_set_current(struct familia_storage * storage);
74
75 /**
76  * Creates new storage structure
77  * @return Newly allocated storage. If allocation failed, returns NULL, like
78  *         malloc.
79  */
80 struct familia_storage * familia_storage_new();
81
82 /**
83  * Frees storage and all the content in it
84  * @parameter storage to free
85  */
86 void familia_storage_free(struct familia_storage * storage);
87
88 /**
89  * Adds individual to the storage
90  * @parameter storage to which add individual
91  * @parameter individual to add to the storage
92  */
93 void familia_storage_add_individual(struct familia_storage * storage, struct familia_individual * individual);
94
95 /**
96  * Gets individual with the given id from the storage
97  * @parameter storage from which search for individual
98  * @parameter individual identifier
99  * @return loaded individual if found. NULL otherwise.
100  */
101 struct familia_individual * familia_storage_get_individual_by_id(struct familia_storage * storage, unsigned int id);
102
103 /**
104  * Removes individual with the given id from the storage
105  * @parameter storage from which remove individual
106  * @parameter individual id
107  */
108 void familia_storage_remove_individual_by_id(struct familia_storage * storage, unsigned int id);
109
110 /**
111  * Adds family to the storage
112  * @parameter storage to which add family
113  * @parameter family to add to the storage
114  */
115 void familia_storage_add_family(struct familia_storage * storage, struct familia_family * family);
116
117 /**
118  * Gets family with the given id from the storage
119  * @parameter storage from which search for family
120  * @parameter family identifier
121  * @return loaded family if found. NULL otherwise
122  */
123 struct familia_family * familia_storage_get_family_by_id(struct familia_storage * storage, unsigned int id);
124
125 /**
126  * Removes family with the given id from the storage
127  * @parameter storage from which remove family
128  * @parameter family id
129  */
130 void familia_storage_remove_family_by_id(struct familia_storage * storage, unsigned int id);
131
132 #endif /*_FAMILIA_STORAGE_H */