Bug 1344

Summary: Can't set default value of an attribute in the derived class
Product: ns-3 Reporter: Artem Krasilov <krasilov>
Component: coreAssignee: Mathieu Lacage <mathieu.lacage>
Status: RESOLVED INVALID    
Severity: normal CC: ns-bugs, tomh, tommaso.pecorella
Priority: P5    
Version: ns-3.12   
Hardware: All   
OS: All   
Attachments: the program representing 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.