19 #include "ns3/core-module.h"
55 static TypeId GetTypeId (
void);
71 FormattingTestObject::GetTypeId (
void)
75 .AddConstructor<FormattingTestObject> ()
76 .AddAttribute (
"OnTime",
"A RandomVariableStream used to pick the duration of the 'On' state.",
77 StringValue (
"ns3::ConstantRandomVariable[Constant=1.0]"),
79 MakePointerChecker <RandomVariableStream>())
84 FormattingTestObject::FormattingTestObject ()
88 FormattingTestObject::GetTestVariable (
void)
const
90 return m_testVariable;
108 void SetAttribute (std::string name,
const AttributeValue &value);
119 FormattingTestObjectHelper::FormattingTestObjectHelper ()
121 m_factory.
SetTypeId (FormattingTestObject::GetTypeId ());
125 FormattingTestObjectHelper::SetAttribute (std::string name,
const AttributeValue &value)
127 m_factory.Set (name, value);
131 FormattingTestObjectHelper::CreateFromFactory (
void)
133 return m_factory.Create ();
140 main (
int argc,
char *argv[])
144 obj->SetAttribute (
"OnTime",
StringValue (
"ns3::UniformRandomVariable"));
145 obj->SetAttribute (
"OnTime",
StringValue (
"ns3::UniformRandomVariable[Min=0.]"));
146 obj->SetAttribute (
"OnTime",
StringValue (
"ns3::UniformRandomVariable[Min=0.|Max=1.]"));
147 obj->SetAttribute (
"OnTime",
StringValue (
"ns3::UniformRandomVariable[Min=50.|Max=100.]"));
177 FormattingTestObjectHelper formattingHelper;
178 formattingHelper.SetAttribute (
"OnTime",
StringValue (
"ns3::UniformRandomVariable[Min=30.|Max=60.0]"));
191 Ptr<Object> outputObj = formattingHelper.CreateFromFactory ();
194 rvStream = fto->GetTestVariable ();
Hold a value for an Attribute.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
void GetAttribute(std::string name, AttributeValue &value) const
Get the value of an attribute, raising fatal errors if unsuccessful.
Instantiate subclasses of ns3::Object.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
A base class which provides memory management and object aggregation.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Hold variables of type string.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
#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...
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Every class exported by the ns3 library is enclosed in the ns3 namespace.