SatCat5
list.h File Reference

Detailed Description

Templated functions for manipulating singly-linked lists.

Several SatCat5 classes use singly-linked lists. To reduce code duplication, we define the "ListCore" function templates for:

  • Adding an item to the head of a list.
  • Checking if an item is already contained in a list.
  • Counting the number of items in a list.
  • Removing an item from any point in a list.

These functions are required for safe initialization of certain global variables, such as those found in satcat5/interrupts.cc. However, most other users should use the simplified "List" wrapper class.

The requirements for items using these either format are:

  • The object MUST declare itself as a friend of satcat5::util::ListCore.
  • The object MUST be a class or struct with a member named "m_next" that is a pointer to the same type of object.
  • The object MUST initialize the pointer to zero. It MUST NOT otherwise access the pointer except through SatCat5 ListCore or List functions.
  • The object MUST NOT add itself to more than one list using a given "m_next" pointer. Objects MAY safely inherit more than one "m_next" pointer from different parents.
  • The pointer SHOULD generally be marked as "private". This reduces the chance of namespace conflicts (see previous item).
  • The object MUST NOT add itself to a given list more than once.
  • If the object's constructor adds itself to a list, then the object's destructor SHOULD remove itself from that list.

Caller is responsible for calling AtomicLock if required.

Definition in file list.h.

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  satcat5::util::ListCore
 Helper functions for manipulating singly-linked lists. More...
 
class  satcat5::util::List< T >
 Templated linked-list class. More...