1 /* Family 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
27 #include "individual.h"
28 #include "submitter.h"
30 #include "lds_event.h"
31 #include "source_citation.h"
32 #include "multimedia_link.h"
35 #include "change_date.h"
39 #include "gom_internal.h"
41 struct family* gom_first_family = NULL;
43 REC_CB(family, fam_start, make_family_record)
44 GET_REC_BY_XREF(family, XREF_FAM, gom_get_family_by_xref)
45 XREF_CB(family, fam_husb_start, husband, make_individual_record)
46 XREF_CB(family, fam_wife_start, wife, make_individual_record)
47 STRING_CB(family, fam_nchi_start, nr_of_children)
48 XREF_LIST_CB(family, fam_chil_start, children, make_individual_record)
49 XREF_LIST_CB(family, fam_subm_start, submitters, make_submitter_record)
51 void family_subscribe()
53 gedcom_subscribe_to_record(REC_FAM, fam_start, def_rec_end);
54 gedcom_subscribe_to_element(ELT_FAM_HUSB, fam_husb_start, def_elt_end);
55 gedcom_subscribe_to_element(ELT_FAM_WIFE, fam_wife_start, def_elt_end);
56 gedcom_subscribe_to_element(ELT_FAM_CHIL, fam_chil_start, def_elt_end);
57 gedcom_subscribe_to_element(ELT_FAM_NCHI, fam_nchi_start, def_elt_end);
58 gedcom_subscribe_to_element(ELT_FAM_SUBM, fam_subm_start, def_elt_end);
61 void family_add_event(Gom_ctxt ctxt, struct event* evt)
63 struct family *fam = SAFE_CTXT_CAST(family, ctxt);
64 LINK_CHAIN_ELT(event, fam->event, evt)
67 void family_add_lss(Gom_ctxt ctxt, struct lds_event* lss)
69 struct family *fam = SAFE_CTXT_CAST(family, ctxt);
70 LINK_CHAIN_ELT(lds_event, fam->lds_spouse_sealing, lss)
73 void family_add_citation(Gom_ctxt ctxt, struct source_citation* cit)
75 struct family *fam = SAFE_CTXT_CAST(family, ctxt);
76 LINK_CHAIN_ELT(source_citation, fam->citation, cit)
79 void family_add_mm_link(Gom_ctxt ctxt, struct multimedia_link* link)
81 struct family *fam = SAFE_CTXT_CAST(family, ctxt);
82 LINK_CHAIN_ELT(multimedia_link, fam->mm_link, link)
85 void family_add_note(Gom_ctxt ctxt, struct note_sub* note)
87 struct family *fam = SAFE_CTXT_CAST(family, ctxt);
88 LINK_CHAIN_ELT(note_sub, fam->note, note)
91 void family_add_user_ref(Gom_ctxt ctxt, struct user_ref_number* ref)
93 struct family *fam = SAFE_CTXT_CAST(family, ctxt);
94 LINK_CHAIN_ELT(user_ref_number, fam->ref, ref)
97 void family_set_record_id(Gom_ctxt ctxt, char *rin)
99 struct family *fam = SAFE_CTXT_CAST(family, ctxt);
100 fam->record_id = strdup(rin);
103 void family_set_change_date(Gom_ctxt ctxt, struct change_date* chan)
105 struct family *fam = SAFE_CTXT_CAST(family, ctxt);
106 fam->change_date = chan;
109 void family_add_user_data(Gom_ctxt ctxt, struct user_data* data)
111 struct family *obj = SAFE_CTXT_CAST(family, ctxt);
112 LINK_CHAIN_ELT(user_data, obj->extra, data)
115 void family_cleanup(struct family* fam)
117 SAFE_FREE(fam->xrefstr);
118 DESTROY_CHAIN_ELTS(event, fam->event, event_cleanup)
119 DESTROY_CHAIN_ELTS(xref_list, fam->children, NULL_DESTROY)
120 SAFE_FREE(fam->nr_of_children);
121 DESTROY_CHAIN_ELTS(xref_list, fam->submitters, NULL_DESTROY)
122 DESTROY_CHAIN_ELTS(lds_event, fam->lds_spouse_sealing, lds_event_cleanup)
123 DESTROY_CHAIN_ELTS(source_citation, fam->citation, citation_cleanup)
124 DESTROY_CHAIN_ELTS(multimedia_link, fam->mm_link, multimedia_link_cleanup)
125 DESTROY_CHAIN_ELTS(note_sub, fam->note, note_sub_cleanup)
126 DESTROY_CHAIN_ELTS(user_ref_number, fam->ref, user_ref_cleanup)
127 SAFE_FREE(fam->record_id);
128 change_date_cleanup(fam->change_date);
129 DESTROY_CHAIN_ELTS(user_data, fam->extra, user_data_cleanup)
132 void families_cleanup()
134 DESTROY_CHAIN_ELTS(family, gom_first_family, family_cleanup);
137 struct family* gom_get_first_family()
139 return gom_first_family;
142 struct family* make_family_record(char* xrefstr)
145 MAKE_CHAIN_ELT(family, gom_first_family, fam);
146 fam->xrefstr = strdup(xrefstr);