1 /* Individual object in the gedcom object model.
2 Copyright (C) 2002 The Genes Development Team
3 This file is part of the Gedcom parser library.
4 Contributed by Peter Verthez <Peter.Verthez@advalvas.be>, 2002.
6 The Gedcom parser library is free software; you can redistribute it
7 and/or modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The Gedcom parser library is distributed in the hope that it will be
12 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the Gedcom parser library; if not, write to the
18 Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
26 #include "individual.h"
28 #include "personal_name.h"
29 #include "lds_event.h"
30 #include "family_link.h"
31 #include "association.h"
32 #include "submitter.h"
33 #include "source_citation.h"
34 #include "multimedia_link.h"
37 #include "change_date.h"
41 #include "gom_internal.h"
43 struct individual* gom_first_individual = NULL;
45 REC_CB(individual, indi_start, make_individual_record)
46 GET_REC_BY_XREF(individual, XREF_INDI, gom_get_individual_by_xref)
47 STRING_CB(individual, indi_resn_start, restriction_notice)
48 STRING_CB(individual, indi_sex_start, sex)
49 XREF_LIST_CB(individual, indi_subm_start, submitters, make_submitter_record)
50 XREF_LIST_CB(individual, indi_alia_start, alias, make_individual_record)
51 XREF_LIST_CB(individual, indi_anci_start, ancestor_interest,
52 make_submitter_record)
53 XREF_LIST_CB(individual, indi_desi_start, descendant_interest,
54 make_submitter_record)
55 STRING_CB(individual, indi_rfn_start, record_file_nr)
56 STRING_CB(individual, indi_afn_start, ancestral_file_nr)
58 void individual_subscribe()
60 gedcom_subscribe_to_record(REC_INDI, indi_start, def_rec_end);
61 gedcom_subscribe_to_element(ELT_INDI_RESN, indi_resn_start, def_elt_end);
62 gedcom_subscribe_to_element(ELT_INDI_SEX, indi_sex_start, def_elt_end);
63 gedcom_subscribe_to_element(ELT_INDI_SUBM, indi_subm_start, def_elt_end);
64 gedcom_subscribe_to_element(ELT_INDI_ALIA, indi_alia_start, def_elt_end);
65 gedcom_subscribe_to_element(ELT_INDI_ANCI, indi_anci_start, def_elt_end);
66 gedcom_subscribe_to_element(ELT_INDI_DESI, indi_desi_start, def_elt_end);
67 gedcom_subscribe_to_element(ELT_INDI_RFN, indi_rfn_start, def_elt_end);
68 gedcom_subscribe_to_element(ELT_INDI_AFN, indi_afn_start, def_elt_end);
71 void individual_add_event(Gom_ctxt ctxt, struct event* evt)
73 struct individual *indiv = SAFE_CTXT_CAST(individual, ctxt);
74 LINK_CHAIN_ELT(event, indiv->event, evt)
77 void individual_add_attribute(Gom_ctxt ctxt, struct event* evt)
79 struct individual *indiv = SAFE_CTXT_CAST(individual, ctxt);
80 LINK_CHAIN_ELT(event, indiv->attribute, evt)
83 void individual_add_name(Gom_ctxt ctxt, struct personal_name* name)
85 struct individual *indiv = SAFE_CTXT_CAST(individual, ctxt);
86 LINK_CHAIN_ELT(personal_name, indiv->name, name)
89 void individual_add_lio(Gom_ctxt ctxt, struct lds_event* evt)
91 struct individual *indiv = SAFE_CTXT_CAST(individual, ctxt);
92 LINK_CHAIN_ELT(lds_event, indiv->lds_individual_ordinance, evt)
95 void individual_add_family_link(Gom_ctxt ctxt, int ctxt_type,
96 struct family_link* link)
98 struct individual *indiv = SAFE_CTXT_CAST(individual, ctxt);
101 LINK_CHAIN_ELT(family_link, indiv->child_to_family, link)
104 LINK_CHAIN_ELT(family_link, indiv->spouse_to_family, link)
107 UNEXPECTED_CONTEXT(ctxt_type);
111 void individual_add_association(Gom_ctxt ctxt, struct association* assoc)
113 struct individual *indiv = SAFE_CTXT_CAST(individual, ctxt);
114 LINK_CHAIN_ELT(association, indiv->association, assoc)
117 void individual_add_citation(Gom_ctxt ctxt, struct source_citation* cit)
119 struct individual *indiv = SAFE_CTXT_CAST(individual, ctxt);
120 LINK_CHAIN_ELT(source_citation, indiv->citation, cit)
123 void individual_add_mm_link(Gom_ctxt ctxt, struct multimedia_link* link)
125 struct individual *indiv = SAFE_CTXT_CAST(individual, ctxt);
126 LINK_CHAIN_ELT(multimedia_link, indiv->mm_link, link)
129 void individual_add_note(Gom_ctxt ctxt, struct note_sub* note)
131 struct individual *indiv = SAFE_CTXT_CAST(individual, ctxt);
132 LINK_CHAIN_ELT(note_sub, indiv->note, note)
135 void individual_add_user_ref(Gom_ctxt ctxt, struct user_ref_number* ref)
137 struct individual *indiv = SAFE_CTXT_CAST(individual, ctxt);
138 LINK_CHAIN_ELT(user_ref_number, indiv->ref, ref)
141 void individual_set_record_id(Gom_ctxt ctxt, char *rin)
143 struct individual *indiv = SAFE_CTXT_CAST(individual, ctxt);
144 indiv->record_id = strdup(rin);
147 void individual_set_change_date(Gom_ctxt ctxt, struct change_date* chan)
149 struct individual *indiv = SAFE_CTXT_CAST(individual, ctxt);
150 indiv->change_date = chan;
153 void individual_add_user_data(Gom_ctxt ctxt, struct user_data* data)
155 struct individual *obj = SAFE_CTXT_CAST(individual, ctxt);
156 LINK_CHAIN_ELT(user_data, obj->extra, data)
159 void individual_cleanup(struct individual* indiv)
161 SAFE_FREE(indiv->xrefstr);
162 SAFE_FREE(indiv->restriction_notice);
163 DESTROY_CHAIN_ELTS(personal_name, indiv->name, name_cleanup)
164 SAFE_FREE(indiv->sex);
165 DESTROY_CHAIN_ELTS(event, indiv->event, event_cleanup)
166 DESTROY_CHAIN_ELTS(event, indiv->attribute, event_cleanup)
167 DESTROY_CHAIN_ELTS(lds_event, indiv->lds_individual_ordinance,
169 DESTROY_CHAIN_ELTS(family_link, indiv->child_to_family, family_link_cleanup)
170 DESTROY_CHAIN_ELTS(family_link, indiv->spouse_to_family, family_link_cleanup)
171 DESTROY_CHAIN_ELTS(xref_list, indiv->submitters, NULL_DESTROY)
172 DESTROY_CHAIN_ELTS(association, indiv->association, association_cleanup)
173 DESTROY_CHAIN_ELTS(xref_list, indiv->alias, NULL_DESTROY)
174 DESTROY_CHAIN_ELTS(xref_list, indiv->ancestor_interest, NULL_DESTROY)
175 DESTROY_CHAIN_ELTS(xref_list, indiv->descendant_interest, NULL_DESTROY)
176 DESTROY_CHAIN_ELTS(source_citation, indiv->citation, citation_cleanup)
177 DESTROY_CHAIN_ELTS(multimedia_link, indiv->mm_link, multimedia_link_cleanup)
178 DESTROY_CHAIN_ELTS(note_sub, indiv->note, note_sub_cleanup)
179 SAFE_FREE(indiv->record_file_nr);
180 SAFE_FREE(indiv->ancestral_file_nr);
181 DESTROY_CHAIN_ELTS(user_ref_number, indiv->ref, user_ref_cleanup)
182 SAFE_FREE(indiv->record_id);
183 change_date_cleanup(indiv->change_date);
184 DESTROY_CHAIN_ELTS(user_data, indiv->extra, user_data_cleanup)
187 void individuals_cleanup()
189 DESTROY_CHAIN_ELTS(individual, gom_first_individual, individual_cleanup);
192 struct individual* gom_get_first_individual()
194 return gom_first_individual;
197 struct individual* make_individual_record(char* xrefstr)
199 struct individual* indiv;
200 MAKE_CHAIN_ELT(individual, gom_first_individual, indiv);
201 indiv->xrefstr = strdup(xrefstr);