63 return ns3::Create<EnumValue> (*
this);
93 m_valueSet.push_front (std::make_pair (value, name));
99 m_valueSet.push_back (std::make_pair (value, name));
105 [value] (
Value v) { return v.first == value; } );
107 "invalid enum value " << value <<
"! Missed entry in MakeEnumChecker?");
114 [name] (
Value v) { return v.second == name; } );
116 "name " << name <<
" is not a valid enum value. Missed entry in MakeEnumChecker?\nAvailable values: " <<
124 return std::move (a) +
", " + v.second;
138 auto pvalue = p->
Get ();
139 auto it = std::find_if (m_valueSet.begin (), m_valueSet.end (),
140 [pvalue] (
Value v) { return v.first == pvalue; } );
141 return (it != m_valueSet.end ());
144 EnumChecker::GetValueTypeName (
void)
const
147 return "ns3::EnumValue";
150 EnumChecker::HasUnderlyingTypeInformation (
void)
const
156 EnumChecker::GetUnderlyingTypeInformation (
void)
const
159 std::ostringstream oss;
160 bool moreValues =
false;
161 for (
const auto &i : m_valueSet)
163 oss << (moreValues ?
"|" :
"") << i.second;
172 return ns3::Create<EnumValue> ();
181 if (src == 0 || dst == 0)
Hold a value for an Attribute.
AttributeChecker implementation for EnumValue.
void Add(int value, std::string name)
Add a new value.
ValueSet m_valueSet
The stored Enum values and symbol names.
int GetValue(const std::string name) const
Get the enum value by name.
std::pair< int, std::string > Value
Type for the pair value, name.
std::string GetName(int value) const
Get the enum symbol name by value.
void AddDefault(int value, std::string name)
Add a default value.
Hold variables of type enum.
void Set(int value)
Set the value.
virtual std::string SerializeToString(Ptr< const AttributeChecker > checker) const
virtual bool DeserializeFromString(std::string value, Ptr< const AttributeChecker > checker)
int m_value
The stored integer value.
virtual Ptr< AttributeValue > Copy(void) const
Smart pointer class similar to boost::intrusive_ptr.
ns3::EnumValue attribute value declarations.
NS_FATAL_x macro definitions.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
U * PeekPointer(const Ptr< U > &p)
Ptr< T > Copy(Ptr< T > object)
Return a deep copy of a Ptr.