FastArduino
v1.9 alpha
C++ library to build fast but small Arduino/AVR projects
|
A proxy class that encapsulates access to a fixed T
instance, or to a dynamic LifeCycle<T>
instance.
More...
#include <fastarduino/lifecycle.h>
Public Member Functions | |
Proxy (const T &dest) | |
Create a Proxy<T> to a static reference. More... | |
template<typename U > | |
Proxy (const LifeCycle< U > &dest) | |
Create a Proxy<T> to a LifeCycle<U> instance (dynamic reference). More... | |
T & | operator* () |
Return a reference to the proxified T instance. | |
T * | operator-> () |
Overloaded -> operator, allowing access to proxified type T instance members. | |
bool | is_dynamic () const |
Tell if this Proxy is dynamic or static. More... | |
uint8_t | id () const |
The identifier of the proxified LifeCycle<U> or 0 if a static instance was proxified. | |
T * | destination () const |
A pointer to the static instance proxified, or nullptr if a dynamic instance (a LifeCycle<U> ) was proxified. | |
AbstractLifeCycleManager * | manager () const |
The LifeCycleManager managing the proxified LifeCycle<U> , or nullptr if a static instance was proxified. | |
Friends | |
bool | operator== (const Proxy< T > &, const Proxy< T > &) |
bool | operator!= (const Proxy< T > &, const Proxy< T > &) |
A proxy class that encapsulates access to a fixed T
instance, or to a dynamic LifeCycle<T>
instance.
This allows to define a method which argument does not have to care whether the object passed should be dynamic or static.
T
instance incurs overhead (data size, code size and speed), you should use Proxy<T>
only when it makes sense.T | the type of the object proxied |
Definition at line 458 of file lifecycle.h.
|
inline |
Create a Proxy<T>
to a static reference.
dest | the reference to a T instance to proxify. |
Definition at line 465 of file lifecycle.h.
|
inline |
Create a Proxy<T>
to a LifeCycle<U>
instance (dynamic reference).
U | the type of reference held by dest ; must be T or a subclass of T , otherwise code will not compile. |
dest | the reference to a LifeCycle<U> instance to proxify; if dest is later moved, it will be automatically tracked by this Proxy<T>. |
Definition at line 479 of file lifecycle.h.
|
inline |
Tell if this Proxy is dynamic or static.
A dynamic proxy was constructed with a LifeCycle<T>
instance and thus ensures that the actual instance will aways be referenced even if it gets moved. A static proxy was constructed directly with a T
instance.
Definition at line 532 of file lifecycle.h.