The abstract base class of all LifeCycleManager.
More...
#include <fastarduino/lifecycle.h>
The abstract base class of all LifeCycleManager.
It encapsulates all needed API for lifecycle management.
- See also
- LifeCycleManager
-
LifeCycle
Definition at line 131 of file lifecycle.h.
◆ register_()
template<typename T >
| uint8_t lifecycle::AbstractLifeCycleManager::register_ |
( |
LifeCycle< T > & |
instance | ) |
|
|
inline |
Register a LifeCycle<T> instance with this LifeCycleManager.
From now on, instance is tracked by this LifeCycleManager, in particular if it is moved around, its latest address is updated. It is assigned a unique identifier so that it can be retrieved, later on, by calling find_().
- Warning
- This method is NOT synchronized and should be called either from an ISR, or from a synchronized block.
- Template Parameters
-
| T | the type encapsulated in a LifeCycle<T> type |
- Parameters
-
- Returns
- a unique identifier for the registered instance
- Return values
-
| 0 | if an error occurred; this can happen when too many instances are already registered with this LifeCycleManager, or when instance is already registered (with yhis or any LifeCycleManager). |
- See also
- LifeCycle
-
unregister_()
-
find_()
Definition at line 156 of file lifecycle.h.
◆ unregister_()
| bool lifecycle::AbstractLifeCycleManager::unregister_ |
( |
uint8_t |
id | ) |
|
|
inline |
Unregisters a LifeCycle<T> instance, identified by id, already registered with this LifeCycleManager.
- Note
- This is automatically called by
LifeCycle<T> destructor.
- Warning
- This method is NOT synchronized and should be called either from an ISR, or from a synchronized block.
- Parameters
-
| id | the unique identifier for the LifeCycle<T> instance to unregister; this is the value returned by register_(). |
- Return values
-
| true | if the LifeCycle<T> instance was found and successfully deregistered |
| false | if there is no registered instance identified by id |
- See also
- register_()
Definition at line 178 of file lifecycle.h.
◆ available_()
| uint8_t lifecycle::AbstractLifeCycleManager::available_ |
( |
| ) |
const |
|
inline |
Return the number of available "slots" for registration of new LifeCycle<T> instances.
- Note
- This method is atomic, hnece it can freely be called from an ISR or normal code without any synchronization required.
Definition at line 198 of file lifecycle.h.
◆ move_()
| bool lifecycle::AbstractLifeCycleManager::move_ |
( |
uint8_t |
id, |
|
|
AbstractLifeCycle & |
dest |
|
) |
| |
|
inline |
Move an already registered LifeCycle<T> instance (identified by id) to a new location, determine by dest.
Once this method is called, the previous LifeCycle<T> instance becomes unusable (its identifier is reset to 0).
- Warning
- This method is automatically called when a registered
LifeCycle<T> is moved to another instance. You should normally never need to call this method directly.
-
This method is NOT synchronized and should be called either from an ISR, or from a synchronized block.
- Parameters
-
| id | the unique identifier for the LifeCycle<T> instance to move; this is the value returned by register_(). |
| dest | a reference to a LifeCycle<T> instance to receive the instance currently identified by id |
- Return values
-
| true | if the LifeCycle<T> instance was found and successfully moved to dest |
| false | if there is no registered instance identified by id |
Definition at line 224 of file lifecycle.h.
◆ find_()
template<typename T >
| LifeCycle<T>* lifecycle::AbstractLifeCycleManager::find_ |
( |
uint8_t |
id | ) |
const |
|
inline |
Find an existing LifeCycle<T> registered with this LifeCycleManager and identified by id.
This is the only way to get a pointer to the right location of an instance.
- Warning
- A LifeCycleManager can hold
LifeCycle<T> instances of any T type, it does not keep information about actual type of a LifeCycle; hence it cannot ensure safe casting in find_() method. It is the responsibility of the application developer to ensure consistency of the type used in register_() and in find_() for the same id !
-
This method is NOT synchronized and should be called either from an ISR, or from a synchronized block.
- Template Parameters
-
| T | the type encapsulated in a LifeCycle<T> type |
- Parameters
-
| id | the unique identifier for the LifeCycle<T> instance to look for; this is the value returned by register_(). |
- Returns
- a pointer to the found
LifeCycle<T> instance
- Return values
-
| nullptr | if there is no registered instance identified by id |
- See also
- LifeCycle
-
register_()
Definition at line 263 of file lifecycle.h.
The documentation for this class was generated from the following file: