src/core/object-factory.h
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Wed, 27 Feb 2008 21:41:34 +0100
changeset 2502 50d0da37f02f
parent 2488 c35c4f282206
child 2507 092b9687568d
permissions -rw-r--r--
introduce the ns3::String class, get rid of the string -> Attribute implicit conversion, and get rid of MakeDataRate, port PointToPointNetDevice to Attributes

#ifndef OBJECT_FACTORY_H
#define OBJECT_FACTORY_H

#include "attribute.h"
#include "object.h"

namespace ns3 {

class ObjectFactory
{
public:
  ObjectFactory ();

  void SetTypeId (TypeId tid);
  void SetTypeId (std::string tid);
  void SetTypeId (const char *tid);
  void Set (std::string name, Attribute value);

  TypeId GetTypeId (void) const;

  Ptr<Object> Create (void) const;
  template <typename T>
  Ptr<T> Create (void) const;

private:
  TypeId m_tid;
  AttributeList m_parameters;
};

} // namespace ns3

namespace ns3 {

template <typename T>
Ptr<T> 
ObjectFactory::Create (void) const
{
  return Create ()->GetObject<T> ();
}

} // namespace ns3

#endif /* OBJECT_FACTORY_H */