ME507 Utility Library  0.2.1
Mechatronics Course Support Software for ARM/Arduino/FreeRTOS
BaseShare Class Referenceabstract

Base class for classes that share data in a thread-safe manner between tasks. More...

#include <baseshare.h>

Inheritance diagram for BaseShare:
Collaboration diagram for BaseShare:

Public Member Functions

 BaseShare (const char *p_name=NULL)
 Construct a base shared data item. More...
 
virtual void print_in_list (Print &printer)=0
 Print one shared data item within a list. More...
 

Protected Attributes

char name [16]
 The name of the shared item. More...
 
BaseSharep_next
 Pointer to the next item in the linked list of shares. More...
 

Static Protected Attributes

static BaseSharep_newest = NULL
 Pointer to the most recently created shared data item. More...
 

Friends

void print_all_shares (Print &printer)
 Start the printout showing the status of all shared data items. More...
 

Detailed Description

Base class for classes that share data in a thread-safe manner between tasks.

This is a base class for classes which share data between tasks without the risk of data corruption associated with global variables. Queues and task shares are two examples of such shared data classes.

Constructor & Destructor Documentation

◆ BaseShare()

BaseShare::BaseShare ( const char *  p_name = NULL)

Construct a base shared data item.

This default constructor saves the name of the shared data item. It is not to be called by application code (nobody has any reason to create a base class object which can't do anything!) but instead by the constructors of descendent classes.

Parameters
p_nameThe name for the shared data item, in a character string

Member Function Documentation

◆ print_in_list()

virtual void BaseShare::print_in_list ( Print &  printer)
pure virtual

Print one shared data item within a list.

Make a printout showing the condition of this shared data item, such as the value of a shared variable or how full a queue's buffer is. This method must be overridden in each descendent class with a method that actually does something.

Parameters
printerReference to a serial device on which to print

Implemented in Share< DataType >, Queue< dataType >, and Queue< char >.

Friends And Related Function Documentation

◆ print_all_shares

void print_all_shares ( Print &  printer)
friend

Start the printout showing the status of all shared data items.

This method begins printing out the status of all items in the system's linked list of shared data items (queues, task shares, and so on). The most recently created share's status is printed first, followed by the status of other shares in reverse order of creation.

Parameters
printerPointer to a serial device on which to print

Member Data Documentation

◆ name

char BaseShare::name[16]
protected

The name of the shared item.

This string holds the shared item's name. The name is only used for identification on debugging printouts or logs.

◆ p_newest

BaseShare * BaseShare::p_newest = NULL
staticprotected

Pointer to the most recently created shared data item.

This static variable, one copy of which is shared by all shared data items, is a pointer to the most recently created one. It is used as the beginning of a linked list of all shared data items in the system.

◆ p_next

BaseShare* BaseShare::p_next
protected

Pointer to the next item in the linked list of shares.

This pointer points to the next item in the system's list of shared data items (shares, queues, etc.) If this share is the most recently created one, the pointer will be NULL. The list goes backwards; the next item is the previously created one.


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