diff options
| author | Felix Morgner <felix.morgner@gmail.com> | 2025-05-20 10:08:01 +0200 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@gmail.com> | 2025-05-20 10:08:01 +0200 |
| commit | 7d9d987d6ccb80aabe98ee1fdb9e5bcc7394ddf2 (patch) | |
| tree | 636c9daea8b2278b731fd364f366967d05945ee9 | |
| parent | 3888afed7c875ee400290f3214d7a377a13394c7 (diff) | |
| download | turns-7d9d987d6ccb80aabe98ee1fdb9e5bcc7394ddf2.tar.xz turns-7d9d987d6ccb80aabe98ee1fdb9e5bcc7394ddf2.zip | |
lib: add basic uuid to participant
| -rw-r--r-- | lib/src/turns-participant.cpp | 10 | ||||
| -rw-r--r-- | lib/src/turns-participant.h | 8 |
2 files changed, 17 insertions, 1 deletions
diff --git a/lib/src/turns-participant.cpp b/lib/src/turns-participant.cpp index 8f929f0..97a7ed0 100644 --- a/lib/src/turns-participant.cpp +++ b/lib/src/turns-participant.cpp @@ -16,6 +16,7 @@ struct _TurnsParticipant gboolean active; gboolean defeated; TurnsParticipantDisposition disposition; + gchar * id; gchar * name; gfloat priority; }; @@ -42,6 +43,7 @@ namespace { auto participant = TURNS_PARTICIPANT(self); + g_free(participant->id); g_free(participant->name); G_OBJECT_CLASS(turns_participant_parent_class)->finalize(self); @@ -145,7 +147,7 @@ static void turns_participant_class_init(TurnsParticipantClass * klass) static void turns_participant_init(TurnsParticipant * self) { - (void)self; + self->id = g_uuid_string_random(); } TurnsParticipant * turns_participant_new() @@ -179,6 +181,12 @@ TurnsParticipantDisposition turns_participant_get_disposition(TurnsParticipant c return self->disposition; } +gchar const * turns_participant_get_id(TurnsParticipant const * self) +{ + g_return_val_if_fail(TURNS_IS_PARTICIPANT(const_cast<TurnsParticipant *>(self)), nullptr); + return self->id; +} + gchar const * turns_participant_get_name(TurnsParticipant const * self) { g_return_val_if_fail(TURNS_IS_PARTICIPANT(const_cast<TurnsParticipant *>(self)), nullptr); diff --git a/lib/src/turns-participant.h b/lib/src/turns-participant.h index fa5e7cd..6ed8ac6 100644 --- a/lib/src/turns-participant.h +++ b/lib/src/turns-participant.h @@ -65,6 +65,14 @@ gboolean turns_participant_get_defeated(TurnsParticipant const * self); TurnsParticipantDisposition turns_participant_get_disposition(TurnsParticipant const * self); /** + * @brief Get the id of a participant. + * + * @param self A participant instance. The value *must not* be NULL. + * @return The id of the instance. The value is owned by the caller of the function. + */ +gchar const * turns_participant_get_id(TurnsParticipant const * self); + +/** * @brief Get the name of a participant. * * @param self A Participant instance. The value *must not* be NULL. |
