mbed.org local branch of microbit-dal. The real version lives in git at https://github.com/lancaster-university/microbit-dal

Dependencies:   BLE_API nRF51822 mbed-dev-bin

Dependents:   microbit Microbit IoTChallenge1 microbit ... more

Embed: (wiki syntax)

« Back to documentation index

RefCounted Struct Reference

RefCounted Struct Reference

Base class for payload for ref-counted objects. More...

#include <RefCounted.h>

Inherited by ImageData, PacketData, and StringData.

Public Member Functions

void incr ()
 Increment reference count.
void decr ()
 Decrement reference count.
void init ()
 Initializes for one outstanding reference.
bool isReadOnly ()
 Checks if the object resides in flash memory.

Data Fields

uint16_t refCount
 The high 15 bits hold the number of outstanding references.

Detailed Description

Base class for payload for ref-counted objects.

Used by ManagedString and MicroBitImage. There is no constructor, as this struct is typically malloc()ed.

Definition at line 37 of file RefCounted.h.


Member Function Documentation

void decr (  )

Decrement reference count.

Definition at line 89 of file RefCounted.cpp.

void incr (  )

Increment reference count.

Definition at line 80 of file RefCounted.cpp.

void init (  )

Initializes for one outstanding reference.

Base class for payload for ref-counted objects.

Used by ManagedString and MicroBitImage. There is no constructor, as this struct is typically malloc()ed. Initializes for one outstanding reference.

Definition at line 38 of file RefCounted.cpp.

bool isReadOnly (  )

Checks if the object resides in flash memory.

Returns:
true if the object resides in flash memory, false otherwise.

Definition at line 72 of file RefCounted.cpp.


Field Documentation

uint16_t refCount

The high 15 bits hold the number of outstanding references.

The lowest bit is always 1 to make sure it doesn't look like vtable. Should never be even or one (object should be deleted then). When it's set to 0xffff, it means the object sits in flash and should not be counted.

Definition at line 47 of file RefCounted.h.