Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow custom transport and MAC constructor arguments #159

Merged
merged 2 commits into from Apr 1, 2020
Merged

Allow custom transport and MAC constructor arguments #159

merged 2 commits into from Apr 1, 2020

Conversation

bobmourlam
Copy link
Contributor

@bobmourlam bobmourlam commented Mar 31, 2020

In the current buildTransportWithAdapter and buildMACLayer_T functions
you are limited to only passing in NEMId, PlatformServiceProvider* and RadioServiceProvider* (MAC) as constructor params for a custom transport or MAC layer.

This change uses a parameter pack to allow an arbitrary number of
arguments to be passed to the transport/MAC constructor. And by using
perfect forwarding there should be no additional cost in copying those
params to the transport instance.

For example, with this change you can do something like this:

class MyCoolTransport
{
public:
   MyCoolTransport(
      NEMId id, 
      PlatformServiceProvider* platformService, 
      int customVar1.
      const std::string& customVar2);
};

...

auto ret =
   transportBuilder.buildTransportWithAdapter<MyCoolTransport>(
      id,
      {},  // ConfigurationUpdateRequest
      platformendpoint,
      transportendpoint,
      42,
      "My Cool String");

See also this change. I don't intend to merge this, but used it to test the change to buildMACLayer_T.
bobmourlam/emane-embedded-example@3147d0f?w=1

Signed-off-by: Bob Mourlam bob.mourlam@gmail.com

In the current buildTransportWithAdapter function you are only able to
pass in NEMId, ConfigurationUpdateRequest, the platform endpoint string
and the transport endpoint string.  Of those, only the NEMId and
PlatformServiceProvider* are passed to the constructor of the T
transport instance that is new-ed.  This forces any custom transport to
only take those 2 params.

This change uses a parameter pack to allow an arbitrary number of
arguments to be passed to the transport constructor.  And by using
perfect forwarding there should be no additional cost in copying those
params to the transport instance.

Signed-off-by: Bob Mourlam <bob.mourlam@gmail.com>
In the current buildMACLayer_T function you are only able to
pass in NEMId, registration string, ConfigurationUpdateRequest and the
bSkipConfigure flag.  Within the buildMACLayer_T function the MAC layer
being built is passed only the NEMId and newly constructed platform
service and radio service pointers.  There's no way to pass in any
custom constructor params.

This change uses a parameter pack to allow an arbitrary number of
arguments to be passed to the MAC constructor.  And by using perfect
forwarding there should be no additional cost in copying those params to
the MAC instance.

Signed-off-by: Bob Mourlam <bob.mourlam@gmail.com>
@sgalgano sgalgano merged commit 0317dbf into adjacentlink:develop Apr 1, 2020
@sgalgano
Copy link
Member

sgalgano commented Apr 1, 2020

Thanks for the pull. This is a great add. And thanks for making your test artifacts available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants