A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Attribute Helper

All these macros can be used to generate automatically the code for subclasses of AttributeValue, AttributeAccessor, and, AttributeChecker, which can be used to give attribute powers to a normal class. More...

+ Collaboration diagram for Attribute Helper:

Macros

#define ATTRIBUTE_ACCESSOR_DEFINE(type)
 
#define ATTRIBUTE_CHECKER_DEFINE(type)
 
#define ATTRIBUTE_CHECKER_IMPLEMENT(type)
 
#define ATTRIBUTE_CHECKER_IMPLEMENT_WITH_NAME(type, name)
 
#define ATTRIBUTE_CONVERTER_DEFINE(type)
 
#define ATTRIBUTE_HELPER_CPP(type)
 
#define ATTRIBUTE_HELPER_HEADER(type)
 
#define ATTRIBUTE_VALUE_DEFINE(type)   ATTRIBUTE_VALUE_DEFINE_WITH_NAME (type,type)
 
#define ATTRIBUTE_VALUE_DEFINE_WITH_NAME(type, name)
 
#define ATTRIBUTE_VALUE_IMPLEMENT(type)   ATTRIBUTE_VALUE_IMPLEMENT_WITH_NAME (type,type)
 
#define ATTRIBUTE_VALUE_IMPLEMENT_WITH_NAME(type, name)
 

Functions

template<typename T , typename BASE >
Ptr< AttributeChecker > ns3::MakeSimpleAttributeChecker (std::string name, std::string underlying)
 A simple string-based attribute checker. More...
 

Detailed Description

All these macros can be used to generate automatically the code for subclasses of AttributeValue, AttributeAccessor, and, AttributeChecker, which can be used to give attribute powers to a normal class.

i.e., the user class can then effectively be made an attribute.

There are two kinds of helper macros: 1) The simple macros.

The simple macros are implemented in terms of the complex macros and should generally be preferred over the complex macros.

Macro Definition Documentation

#define ATTRIBUTE_ACCESSOR_DEFINE (   type)
Value:
template <typename T1> \
Ptr<const AttributeAccessor> Make ## type ## Accessor (T1 a1) \
{ \
return MakeAccessorHelper<type ## Value> (a1); \
} \
template <typename T1, typename T2> \
Ptr<const AttributeAccessor> Make ## type ## Accessor (T1 a1, T2 a2) \
{ \
return MakeAccessorHelper<type ## Value> (a1, a2); \
}
Parameters
typethe name of the class

This macro defines and generates the code for the implementation of the Make<type>Accessor template functions. This macro is typically invoked in a class header to allow users of this class to view and use the template functions defined here. This macro is implemented through the helper templates functions ns3::MakeAccessorHelper<>.

Definition at line 109 of file attribute-helper.h.

#define ATTRIBUTE_CHECKER_DEFINE (   type)
Value:
class type ## Checker : public AttributeChecker {}; \
Ptr<const AttributeChecker> Make ## type ## Checker (void); \
Parameters
typethe name of the class

This macro defines the typeChecker class and the associated Make<type>Checker function. Typically invoked in the class header file..

Definition at line 175 of file attribute-helper.h.

#define ATTRIBUTE_CHECKER_IMPLEMENT (   type)
Value:
Ptr<const AttributeChecker> Make ## type ## Checker (void) \
{ \
return MakeSimpleAttributeChecker<type ## Value,type ## Checker> (# type "Value", # type); \
} \
Parameters
typethe name of the class

This macro implements the Make<type>Checker function. Typically invoked in the source file..

Definition at line 233 of file attribute-helper.h.

#define ATTRIBUTE_CHECKER_IMPLEMENT_WITH_NAME (   type,
  name 
)
Value:
Ptr<const AttributeChecker> Make ## type ## Checker (void) \
{ \
return MakeSimpleAttributeChecker<type ## Value,type ## Checker> (# type "Value", name); \
} \
Internal:

Definition at line 243 of file attribute-helper.h.

#define ATTRIBUTE_CONVERTER_DEFINE (   type)
Parameters
typethe name of the class

