Hi there.
I'm interested in the dynamic creation of a simulated network using
ThruputMeteringChannel.
Until now I built my network dynamically with
cDatarateChannel and it work fine.
One the other hand INET examples based on ThruputMeteringChannel in NED files work fine too.
However I don't manage to create
ThruputMeteringChannel dynamically (ie without NED declarations).
I tried:
ThruputMeteringChannel *thruputMeteringChannel = new ThruputMeteringChannel("thruputMeteringChannel");
// then I connect the channel, initialize it etc
But it get the following error message at the initialization time:
thruputMeteringChannel:
Object has no associated cComponentType (maybe ThruputMeteringChannel
should not subclass cModule/cChannel?)
This is due
to the fact that the
ThruputMeteringChannel constructor
actually use the constructor of the Base Class
DatarateChannel instead of the
DatarateChannel::create() method:
ThruputMeteringChannel::ThruputMeteringChannel(const char *name) : cDatarateChannel(name)
{...}
AND, as said in "cdataratechannel.h", the create method must be used for dataratechannel dynamic creation rather than the constructor:
/**
* Constructor. This is only for internal purposes, and should not
* be used when creating channels dynamically; use the create()
* factory method instead.
*/
explicit cDatarateChannel(const char *name=NULL);
In C++, the derived class constructor implicitely call the base classe constructor and not another mehod (like 'create').
So I guess that the dynamic creation of ThruputMeteringChannel is not possible !
As well, it is not possible to create any
dataratechannel's derived class dynamically, because the correct dynamic
creation is done with the create method...
Could anyone tell me if I missunderstood something ?
Thanks in advance for help