ME507 Utility Library
0.2.1
Mechatronics Course Support Software for ARM/Arduino/FreeRTOS
|
Base class for classes that share data in a thread-safe manner between tasks. More...
#include <baseshare.h>
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... | |
BaseShare * | p_next |
Pointer to the next item in the linked list of shares. More... | |
Static Protected Attributes | |
static BaseShare * | p_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... | |
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.
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.
p_name | The name for the shared data item, in a character string |
|
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.
printer | Reference to a serial device on which to print |
Implemented in Share< DataType >, Queue< dataType >, and Queue< char >.
|
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.
printer | Pointer to a serial device on which to print |
|
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.
|
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.
|
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.