Is ThruputMeteringChannel dynamic creation possible ? (INET)

249 views
Skip to first unread message

damien....@gmail.com

unread,
Oct 3, 2013, 10:32:48 AM10/3/13
to omn...@googlegroups.com
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

damien....@gmail.com

unread,
Oct 3, 2013, 11:47:23 AM10/3/13
to omn...@googlegroups.com
My message is not very clear :-).
I mean that, given the cDatarateChannel implementation it is not possible to instanciate properly any channel derived from cDatarateChannel without NED files.
Thus for me the problem does not come from ThrughputMeteringChannel but from cDatarateChannel.

damien....@gmail.com

unread,
Oct 7, 2013, 9:26:22 AM10/7/13
to omn...@googlegroups.com
So the only way to have thruput metering channels that can be dynamically created is to implement a Thruputmetering channel class in OMNet, with its own cComponentType etc and rebuild OMNet... (!!)
Reply all
Reply to author
Forward
0 new messages