X-Git-Url: https://git.dlugolecki.net.pl/?a=blobdiff_plain;f=src%2Fstorage%2Ffamily.h;h=adf2dac5502daca279cf5375c2d34b7ce6d82abc;hb=4faf7e4b4b91a9c320f7d60299162b09720f1e4a;hp=d3691673a6b17cfd98a02df4f0d923487c60d885;hpb=094bc471373afa79a63c024909d57261fef00b2f;p=familia.git diff --git a/src/storage/family.h b/src/storage/family.h index d369167..adf2dac 100644 --- a/src/storage/family.h +++ b/src/storage/family.h @@ -17,8 +17,8 @@ * * ****************************************************************************/ -#ifndef _FAMILIA_MARRIAGE_H -#define _FAMILIA_MARRIAGE_H +#ifndef _FAMILIA_FAMILY_H +#define _FAMILIA_FAMILY_H #include "individual.h" @@ -39,6 +39,12 @@ struct familia_family { /** Second individual of family */ struct familia_individual * individual2; + + /** Children of this family */ + struct familia_individual ** children; + + /** Number of children of this family */ + unsigned short children_no; }; /** @@ -50,7 +56,7 @@ struct familia_family * familia_family_new(); /** * Frees allocated memory of the given family - * DISCLAIMER! This function does not remove linked individuals. You have to + * DISCLAIMER! This function does not free memory of linked individuals. You have to * remove them manually from storage. * @parameter individual free */ @@ -61,22 +67,53 @@ void familia_family_free(struct familia_family * family); * @parameter family to set the individual * @parameter individual which will be set */ -void familia_family_set_individual(struct familia_family * family, struct familia_individual * individual, enum FFamilyIndividualIndex index); +void familia_family_set_parent(struct familia_family * family, struct familia_individual * individual, enum FFamilyIndividualIndex index); /** * Gets individual from the given family * @parameter family to get the individual * @parameter individual index of which individual get */ -struct familia_individual * familia_family_get_individual(struct familia_family * family, enum FFamilyIndividualIndex index); +struct familia_individual * familia_family_get_parent(struct familia_family * family, enum FFamilyIndividualIndex index); /** * Removes individual from the given family - * DISCLAIMER! This function does not remove linked individuals. You have to + * DISCLAIMER! This function does not free memory of linked individuals. You have to * remove them manually from storage. * @parameter family to remove the individual * @parameter individual index of which individual to remove + * @return returns removed individual, NULL if such does not exist. + */ +struct familia_individual * familia_family_remove_parent(struct familia_family * family, enum FFamilyIndividualIndex index); + +/** + * Adds new child in the given family + * Automatically sets family as parents in individual variable. + * + * @parameter family to set the individual + * @parameter individual which will be added + */ +void familia_family_add_child(struct familia_family * family, struct familia_individual * individual); + +/** + * Gets the nth child from the given family + * Child with index = 0 is the oldest. Bigger the index, the child is younger + * @parameter family to get the child + * @parameter individual index of which individual get + * @return selected child. If index is bigger than child_no of the family + * returns NULL. + */ +struct familia_individual * familia_family_get_child_by_id(struct familia_family * family, unsigned short index); + +/** + * Removes child from the given family + * DISCLAIMER! This function does not free memory of linked children. You have to + * remove them manually from storage. + * @parameter family to remove the child + * @parameter index of which child should be removed + * @return removed child. If such does not exist or index is bigger than child_no + * of the family, returns NULL. */ -struct familia_individual * familia_family_remove_individual(struct familia_family * family, enum FFamilyIndividualIndex index); +struct familia_individual * familia_family_remove_child_by_id(struct familia_family * family, unsigned short index); -#endif /*_FAMILIA_MARRIAGE_H */ +#endif /*_FAMILIA_FAMILY_H */