A Discrete-Event Network Simulator
API
ns3::EnumChecker Class Reference

AttributeChecker implementation for EnumValue. More...

#include "enum.h"

+ Inheritance diagram for ns3::EnumChecker:
+ Collaboration diagram for ns3::EnumChecker:

Public Member Functions

 EnumChecker ()
 
void Add (int value, std::string name)
 Add a new value. More...
 
void AddDefault (int value, std::string name)
 Add a default value. More...
 
virtual bool Check (const AttributeValue &value) const
 
virtual bool Copy (const AttributeValue &src, AttributeValue &dst) const
 Copy the source to the destination. More...
 
virtual Ptr< AttributeValueCreate (void) const
 
std::string GetName (int value) const
 Get the enum symbol name by value. More...
 
virtual std::string GetUnderlyingTypeInformation (void) const
 
int GetValue (const std::string name) const
 Get the enum value by name. More...
 
virtual std::string GetValueTypeName (void) const
 
virtual bool HasUnderlyingTypeInformation (void) const
 
- Public Member Functions inherited from ns3::AttributeChecker
 AttributeChecker ()
 
virtual ~AttributeChecker ()
 
Ptr< AttributeValueCreateValidValue (const AttributeValue &value) const
 Create a valid value from the argument value, or reinterpret the argument as a string. More...
 
- Public Member Functions inherited from ns3::SimpleRefCount< AttributeChecker >
 SimpleRefCount ()
 Default constructor. More...
 
 SimpleRefCount (const SimpleRefCount &o[[maybe_unused]])
 Copy constructor. More...
 
uint32_t GetReferenceCount (void) const
 Get the reference count of the object. More...
 
SimpleRefCountoperator= ([[maybe_unused]] const SimpleRefCount &o)
 Assignment operator. More...
 
void Ref (void) const
 Increment the reference count. More...
 
void Unref (void) const
 Decrement the reference count. More...
 

Private Types

typedef std::pair< int, std::string > Value
 Type for the pair value, name. More...
 
typedef std::list< ValueValueSet
 Type of container for storing Enum values and symbol names. More...
 

Private Attributes

ValueSet m_valueSet
 The stored Enum values and symbol names. More...
 

Detailed Description

AttributeChecker implementation for EnumValue.

See also
AttributeChecker

Definition at line 85 of file enum.h.

Member Typedef Documentation

◆ Value

typedef std::pair<int,std::string> ns3::EnumChecker::Value
private

Type for the pair value, name.

Definition at line 127 of file enum.h.

◆ ValueSet

Type of container for storing Enum values and symbol names.

Definition at line 129 of file enum.h.

Constructor & Destructor Documentation

◆ EnumChecker()

ns3::EnumChecker::EnumChecker ( )

Definition at line 84 of file enum.cc.

References NS_LOG_FUNCTION.

Member Function Documentation

◆ Add()

void ns3::EnumChecker::Add ( int  value,
std::string  name 
)

Add a new value.

Parameters
[in]valueThe value.
[in]nameThe enum symbol name.

Definition at line 96 of file enum.cc.

References m_valueSet, and NS_LOG_FUNCTION.

◆ AddDefault()

void ns3::EnumChecker::AddDefault ( int  value,
std::string  name 
)

Add a default value.

Parameters
[in]valueThe value.
[in]nameThen enum symbol name.

Definition at line 90 of file enum.cc.

References m_valueSet, and NS_LOG_FUNCTION.

◆ Check()

bool ns3::EnumChecker::Check ( const AttributeValue value) const
virtual
Parameters
[in]valueA pointer to the value to check
Returns
true if the input value is both of the right type and if its value is within the requested range. Returns false otherwise.

Implements ns3::AttributeChecker.

Definition at line 130 of file enum.cc.

References ns3::EnumValue::Get(), and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

◆ Copy()

bool ns3::EnumChecker::Copy ( const AttributeValue source,
AttributeValue destination 
) const
virtual

Copy the source to the destination.

Parameters
[in]sourceSource AttributeValue
[out]destinationDestination AttributeValue
Returns
true if copy was successful

Implements ns3::AttributeChecker.

Definition at line 176 of file enum.cc.

References NS_LOG_FUNCTION.

◆ Create()

Ptr< AttributeValue > ns3::EnumChecker::Create ( void  ) const
virtual
Returns
a new instance of an AttributeValue (wrapper in an Attribute instance) which matches the type of the underlying attribute.

This method is typically used to create a temporary variable prior to calling Attribute::DeserializeFromString.

Implements ns3::AttributeChecker.

Definition at line 169 of file enum.cc.

References NS_LOG_FUNCTION.

◆ GetName()

std::string ns3::EnumChecker::GetName ( int  value) const

Get the enum symbol name by value.

Parameters
[in]valueThe value.
Returns
The enum symbol name.

Definition at line 102 of file enum.cc.

References m_valueSet, and NS_ASSERT_MSG.

Referenced by ns3::EnumValue::SerializeToString().

+ Here is the caller graph for this function:

◆ GetUnderlyingTypeInformation()

std::string ns3::EnumChecker::GetUnderlyingTypeInformation ( void  ) const
virtual
Returns
a human-readable representation of information about the underlying C++ type.

Implements ns3::AttributeChecker.

Definition at line 156 of file enum.cc.

References NS_LOG_FUNCTION.

◆ GetValue()

int ns3::EnumChecker::GetValue ( const std::string  name) const

Get the enum value by name.

Parameters
[in]nameThen enum symbol name.
Returns
The enum value.

Definition at line 111 of file enum.cc.

References m_valueSet, and NS_ASSERT_MSG.

Referenced by ns3::EnumValue::DeserializeFromString().

+ Here is the caller graph for this function:

◆ GetValueTypeName()

std::string ns3::EnumChecker::GetValueTypeName ( void  ) const
virtual
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.

Implements ns3::AttributeChecker.

Definition at line 144 of file enum.cc.

References NS_LOG_FUNCTION.

◆ HasUnderlyingTypeInformation()

bool ns3::EnumChecker::HasUnderlyingTypeInformation ( void  ) const
virtual
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.

Implements ns3::AttributeChecker.

Definition at line 150 of file enum.cc.

References NS_LOG_FUNCTION.

Member Data Documentation

◆ m_valueSet

ValueSet ns3::EnumChecker::m_valueSet
private

The stored Enum values and symbol names.

Definition at line 131 of file enum.h.

Referenced by Add(), AddDefault(), GetName(), and GetValue().


The documentation for this class was generated from the following files: