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_STORAGE_H
21 #define _FAMILIA_STORAGE_H
23 #include "individual.h"
28 * @brief Data storage code.
30 * All loaded objects and basic operations on them.
34 * Enumeration of object types allowed to store.
36 enum familia_storage_type {
42 * Structure for holding loaded file contents
44 struct familia_storage {
46 * Dynamically allocated array of loaded individuals
48 struct familia_individual ** individuals;
50 /** Number of allocated individuals */
51 unsigned int individuals_no;
54 * Dynamically allocated array of loaded families
56 struct familia_family ** families;
58 /** Number of allocated families */
59 unsigned int families_no;
64 * Gets currently loaded storage structure.
65 * @return storage to set as a current one
67 struct familia_storage * familia_storage_get_current();
70 * Sets storage structure as a currently loaded one.
71 * @param storage storage to set as a current one
73 void familia_storage_set_current(struct familia_storage * storage);
76 * Creates new storage structure
77 * @return Newly allocated storage. If allocation failed, returns NULL, like
80 struct familia_storage * familia_storage_new();
83 * Frees storage and all the content in it
84 * @param storage storage to free
86 void familia_storage_free(struct familia_storage * storage);
89 * Adds individual to the storage
90 * @param storage storage to which add individual
91 * @param individual individual to add to the storage
93 void familia_storage_add_individual(struct familia_storage * storage, struct familia_individual * individual);
96 * Gets individual with the given id from the storage
97 * @param storage storage from which search for individual
98 * @param id individual identifier
99 * @return loaded individual if found. NULL otherwise.
101 struct familia_individual * familia_storage_get_individual_by_id(struct familia_storage * storage, unsigned int id);
104 * Removes individual with the given id from the storage
105 * @param storage storage from which remove individual
106 * @param id individual id
108 void familia_storage_remove_individual_by_id(struct familia_storage * storage, unsigned int id);
111 * Adds family to the storage
112 * @param storage storage to which add family
113 * @param family family to add to the storage
115 void familia_storage_add_family(struct familia_storage * storage, struct familia_family * family);
118 * Gets family with the given id from the storage
119 * @param storage storage from which search for family
120 * @param id family identifier
121 * @return loaded family if found. NULL otherwise
123 struct familia_family * familia_storage_get_family_by_id(struct familia_storage * storage, unsigned int id);
126 * Removes family with the given id from the storage
127 * @param storage storage from which remove family
128 * @param id family id
130 void familia_storage_remove_family_by_id(struct familia_storage * storage, unsigned int id);
132 void familia_storage_dump_all();
134 #endif /*_FAMILIA_STORAGE_H */