87 "ObjectFactory::Create - can't use an ObjectFactory without setting a TypeId first.");
90 auto derived =
dynamic_cast<Object*
>(base);
92 derived->SetTypeId(
m_tid);
105 os << i->name <<
"=" << i->value->SerializeToString(i->checker);
120 std::string::size_type lbracket;
121 std::string::size_type rbracket;
122 lbracket = v.find(
'[');
123 rbracket = v.find(
']');
124 if (lbracket == std::string::npos && rbracket == std::string::npos)
129 if (lbracket == std::string::npos || rbracket == std::string::npos)
133 NS_ASSERT(lbracket != std::string::npos);
134 NS_ASSERT(rbracket != std::string::npos);
135 std::string tid = v.substr(0, lbracket);
136 std::string parameters = v.substr(lbracket + 1, rbracket - (lbracket + 1));
138 std::string::size_type cur;
140 while (cur != parameters.size())
142 std::string::size_type equal = parameters.find(
'=', cur);
143 if (equal == std::string::npos)
145 is.setstate(std::ios_base::failbit);
150 std::string name = parameters.substr(cur, equal - cur);
154 is.setstate(std::ios_base::failbit);
159 std::string::size_type next = parameters.find(
'|', cur);
161 if (next == std::string::npos)
163 value = parameters.substr(equal + 1, parameters.size() - (equal + 1));
164 cur = parameters.size();
168 value = parameters.substr(equal + 1, next - (equal + 1));
172 bool ok = val->DeserializeFromString(value, info.
checker);
175 is.setstate(std::ios_base::failbit);
void Add(std::string name, Ptr< const AttributeChecker > checker, Ptr< AttributeValue > value)
Add an Attribute to the list.
Hold a value for an Attribute.
Anchor the ns-3 type and attribute system.
Instantiate subclasses of ns3::Object.
Ptr< Object > Create() const
Create an Object instance of the configured TypeId.
TypeId GetTypeId() const
Get the TypeId which will be created by this ObjectFactory.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
TypeId m_tid
The TypeId this factory will create.
ObjectFactory()
Default constructor.
void DoSet(const std::string &name, const AttributeValue &value)
Set an attribute to be set during construction.
AttributeConstructionList m_parameters
The list of attributes and values to be used in constructing objects by this factory.
bool IsTypeIdSet() const
Check if the ObjectFactory has been configured with a TypeId.
A base class which provides memory management and object aggregation.
Smart pointer class similar to boost::intrusive_ptr.
a unique identifier for an interface.
static TypeId LookupByName(std::string name)
Get a TypeId by name.
Callback< ObjectBase * > GetConstructor() const
Get the constructor callback.
uint16_t GetUid() const
Get the internal id of this TypeId.
bool LookupAttributeByName(std::string name, AttributeInformation *info, bool permissive=false) const
Find an Attribute by name, retrieving the associated AttributeInformation.
std::string GetName() const
Get the name.
#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 ATTRIBUTE_HELPER_CPP(type)
Define the attribute value, accessor and checkers for class type
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
#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 ",...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::ostream & operator<<(std::ostream &os, const Angles &a)
std::istream & operator>>(std::istream &is, Angles &a)
ns3::ObjectFactory class declaration.