View | Details | Raw Unified | Return to bug 1604
Collapse All | Expand All

(-)a/src/core/model/config.cc (+26 lines)
 Lines 776-781    Link Here 
776
  return Singleton<ConfigImpl>::Get ()->GetRootNamespaceObject (i);
776
  return Singleton<ConfigImpl>::Get ()->GetRootNamespaceObject (i);
777
}
777
}
778
778
779
std::string GetDefault (const std::string attributePath)
780
{
781
  NS_LOG_FUNCTION (attributePath);
782
  // Attribute name is last token
783
  size_t colon = attributePath.rfind ("::");
784
  const std::string typeName = attributePath.substr (0, colon);
785
  NS_LOG_DEBUG ("typeName: '" << typeName << "', colon: " << colon);
786
  
787
  TypeId tid;
788
  if (!TypeId::LookupByNameFailSafe (typeName, &tid))
789
    {
790
      NS_FATAL_ERROR ("Unknown type=" << typeName);
791
    }
792
793
  const std::string attrName = attributePath.substr (colon + 2);
794
  struct TypeId::AttributeInformation info;  
795
  if (!tid.LookupAttributeByName (attrName, &info))
796
    {
797
      NS_FATAL_ERROR ("Attribute not found: " << attributePath);
798
    }
799
800
  std::string defValue = info.initialValue->SerializeToString (info.checker);
801
802
  return defValue;
803
}
804
779
} // namespace Config
805
} // namespace Config
780
806
781
} // namespace ns3
807
} // namespace ns3
(-)a/src/core/model/config.h (+12 lines)
 Lines 247-252    Link Here 
247
 */
247
 */
248
Ptr<Object> GetRootNamespaceObject (uint32_t i);
248
Ptr<Object> GetRootNamespaceObject (uint32_t i);
249
249
250
/**
251
 * Get the current default value for an attribute.
252
 *
253
 * The current default is the initial value which would be
254
 * used by new instances of the type, including any
255
 * CommandLine configuration.
256
 *
257
 * \param attributePath The configuration path for the attribute.
258
 * \returns The default value, serialized to a string.
259
 */
260
  std::string GetDefault (const std::string attributePath);
261
  
250
} // namespace Config
262
} // namespace Config
251
263
252
} // namespace ns3
264
} // namespace ns3

Return to bug 1604