[Ns-developers] Learning Bridge, NetDevice API changes

Gustavo Carneiro gjcarneiro at gmail.com
Mon Jul 7 04:28:28 PDT 2008


2008/7/6 Tom Henderson <tomh at tomh.org>:
[...]

> Also, a small ns-3 coding style question:
>
> +          Ptr<NetDevice> dev = node->GetDevice (i);
> +          if (dynamic_cast<CsmaNetDevice*> (PeekPointer (dev)))
>
> Can't this dynamic cast be replaced by:
>
>    if (dev->GetObject<CsmaNetDevice> ())


It can.

Although, as a matter of performance, I strongly suspect the dynamic_cast
version is much faster, and as a matter of style I tend to prefer plain C++
constructs than NS-3 constructs (I already hear students calling NS-3
another programming language, not C++).

-- 
Gustavo J. A. M. Carneiro
INESC Porto, Telecommunications and Multimedia Unit
"The universe is always one step beyond logic." -- Frank Herbert


More information about the Ns-developers mailing list