This macro defines the conversion operators for class type to and from instances of type Attribute. Typically invoked in the class header file.

Definition at line 165 of file attribute-helper.h.

#define ATTRIBUTE_HELPER_CPP (   type)
Value:
#define ATTRIBUTE_VALUE_IMPLEMENT(type)
#define ATTRIBUTE_CHECKER_IMPLEMENT(type)
Parameters
typethe name of the class

This macro should be invoked from the class implementation file.

Definition at line 267 of file attribute-helper.h.

#define ATTRIBUTE_HELPER_HEADER (   type)
Value:
#define ATTRIBUTE_VALUE_DEFINE(type)
#define ATTRIBUTE_CHECKER_DEFINE(type)
#define ATTRIBUTE_ACCESSOR_DEFINE(type)
Parameters
typethe name of the class

This macro should be invoked outside of the class declaration in its public header.

Definition at line 256 of file attribute-helper.h.

#define ATTRIBUTE_VALUE_DEFINE (   type)    ATTRIBUTE_VALUE_DEFINE_WITH_NAME (type,type)
Parameters
typethe name of the class.

This macro defines the class typeValue associated to class type. This macro is typically invoked in the class header file.

Definition at line 153 of file attribute-helper.h.

#define ATTRIBUTE_VALUE_DEFINE_WITH_NAME (   type,
  name 
)
Value:
class name ## Value : public AttributeValue \
{ \
public: \
name ## Value (); \
name ## Value (const type &value); \
void Set (const type &value); \
type Get (void) const; \
template <typename T> \
bool GetAccessor (T &value) const { \
value = T (m_value); \
return true; \
} \
virtual Ptr<AttributeValue> Copy (void) const; \
virtual std::string SerializeToString (Ptr<const AttributeChecker> checker) const; \
virtual bool DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker); \
type m_value; \
};
#define private
void Set(std::string path, const AttributeValue &value)
Definition: config.cc:662
Ptr< T > Copy(Ptr< T > object)
Definition: ptr.h:387
Internal:

Definition at line 125 of file attribute-helper.h.

#define ATTRIBUTE_VALUE_IMPLEMENT (   type)    ATTRIBUTE_VALUE_IMPLEMENT_WITH_NAME (type,type)
Parameters
typethe name of the class.

This macro implements the typeValue class (including the typeValue::SerializeToString and typeValue::DeserializeFromString methods). Typically invoked in the source file.

Definition at line 222 of file attribute-helper.h.

#define ATTRIBUTE_VALUE_IMPLEMENT_WITH_NAME (   type,
  name 
)
Value:
name ## Value::name ## Value () \
: m_value () {} \
name ## Value::name ## Value (const type &value) \
: m_value (value) {} \
void name ## Value::Set (const type &v) { \
m_value = v; \
} \
type name ## Value::Get (void) const { \
return m_value; \
} \
Ptr<AttributeValue> \
name ## Value::Copy (void) const { \
return ns3::Create<name ## Value> (*this); \
} \
std::string \
name ## Value::SerializeToString (Ptr<const AttributeChecker> checker) const { \
std::ostringstream oss; \
oss << m_value; \
return oss.str (); \
} \
bool \
name ## Value::DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker) { \
std::istringstream iss; \
iss.str (value); \
iss >> m_value; \
return !iss.bad () && !iss.fail (); \
}
void Set(std::string path, const AttributeValue &value)
Definition: config.cc:662
Ptr< T > Copy(Ptr< T > object)
Definition: ptr.h:387
Internal:

Definition at line 184 of file attribute-helper.h.

Function Documentation

template<typename T , typename BASE >
Ptr<AttributeChecker> ns3::MakeSimpleAttributeChecker ( std::string  name,
std::string  underlying 
)

A simple string-based attribute checker.

Parameters
namevalue type of the attribute
underlyingunderlying type name
Returns
Ptr to AttributeChecker

Definition at line 60 of file attribute-helper.h.

References ns3::Copy(), and ns3::Create().

+ Here is the call graph for this function: