8#ifndef OBJECT_FACTORY_H
9#define OBJECT_FACTORY_H
56 template <
typename... Args>
87 template <
typename... Args>
120 template <
typename T>
178template <
typename T,
typename... Args>
197 auto obj =
object->GetObject<T>();
199 "ObjectFactory::Create error: incompatible types ("
200 << T::GetTypeId().GetName() <<
" and " <<
object->GetInstanceTypeId() <<
")");
204template <
typename... Args>
211template <
typename... Args>
219template <
typename T,
typename... Args>
225 factory.
Set(args...);
226 return factory.
Create<T>();
ns3::AttributeConstructionList declaration.
List of Attribute name, value and checker triples used to construct Objects.
Hold a value for an Attribute.
Instantiate subclasses of ns3::Object.
void Set()
Base case to stop the recursion performed by the templated version of this method.
Ptr< Object > Create() const
Create an Object instance of the configured TypeId.
friend std::ostream & operator<<(std::ostream &os, const ObjectFactory &factory)
Print the factory configuration on an output stream.
void Set(const std::string &name, const AttributeValue &value, Args &&... args)
Set an attribute to be set during construction.
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.
friend std::istream & operator>>(std::istream &is, ObjectFactory &factory)
Read a factory configuration from an input stream.
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.
Smart pointer class similar to boost::intrusive_ptr.
a unique identifier for an interface.
#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_HEADER(type)
Declare the attribute value, accessor and checkers for class type
Ptr< T > CreateObjectWithAttributes(Args... args)
Allocate an Object on the heap and initialize with a set of attributes.
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::Object class declaration, which is the root of the Object hierarchy and Aggregation.
ns3::TypeId declaration; inline and template implementations.