Bug 1344 - Can't set default value of an attribute in the derived class
Can't set default value of an attribute in the derived class
Status: RESOLVED INVALID
Product: ns-3
Classification: Unclassified
Component: core
ns-3.12
All All
: P5 normal
Assigned To: Mathieu Lacage
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-01-16 08:42 UTC by Artem Krasilov
Modified: 2013-08-06 14:16 UTC (History)
3 users (show)

See Also:


Attachments
the program representing bug (1.04 KB, text/x-c++src)
2012-01-16 08:42 UTC, Artem Krasilov
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Artem Krasilov 2012-01-16 08:42:36 UTC
Created attachment 1307 [details]
the program representing bug

I have two inheriting classes: ns3::WifiMac and ns3::AdhocWifiMac. The parent class (ns3::WifiMac) has the attribute CtsTimeout. When I try to set default value of this attribute for ns3::AdhocWifiMac class (via Config::SetDefault) the program throws fatal error:  

msg="Could not set default value for ns3::AdhocWifiMac::CtsTimeout", file=../src/core/model/config.cc, line=613.

The program representing the error is in attachment. It should be mentioned the in ns-3.11 release it works fine.

It seems that the problem is that SetDefaultFailSafe method in src/core/model/config.cc file looks throw the atributes of the requested class only and does not look through it's parents atributes.
Comment 1 Tommaso Pecorella 2013-08-06 14:16:40 UTC
Attributes are not inherited by sub-classes. A sub-class might use a base class attribute though its accessors, however this does not mean that the attribute is owned by the sub-class.

Attributes *must* be set in the class they are defined. In this case ns3::WifiMac.