diff --git a/doc/doxygen.conf b/doc/doxygen.conf index 72be830b6..b4d10dab9 100644 --- a/doc/doxygen.conf +++ b/doc/doxygen.conf @@ -1046,13 +1046,13 @@ ENABLE_PREPROCESSING = YES # compilation will be performed. Macro expansion can be done in a controlled # way by setting EXPAND_ONLY_PREDEF to YES. -MACRO_EXPANSION = NO +MACRO_EXPANSION = YES # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES # then the macro expansion is limited to the macros specified with the # PREDEFINED and EXPAND_AS_DEFINED tags. -EXPAND_ONLY_PREDEF = NO +EXPAND_ONLY_PREDEF = YES # If the SEARCH_INCLUDES tag is set to YES (the default) the includes files # in the INCLUDE_PATH (see below) will be search if a #include is found. @@ -1089,7 +1089,9 @@ PREDEFINED = RUN_SELF_TESTS \ # The macro definition that is found in the sources will be used. # Use the PREDEFINED tag if you want to use a different macro definition. -EXPAND_AS_DEFINED = +EXPAND_AS_DEFINED = ATTRIBUTE_VALUE_DEFINE \ + ATTRIBUTE_VALUE_DEFINE_WITH_NAME \ + ATTRIBUTE_HELPER_HEADER_2 # If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then # doxygen's preprocessor will remove all function-like macros that are alone diff --git a/src/common/data-rate.h b/src/common/data-rate.h index 595565bf1..90a81ace8 100644 --- a/src/common/data-rate.h +++ b/src/common/data-rate.h @@ -89,6 +89,11 @@ private: std::ostream &operator << (std::ostream &os, const DataRate &rate); std::istream &operator >> (std::istream &is, DataRate &rate); +/** + * \class ns3::DataRateValue + * \brief hold objects of type ns3::DataRate + */ + ATTRIBUTE_HELPER_HEADER_2 (DataRate); /** diff --git a/src/core/attribute-helper.h b/src/core/attribute-helper.h index c69882a6a..1b31326b0 100644 --- a/src/core/attribute-helper.h +++ b/src/core/attribute-helper.h @@ -29,21 +29,21 @@ namespace ns3 { template Ptr -MakeSimpleAttributeChecker (std::string name) +MakeSimpleAttributeChecker (std::string name, std::string underlying) { struct SimpleAttributeChecker : public BASE { virtual bool Check (const AttributeValue &value) const { return dynamic_cast (&value) != 0; } - virtual std::string GetType (void) const { + virtual std::string GetValueTypeName (void) const { return m_type; } - virtual bool HasTypeConstraints (void) const { - return false; + virtual bool HasUnderlyingTypeInformation (void) const { + return true; } - virtual std::string GetTypeConstraints (void) const { - return ""; + virtual std::string GetUnderlyingTypeInformation (void) const { + return m_underlying; } virtual Ptr Create (void) const { return ns3::Create (); @@ -59,8 +59,10 @@ MakeSimpleAttributeChecker (std::string name) return true; } std::string m_type; + std::string m_underlying; } *checker = new SimpleAttributeChecker (); checker->m_type = name; + checker->m_underlying = underlying; return Ptr (checker, false); } @@ -108,7 +110,7 @@ MakeSimpleAttributeChecker (std::string name) return MakeAccessorHelper (a1, a2); \ } -#define ATTRIBUTE_VALUE_DEFINE_WITH_NAME(type,name) \ +#define ATTRIBUTE_VALUE_DEFINE_WITH_NAME(type,name) \ class name##Value : public AttributeValue \ { \ public: \ @@ -210,9 +212,16 @@ MakeSimpleAttributeChecker (std::string name) #define ATTRIBUTE_CHECKER_IMPLEMENT(type) \ Ptr Make##type##Checker (void) \ { \ - return MakeSimpleAttributeChecker (#type); \ + return MakeSimpleAttributeChecker (#type "Value", #type); \ } \ +#define ATTRIBUTE_CHECKER_IMPLEMENT_WITH_NAME(type,name) \ + Ptr Make##type##Checker (void) \ + { \ + return MakeSimpleAttributeChecker (#type "Value", name); \ + } \ + + /** * \ingroup AttributeHelper * \param type the name of the class diff --git a/src/core/attribute.h b/src/core/attribute.h index a1f59da7d..7061f1a70 100644 --- a/src/core/attribute.h +++ b/src/core/attribute.h @@ -145,9 +145,28 @@ public: * false otherwise. */ virtual bool Check (const AttributeValue &value) const = 0; - virtual std::string GetType (void) const = 0; - virtual bool HasTypeConstraints (void) const = 0; - virtual std::string GetTypeConstraints (void) const = 0; + /** + * \returns the c++ fully-qualified typename of the subclass + * of the ns3::AttributeValue base class which is associated + * to this checker. + * + * A typical return value here is FooValue where Foo is the name of the + * type being wrapped. + */ + virtual std::string GetValueTypeName (void) const = 0; + /** + * \returns true if this checker has information about the underlying + * C++ type, false otherwise. + * + * If this method returns false, the return value of the GetUnderlyingTypeInformation + * method cannot be relied upon. + */ + virtual bool HasUnderlyingTypeInformation (void) const = 0; + /** + * \returns a human-readable representation of information about + * the underlying C++ type. + */ + virtual std::string GetUnderlyingTypeInformation (void) const = 0; /** * \returns a new instance of an AttributeValue (wrapper in an Attribute * instance) which matches the type of the underlying attribute. diff --git a/src/core/boolean.cc b/src/core/boolean.cc index 64b039881..1f2a8848f 100644 --- a/src/core/boolean.cc +++ b/src/core/boolean.cc @@ -97,6 +97,6 @@ BooleanValue::DeserializeFromString (std::string value, Ptr MakeDoubleChecker (double min, double max, std::stri } return v->Get () >= m_minValue && v->Get () <= m_maxValue; } - virtual std::string GetType (void) const { - return m_name; + virtual std::string GetValueTypeName (void) const { + return "ns3::DoubleValue"; } - virtual bool HasTypeConstraints (void) const { + virtual bool HasUnderlyingTypeInformation (void) const { return true; } - virtual std::string GetTypeConstraints (void) const { + virtual std::string GetUnderlyingTypeInformation (void) const { std::ostringstream oss; - oss << m_minValue << ":" << m_maxValue; + oss << m_name << " " << m_minValue << ":" << m_maxValue; return oss.str (); } virtual Ptr Create (void) const { diff --git a/src/core/double.h b/src/core/double.h index 4dfd20c30..60de64150 100644 --- a/src/core/double.h +++ b/src/core/double.h @@ -27,7 +27,7 @@ namespace ns3 { /** - * \class DoubleValue + * \class ns3::DoubleValue * \brief Hold an floating point type * * \anchor double diff --git a/src/core/enum.cc b/src/core/enum.cc index b2c090fd4..58cc9fcc8 100644 --- a/src/core/enum.cc +++ b/src/core/enum.cc @@ -109,17 +109,17 @@ EnumChecker::Check (const AttributeValue &value) const return false; } std::string -EnumChecker::GetType (void) const +EnumChecker::GetValueTypeName (void) const { - return "EnumValue"; + return "ns3::EnumValue"; } bool -EnumChecker::HasTypeConstraints (void) const +EnumChecker::HasUnderlyingTypeInformation (void) const { return true; } std::string -EnumChecker::GetTypeConstraints (void) const +EnumChecker::GetUnderlyingTypeInformation (void) const { std::ostringstream oss; for (ValueSet::const_iterator i = m_valueSet.begin (); i != m_valueSet.end ();) diff --git a/src/core/enum.h b/src/core/enum.h index ade511d41..4cea3134a 100644 --- a/src/core/enum.h +++ b/src/core/enum.h @@ -57,9 +57,9 @@ public: void Add (int v, std::string name); virtual bool Check (const AttributeValue &value) const; - virtual std::string GetType (void) const; - virtual bool HasTypeConstraints (void) const; - virtual std::string GetTypeConstraints (void) const; + virtual std::string GetValueTypeName (void) const; + virtual bool HasUnderlyingTypeInformation (void) const; + virtual std::string GetUnderlyingTypeInformation (void) const; virtual Ptr Create (void) const; virtual bool Copy (const AttributeValue &src, AttributeValue &dst) const; diff --git a/src/core/integer.cc b/src/core/integer.cc index f783d22cc..d78a9eda9 100644 --- a/src/core/integer.cc +++ b/src/core/integer.cc @@ -44,15 +44,15 @@ MakeIntegerChecker (int64_t min, int64_t max, std::string name) } return v->Get () >= m_minValue && v->Get () <= m_maxValue; } - virtual std::string GetType (void) const { - return m_name; + virtual std::string GetValueTypeName (void) const { + return "ns3::IntegerValue"; } - virtual bool HasTypeConstraints (void) const { + virtual bool HasUnderlyingTypeInformation (void) const { return true; } - virtual std::string GetTypeConstraints (void) const { + virtual std::string GetUnderlyingTypeInformation (void) const { std::ostringstream oss; - oss << m_minValue << ":" << m_maxValue; + oss << m_name << " " << m_minValue << ":" << m_maxValue; return oss.str (); } virtual Ptr Create (void) const { diff --git a/src/core/integer.h b/src/core/integer.h index 0249d1501..ea7a20c0e 100644 --- a/src/core/integer.h +++ b/src/core/integer.h @@ -27,7 +27,7 @@ namespace ns3 { /** - * \class IntegerValue + * \class ns3::IntegerValue * \brief Hold a signed integer type * * \anchor int8_t diff --git a/src/core/object-factory.h b/src/core/object-factory.h index 0e5a5685c..ccfdc4177 100644 --- a/src/core/object-factory.h +++ b/src/core/object-factory.h @@ -89,6 +89,11 @@ private: std::ostream & operator << (std::ostream &os, const ObjectFactory &factory); std::istream & operator >> (std::istream &is, ObjectFactory &factory); +/** + * \class ns3::ObjectFactoryValue + * \brief hold objects of type ns3::ObjectFactory + */ + ATTRIBUTE_HELPER_HEADER_2 (ObjectFactory); } // namespace ns3 diff --git a/src/core/object-vector.h b/src/core/object-vector.h index 18cd826d0..934f0c010 100644 --- a/src/core/object-vector.h +++ b/src/core/object-vector.h @@ -87,13 +87,13 @@ public: virtual bool Check (const AttributeValue &value) const { return dynamic_cast (&value) != 0; } - virtual std::string GetType (void) const { + virtual std::string GetValueTypeName (void) const { return "ns3::ObjectVectorValue"; } - virtual bool HasTypeConstraints (void) const { + virtual bool HasUnderlyingTypeInformation (void) const { return true; } - virtual std::string GetTypeConstraints (void) const { + virtual std::string GetUnderlyingTypeInformation (void) const { return T::GetTypeId ().GetName (); } virtual Ptr Create (void) const { diff --git a/src/core/pointer.h b/src/core/pointer.h index bd9ad713e..b880606ad 100644 --- a/src/core/pointer.h +++ b/src/core/pointer.h @@ -25,6 +25,9 @@ namespace ns3 { +/** + * \brief hold objects of type Ptr + */ class PointerValue : public AttributeValue { public: @@ -109,17 +112,16 @@ class APointerChecker : public PointerChecker } return true; } - virtual std::string GetType (void) const { - // XXX: we should be able to return better information + virtual std::string GetValueTypeName (void) const { + return "ns3::PointerValue"; + } + virtual bool HasUnderlyingTypeInformation (void) const { + return true; + } + virtual std::string GetUnderlyingTypeInformation (void) const { TypeId tid = T::GetTypeId (); return "Ptr< " + tid.GetName () + " >"; } - virtual bool HasTypeConstraints (void) const { - return false; - } - virtual std::string GetTypeConstraints (void) const { - return ""; - } virtual Ptr Create (void) const { return ns3::Create (); } diff --git a/src/core/random-variable.h b/src/core/random-variable.h index 470759b1f..4abb36bdb 100644 --- a/src/core/random-variable.h +++ b/src/core/random-variable.h @@ -662,6 +662,11 @@ public: std::ostream &operator << (std::ostream &os, const RandomVariable &var); std::istream &operator >> (std::istream &os, RandomVariable &var); +/** + * \class ns3::RandomVariableValue + * \brief hold objects of type ns3::RandomVariable + */ + ATTRIBUTE_VALUE_DEFINE (RandomVariable); ATTRIBUTE_CHECKER_DEFINE (RandomVariable); ATTRIBUTE_ACCESSOR_DEFINE (RandomVariable); diff --git a/src/core/string.cc b/src/core/string.cc index 95a0d0103..fbd70e2be 100644 --- a/src/core/string.cc +++ b/src/core/string.cc @@ -2,7 +2,7 @@ namespace ns3 { -ATTRIBUTE_CHECKER_IMPLEMENT (String); +ATTRIBUTE_CHECKER_IMPLEMENT_WITH_NAME (String, "std::string"); ATTRIBUTE_CONVERTER_IMPLEMENT (String); ATTRIBUTE_VALUE_IMPLEMENT_WITH_NAME (std::string, String); diff --git a/src/core/string.h b/src/core/string.h index 0da1c81d2..65d21590f 100644 --- a/src/core/string.h +++ b/src/core/string.h @@ -7,7 +7,7 @@ namespace ns3 { /** - * \class StringValue + * \class ns3::StringValue * \brief hold variables of type string * * This class can be used to hold variables of type string, diff --git a/src/core/type-id.h b/src/core/type-id.h index c71527f2f..56ef2de94 100644 --- a/src/core/type-id.h +++ b/src/core/type-id.h @@ -380,6 +380,11 @@ bool operator == (TypeId a, TypeId b); bool operator != (TypeId a, TypeId b); bool operator < (TypeId a, TypeId b); +/** + * \class ns3::TypeIdValue + * \brief hold objects of type ns3::TypeId + */ + ATTRIBUTE_HELPER_HEADER_2 (TypeId); diff --git a/src/core/uinteger.cc b/src/core/uinteger.cc index 609562cc9..fd43ca990 100644 --- a/src/core/uinteger.cc +++ b/src/core/uinteger.cc @@ -43,15 +43,15 @@ Ptr MakeUintegerChecker (uint64_t min, uint64_t max, std } return v->Get () >= m_minValue && v->Get () <= m_maxValue; } - virtual std::string GetType (void) const { - return m_name; + virtual std::string GetValueTypeName (void) const { + return "ns3::UintegerValue"; } - virtual bool HasTypeConstraints (void) const { + virtual bool HasUnderlyingTypeInformation (void) const { return true; } - virtual std::string GetTypeConstraints (void) const { + virtual std::string GetUnderlyingTypeInformation (void) const { std::ostringstream oss; - oss << m_minValue << ":" << m_maxValue; + oss << m_name << " " << m_minValue << ":" << m_maxValue; return oss.str (); } virtual Ptr Create (void) const { diff --git a/src/devices/wifi/ssid.h b/src/devices/wifi/ssid.h index f149170c6..0feed168b 100644 --- a/src/devices/wifi/ssid.h +++ b/src/devices/wifi/ssid.h @@ -58,6 +58,11 @@ private: std::ostream &operator << (std::ostream &os, const Ssid &ssid); std::istream &operator >> (std::istream &is, Ssid &ssid); +/** + * \class ns3::SsidValue + * \brief hold objects of type ns3::Ssid + */ + ATTRIBUTE_HELPER_HEADER_2 (Ssid); } // namespace ns3 diff --git a/src/devices/wifi/wifi-mode.h b/src/devices/wifi/wifi-mode.h index c2ec75cc6..9b15a203e 100644 --- a/src/devices/wifi/wifi-mode.h +++ b/src/devices/wifi/wifi-mode.h @@ -118,6 +118,11 @@ bool operator == (const WifiMode &a, const WifiMode &b); std::ostream & operator << (std::ostream & os, const WifiMode &mode); std::istream & operator >> (std::istream &is, WifiMode &mode); +/** + * \class ns3::WifiModeValue + * \brief hold objects of type ns3::WifiMode + */ + ATTRIBUTE_HELPER_HEADER_2 (WifiMode); /** diff --git a/src/mobility/rectangle.h b/src/mobility/rectangle.h index 024339715..3777ee1a6 100644 --- a/src/mobility/rectangle.h +++ b/src/mobility/rectangle.h @@ -68,6 +68,11 @@ public: std::ostream &operator << (std::ostream &os, const Rectangle &rectangle); std::istream &operator >> (std::istream &is, Rectangle &rectangle); +/** + * \class ns3::RectangleValue + * \brief hold objects of type ns3::Rectangle + */ + ATTRIBUTE_HELPER_HEADER_2 (Rectangle); } // namespace ns3 diff --git a/src/mobility/vector.h b/src/mobility/vector.h index 7d97689b3..3517f7d36 100644 --- a/src/mobility/vector.h +++ b/src/mobility/vector.h @@ -63,6 +63,11 @@ public: double CalculateDistance (const Vector &a, const Vector &b); +/** + * \class ns3::VectorValue + * \brief hold objects of type ns3::Vector + */ + ATTRIBUTE_HELPER_HEADER_2 (Vector); std::ostream &operator << (std::ostream &os, const Vector &vector); diff --git a/src/node/address.h b/src/node/address.h index aaf2fc6c1..e5b6c82e3 100644 --- a/src/node/address.h +++ b/src/node/address.h @@ -166,6 +166,11 @@ private: uint8_t m_data[MAX_SIZE]; }; +/** + * \class ns3::AddressValue + * \brief hold objects of type ns3::Address + */ + ATTRIBUTE_HELPER_HEADER_2 (Address); bool operator == (const Address &a, const Address &b); diff --git a/src/node/ipv4-address.h b/src/node/ipv4-address.h index 669f8904a..fc2dc7fe7 100644 --- a/src/node/ipv4-address.h +++ b/src/node/ipv4-address.h @@ -185,6 +185,15 @@ private: uint32_t m_mask; }; +/** + * \class ns3::Ipv4AddressValue + * \brief hold objects of type ns3::Ipv4Address + */ +/** + * \class ns3::Ipv4MaskValue + * \brief hold objects of type ns3::Ipv4Mask + */ + ATTRIBUTE_HELPER_HEADER_2 (Ipv4Address); ATTRIBUTE_HELPER_HEADER_2 (Ipv4Mask); diff --git a/src/node/mac48-address.h b/src/node/mac48-address.h index 8e11b739b..6227e2e1b 100644 --- a/src/node/mac48-address.h +++ b/src/node/mac48-address.h @@ -112,6 +112,11 @@ private: uint8_t m_address[6]; }; +/** + * \class ns3::Mac48AddressValue + * \brief hold objects of type ns3::Mac48Address + */ + ATTRIBUTE_HELPER_HEADER_2 (Mac48Address); bool operator == (const Mac48Address &a, const Mac48Address &b); diff --git a/src/simulator/nstime.h b/src/simulator/nstime.h index 92c7d43d8..a163599b7 100644 --- a/src/simulator/nstime.h +++ b/src/simulator/nstime.h @@ -667,6 +667,12 @@ typedef TimeUnit<0> Scalar; typedef TimeUnit<-1> TimeInvert; typedef TimeUnit<2> TimeSquare; +/** + * \class ns3::TimeValue + * \brief hold objects of type ns3::Time + */ + + ATTRIBUTE_ACCESSOR_DEFINE (Time); ATTRIBUTE_VALUE_DEFINE (Time); ATTRIBUTE_CHECKER_DEFINE (Time); diff --git a/utils/print-introspected-doxygen.cc b/utils/print-introspected-doxygen.cc index f0383e1c0..10877461c 100644 --- a/utils/print-introspected-doxygen.cc +++ b/utils/print-introspected-doxygen.cc @@ -19,12 +19,12 @@ PrintAttributes (TypeId tid, std::ostream &os) os << "
  • " << tid.GetAttributeName (j) << ": " << tid.GetAttributeHelp (j) << std::endl; Ptr checker = tid.GetAttributeChecker (j); - os << "
      " << std::endl << "
    • Type: \\ref " << checker->GetType (); - if (checker->HasTypeConstraints ()) + os << "
        " << std::endl << "
      • Set with class: \\ref " + << checker->GetValueTypeName () << "
      • " << std::endl; + if (checker->HasUnderlyingTypeInformation ()) { - os << " -> " << checker->GetTypeConstraints (); + os << "
      • Underlying type: \\ref " << checker->GetUnderlyingTypeInformation () << "
      • " << std::endl; } - os << "" << std::endl; uint32_t flags = tid.GetAttributeFlags (j); Ptr accessor = tid.GetAttributeAccessor (j); os << "
      • Flags: ";