mirror of
https://github.com/espressif/openthread.git
synced 2026-07-25 21:44:07 +00:00
[locator] adding Get<Type> to InstanceLocator (#3714)
This commit changes how the objects in OpenThread access each other. It adds a template `Get<Type>()` method in `InstanceLocator`. This method returns a reference to a given `Type` object belonging to the OpenThread instance (e.g. `Get<MeshForwarder>()` returns a reference to `MeshForwarder` object on the OpenThread instance). The `InstanceLocator` is used as base class of all OpenThread classes so every class can easily access any other object. This commit also changes how the main instance is retrieved in `InstanceLocator` for the single-instance case. The method `GetInstance()` directly uses the raw buffer `gInstanceRaw`. This change helps make the `GetInstance()` and in turn all `Get<Type>()` methods in-line. This commit also removes the existing getters across all classes to use the new `Get<Type>()` model.
This commit is contained in:
committed by
Jonathan Hui
parent
9dfa4e2b31
commit
8f112eeb5a
@@ -220,7 +220,7 @@ void TestPriorityQueue(void)
|
||||
instance = testInitInstance();
|
||||
VerifyOrQuit(instance != NULL, "Null OpenThread instance\n");
|
||||
|
||||
messagePool = &instance->GetMessagePool();
|
||||
messagePool = &instance->Get<ot::MessagePool>();
|
||||
|
||||
// Use the function "New()" to allocate messages with different priorities
|
||||
for (int i = 0; i < kNumNewPriorityTestMessages; i++)
|
||||
|
||||
Reference in New Issue
Block a user