Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to write a helper function

34 views
Skip to first unread message

Adnan Rashid

unread,
Nov 21, 2019, 1:48:37 PM11/21/19
to
Dear All,

I wrote this below code in the source file. (I am using a simulator ns3 which is based on C++)


ApplicationContainer sixLbrApps;
ObjectFactory factory;
factory.SetTypeId (SixLowPanRadvd::GetTypeId ());
Ptr<SixLowPanRadvd> sixLbr = factory.Create<SixLowPanRadvd> ();
nodes.Get (0)->AddApplication (sixLbr);
sixLbrApps.Add (sixLbr);
sixLbrApps.Start(Seconds(0));


How can I write a helper function for the above code? So I can reuse the above functionality by calling the function.

Öö Tiib

unread,
Nov 21, 2019, 7:03:10 PM11/21/19
to
If you need help about concrete library (I guess) like
<https://www.nsnam.org/> then please contact directly the
manufacturer or forum or fan-club of that library. For me
(if to try to be straightly honest) the whole product feels like "dirt"
or "digital waste", sorry. Usenet group comp.lang.c++ is meant to
discuss standard C++ and so such odd libraries are not topical
here.

Jorgen Grahn

unread,
Nov 22, 2019, 1:57:02 AM11/22/19
to
On Fri, 2019-11-22, Öö Tiib wrote:
> On Thursday, 21 November 2019 20:48:37 UTC+2, Adnan Rashid wrote:
>> Dear All,
>>
>> I wrote this below code in the source file. (I am using a simulator
>> ns3 which is based on C++)
>>
>> ApplicationContainer sixLbrApps;
>> ObjectFactory factory;
>> factory.SetTypeId (SixLowPanRadvd::GetTypeId ());
>> Ptr<SixLowPanRadvd> sixLbr = factory.Create<SixLowPanRadvd> ();
>> nodes.Get (0)->AddApplication (sixLbr);
>> sixLbrApps.Add (sixLbr);
>> sixLbrApps.Start(Seconds(0));
>>
>> How can I write a helper function for the above code? So I can
>> reuse the above functionality by calling the function.
>
> If you need help about concrete library (I guess) like
> <https://www.nsnam.org/> then please contact directly the
> manufacturer or forum or fan-club of that library. For me (if to try
> to be straightly honest) the whole product feels like "dirt" or
> "digital waste", sorry.

The API looks ugly, but maybe the actual simulation is good?

> Usenet group comp.lang.c++ is meant to
> discuss standard C++ and so such odd libraries are not topical
> here.

I think the OP is really asking about basic C++ programming, not so
much the library. It's still difficult to come up with a good reply
though ... he can wrap the code in

void helper()
{
// the code above
}

but that will just create and start sixLbrApps and then (I guess)
immediately destroy it.

/Jorgen

--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
0 new messages