Relationship Generator 1.2.2
Believable families around a person: parents, siblings, partners and children, with ages and names for C++23
Loading...
Searching...
No Matches
dasmig::family Class Reference

Return type for family generation. More...

#include <relgen.hpp>

Public Member Functions

const person & anchor () const
 The person the family is built around.
 
std::vector< person > with_role (relation r) const
 The members with a given role.
 
std::vector< person > parents () const
 The anchor's parents.
 
std::vector< person > siblings () const
 The anchor's full siblings, oldest first.
 
std::vector< person > half_siblings () const
 The anchor's half-siblings, oldest first.
 
std::vector< person > grandparents () const
 The anchor's grandparents.
 
std::vector< person > partners () const
 The anchor's partners, in the order the unions began.
 
std::vector< person > children () const
 The anchor's children, oldest first.
 
std::vector< person > grandchildren () const
 The anchor's grandchildren, oldest first.
 
std::vector< person > stepchildren () const
 The children of the anchor's partners by earlier unions.
 
std::vector< person > stepparents () const
 The anchor's stepparents: the partners of a parent who are not the other parent.
 
std::vector< person > stepsiblings () const
 The stepparents' children by an earlier union.
 
std::optional< edge > union_with (std::size_t partner_id) const
 The union with a partner.
 
std::uint64_t seed () const
 Retrieve the random seed used to generate this family.
 
const core::seed_signature & signature () const
 The seed and the data this family was generated from.
 
std::string to_string () const
 Human-readable summary string.
 
void to_json (core::json_writer &w) const
 Write this family as a JSON object.
 
std::string to_json () const
 This family as a JSON document.
 
 operator std::string () const
 Implicit conversion to std::string.
 

Static Public Member Functions

static std::string iso_date (const std::chrono::year_month_day &d)
 A date as YYYY-MM-DD.
 

Public Attributes

std::string country_code
 The anchor's country; the family lives there.
 
std::chrono::year_month_day reference_date {}
 The date ages and who is alive refer to.
 
std::vector< person > members
 Everyone; members[i].id == i.
 
std::vector< edge > edges
 Parent, sibling and partner links.
 
data_source fertility_source {data_source::country}
 Where the fertility figures came from.
 
data_source union_source {data_source::country}
 Where the marriage figures came from.
 
std::optional< household > home {}
 Who the anchor lives with; set only when family_request::home was. // NOLINT(readability-redundant-member-init)
 

Friends

class relg
 
std::ostream & operator<< (std::ostream &os, const family &v)
 Stream the summary to an output stream.
 

Detailed Description

Return type for family generation.

Holds the members (the anchor is members[0]) and the links between them, and supports streaming a short summary via operator<< and JSON output via to_json().

Definition at line 353 of file relgen.hpp.

Member Function Documentation

◆ anchor()

const person & dasmig::family::anchor ( ) const
inline

The person the family is built around.

Returns
members[0].

Definition at line 366 of file relgen.hpp.

◆ children()

std::vector< person > dasmig::family::children ( ) const
inline

The anchor's children, oldest first.

Returns
The children, by birth and by adoption.

Definition at line 427 of file relgen.hpp.

◆ grandchildren()

std::vector< person > dasmig::family::grandchildren ( ) const
inline

The anchor's grandchildren, oldest first.

Returns
The grandchildren.

Definition at line 431 of file relgen.hpp.

◆ grandparents()

std::vector< person > dasmig::family::grandparents ( ) const
inline

The anchor's grandparents.

Returns
Paternal then maternal, father's side first.

Definition at line 410 of file relgen.hpp.

◆ half_siblings()

std::vector< person > dasmig::family::half_siblings ( ) const
inline

The anchor's half-siblings, oldest first.

The children of a parent and a stepparent take ids after the stepparents (see family_request::stepparents), so ids are not in birth order when there are some.

Returns
The half-siblings.

Definition at line 400 of file relgen.hpp.

◆ iso_date()

static std::string dasmig::family::iso_date ( const std::chrono::year_month_day &  d)
inlinestatic

A date as YYYY-MM-DD.

Parameters
dThe date.
Returns
ISO 8601 text.

Definition at line 586 of file relgen.hpp.

◆ operator std::string()

dasmig::family::operator std::string ( ) const
inline

Implicit conversion to std::string.

Returns
Summary string.

Definition at line 568 of file relgen.hpp.

◆ parents()

std::vector< person > dasmig::family::parents ( ) const
inline

The anchor's parents.

Returns
Father then mother, as present.

Definition at line 383 of file relgen.hpp.

◆ partners()

std::vector< person > dasmig::family::partners ( ) const
inline

The anchor's partners, in the order the unions began.

Returns
The partners, current and former.

Definition at line 423 of file relgen.hpp.

◆ seed()

std::uint64_t dasmig::family::seed ( ) const
inline

Retrieve the random seed used to generate this family.

Returns
The call seed; pass it to get_family(request, seed) with the same request and data to replay this family.

Definition at line 466 of file relgen.hpp.

◆ siblings()

std::vector< person > dasmig::family::siblings ( ) const
inline

The anchor's full siblings, oldest first.

Returns
The siblings.

Definition at line 392 of file relgen.hpp.

◆ signature()

const core::seed_signature & dasmig::family::signature ( ) const
inline

The seed and the data this family was generated from.

Returns
The replay signature; data is relg::data_hash() at the time of generation.

Definition at line 471 of file relgen.hpp.

◆ stepchildren()

std::vector< person > dasmig::family::stepchildren ( ) const
inline

The children of the anchor's partners by earlier unions.

Returns
The stepchildren, oldest first.

Definition at line 435 of file relgen.hpp.

◆ stepparents()

std::vector< person > dasmig::family::stepparents ( ) const
inline

The anchor's stepparents: the partners of a parent who are not the other parent.

Returns
Stepfathers then stepmothers, as present (see family_request::stepparents).

Definition at line 440 of file relgen.hpp.

◆ stepsiblings()

std::vector< person > dasmig::family::stepsiblings ( ) const
inline

The stepparents' children by an earlier union.

Returns
The stepsiblings, oldest first (see family_request::stepparents).

Definition at line 449 of file relgen.hpp.

◆ to_json() [1/2]

std::string dasmig::family::to_json ( ) const
inline

This family as a JSON document.

Returns
Compact JSON, for example {"country":"BR","reference_date":"2023-07-01","members":[...],"edges":[...],...}.

Definition at line 559 of file relgen.hpp.

◆ to_json() [2/2]

void dasmig::family::to_json ( core::json_writer &  w) const
inline

Write this family as a JSON object.

Parameters
wWriter positioned where a value is allowed.

Definition at line 486 of file relgen.hpp.

◆ to_string()

std::string dasmig::family::to_string ( ) const
inline

Human-readable summary string.

Returns
For example BR family of 5 (anchor born 1983-05-20).

Definition at line 478 of file relgen.hpp.

◆ union_with()

std::optional< edge > dasmig::family::union_with ( std::size_t  partner_id) const
inline

The union with a partner.

Parameters
partner_idThe partner's id.
Returns
The link, or nothing if the member is not a partner.

Definition at line 454 of file relgen.hpp.

◆ with_role()

std::vector< person > dasmig::family::with_role ( relation  r) const
inline

The members with a given role.

Parameters
rThe role.
Returns
Copies of them, in id order.

Definition at line 371 of file relgen.hpp.

Friends And Related Symbol Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  os,
const family &  v 
)
friend

Stream the summary to an output stream.

Parameters
osOutput stream.
vThe family to stream.
Returns
The stream.

Definition at line 577 of file relgen.hpp.

◆ relg

friend class relg
friend

Definition at line 594 of file relgen.hpp.

Member Data Documentation

◆ country_code

std::string dasmig::family::country_code

The anchor's country; the family lives there.

Definition at line 356 of file relgen.hpp.

◆ edges

std::vector<edge> dasmig::family::edges

Parent, sibling and partner links.

Definition at line 359 of file relgen.hpp.

◆ fertility_source

data_source dasmig::family::fertility_source {data_source::country}

Where the fertility figures came from.

Definition at line 360 of file relgen.hpp.

◆ home

std::optional<household> dasmig::family::home {}

Who the anchor lives with; set only when family_request::home was. // NOLINT(readability-redundant-member-init)

Definition at line 362 of file relgen.hpp.

◆ members

std::vector<person> dasmig::family::members

Everyone; members[i].id == i.

Definition at line 358 of file relgen.hpp.

◆ reference_date

std::chrono::year_month_day dasmig::family::reference_date {}

The date ages and who is alive refer to.

Definition at line 357 of file relgen.hpp.

◆ union_source

data_source dasmig::family::union_source {data_source::country}

Where the marriage figures came from.

Definition at line 361 of file relgen.hpp.


The documentation for this class was generated from the following file: