libcontrac
A library for contact tracing
Data Structures | Functions
Containers

Provides containers for managing lists of items. More...

Data Structures

struct  DtkListItem
 A DTK list element. More...
 
struct  DtkList
 The head of a DTK list. More...
 
struct  RpiListItem
 An RPI list element. More...
 
struct  RpiList
 The head of an RPI list. More...
 

Functions

DtkList * dtk_list_new ()
 
void dtk_list_delete (DtkList *data)
 
void dtk_list_append (DtkList *data, Dtk *dtk)
 
DtkListItem const * dtk_list_first (DtkList const *data)
 
DtkListItem const * dtk_list_next (DtkListItem const *data)
 
Dtk const * dtk_list_get_dtk (DtkListItem const *data)
 
void dtk_list_add_diagnosis (DtkList *data, unsigned char const *dtk_bytes, uint32_t day_number)
 
RpiList * rpi_list_new ()
 
void rpi_list_delete (RpiList *data)
 
void rpi_list_append (RpiList *data, Rpi *rpi)
 
RpiListItem const * rpi_list_first (RpiList const *data)
 
RpiListItem const * rpi_list_next (RpiListItem const *data)
 
Rpi const * rpi_list_get_rpi (RpiListItem const *data)
 
void rpi_list_add_beacon (RpiList *data, unsigned char const *rpi_bytes, uint8_t time_interval_number)
 

Detailed Description

Provides containers for managing lists of items.

This allows the simplified management of lists of Dtk and Rpi objects. This is useful when checking DTKs received from a Diagnosis Server with RPIs captured over Bluetooth. The two can be easily stored and passed into the match_list_find_matches() function.

Function Documentation

◆ dtk_list_add_diagnosis()

void dtk_list_add_diagnosis ( DtkList *  data,
unsigned char const *  dtk_bytes,
uint32_t  day_number 
)

Adds Dtk data to the list.

The dtk_bytes buffer passed in must contain exactly DTK_SIZE (16) bytes of data. It doen't have to be null terminated.

Parameters
dataThe current list to operate on.
dtk_bytesThe DTK value to add, in binary format.
day_numberThe day number to associate with the DTK.

◆ dtk_list_append()

void dtk_list_append ( DtkList *  data,
Dtk *  dtk 
)

Adds an item to the list.

This adds a Dtk item to the list. It's primarily for internal use and when adding DTKs to the list it's usually more appropriate to use the dtk_list_add_diagnosis() function.

Parameters
dataThe list to append to.
dtkThe DTK to append.

◆ dtk_list_delete()

void dtk_list_delete ( DtkList *  data)

Deletes an instance of the class, freeing up the memory allocated to it.

This will also delete all items contained in the list.

Parameters
dataThe instance to free.

◆ dtk_list_first()

DtkListItem const * dtk_list_first ( DtkList const *  data)

Returns the first item in the list.

Useful for iterating through the items in the list.

Parameters
dataThe list to operate on.
Returns
The first item of the list.

◆ dtk_list_get_dtk()

Dtk const * dtk_list_get_dtk ( DtkListItem const *  data)

Returns the Dtk item contained in this list item.

Parameters
dataThe current item in the list.
Returns
The Dtk instance stored in the list element.

◆ dtk_list_new()

DtkList * dtk_list_new ( )

Creates a new instance of the class.

Returns
The newly created object.

◆ dtk_list_next()

DtkListItem const * dtk_list_next ( DtkListItem const *  data)

Returns the next item in the list.

Useful for iterating through the items in the list.

Parameters
dataThe current item in the list.
Returns
The next item in the list following the current item.

◆ rpi_list_add_beacon()

void rpi_list_add_beacon ( RpiList *  data,
unsigned char const *  rpi_bytes,
uint8_t  time_interval_number 
)

Adds Rpi data to the list.

The rpi_bytes buffer passed in must contain exactly RPI_SIZE (16) bytes of data. It doen't have to be null terminated.

Parameters
dataThe current list to operate on.
rpi_bytesThe RPI value to add, in binary format.
time_interval_numberThe time interval number to associate with the RPI.

◆ rpi_list_append()

void rpi_list_append ( RpiList *  data,
Rpi *  rpi 
)

Adds an item to the list.

This adds an Rpi item to the list. It's primarily for internal use and when adding RPIs to the list it's usually more appropriate to use the rpi_list_add_beacon() function.

Parameters
dataThe list to append to.
rpiThe RPI to append.

◆ rpi_list_delete()

void rpi_list_delete ( RpiList *  data)

Deletes an instance of the class, freeing up the memory allocated to it.

This will also delete all items contained in the list.

Parameters
dataThe instance to free.

◆ rpi_list_first()

RpiListItem const * rpi_list_first ( RpiList const *  data)

Returns the first item in the list.

Useful for iterating through the items in the list.

Parameters
dataThe list to operate on.
Returns
The first item of the list.

◆ rpi_list_get_rpi()

Rpi const * rpi_list_get_rpi ( RpiListItem const *  data)

Returns the Rpi item contained in this list item.

Parameters
dataThe current item in the list.
Returns
The Rpi instance stored in the list element.

◆ rpi_list_new()

RpiList * rpi_list_new ( )

Creates a new instance of the class.

Returns
The newly created object.

◆ rpi_list_next()

RpiListItem const * rpi_list_next ( RpiListItem const *  data)

Returns the next item in the list.

Useful for iterating through the items in the list.

Parameters
dataThe current item in the list.
Returns
The next item in the list following the current item.