src/core/object-factory.h
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Tue, 26 Feb 2008 22:39:57 +0100
changeset 2488 c35c4f282206
parent 2483 a6097b0414b3
child 2502 50d0da37f02f
permissions -rw-r--r--
add an extra overload of SetTypeId to avoid overload resolution confusions.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2395
ffd1c96afe4b a pretty simple wrapper around TypeId+Parameters: ObjectFactory
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     1
#ifndef OBJECT_FACTORY_H
ffd1c96afe4b a pretty simple wrapper around TypeId+Parameters: ObjectFactory
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     2
#define OBJECT_FACTORY_H
ffd1c96afe4b a pretty simple wrapper around TypeId+Parameters: ObjectFactory
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     3
2438
e2ac9f9aeeb9 value.h -> attribute.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2433
diff changeset
     4
#include "attribute.h"
2395
ffd1c96afe4b a pretty simple wrapper around TypeId+Parameters: ObjectFactory
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     5
#include "object.h"
ffd1c96afe4b a pretty simple wrapper around TypeId+Parameters: ObjectFactory
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     6
ffd1c96afe4b a pretty simple wrapper around TypeId+Parameters: ObjectFactory
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     7
namespace ns3 {
ffd1c96afe4b a pretty simple wrapper around TypeId+Parameters: ObjectFactory
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     8
ffd1c96afe4b a pretty simple wrapper around TypeId+Parameters: ObjectFactory
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     9
class ObjectFactory
ffd1c96afe4b a pretty simple wrapper around TypeId+Parameters: ObjectFactory
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    10
{
ffd1c96afe4b a pretty simple wrapper around TypeId+Parameters: ObjectFactory
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    11
public:
ffd1c96afe4b a pretty simple wrapper around TypeId+Parameters: ObjectFactory
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    12
  ObjectFactory ();
ffd1c96afe4b a pretty simple wrapper around TypeId+Parameters: ObjectFactory
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    13
ffd1c96afe4b a pretty simple wrapper around TypeId+Parameters: ObjectFactory
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    14
  void SetTypeId (TypeId tid);
ffd1c96afe4b a pretty simple wrapper around TypeId+Parameters: ObjectFactory
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    15
  void SetTypeId (std::string tid);
2488
c35c4f282206 add an extra overload of SetTypeId to avoid overload resolution confusions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2483
diff changeset
    16
  void SetTypeId (const char *tid);
2433
3a98e1db7f80 PValue -> Attribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2395
diff changeset
    17
  void Set (std::string name, Attribute value);
2395
ffd1c96afe4b a pretty simple wrapper around TypeId+Parameters: ObjectFactory
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    18
  void Set (std::string name, std::string value);
ffd1c96afe4b a pretty simple wrapper around TypeId+Parameters: ObjectFactory
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    19
ffd1c96afe4b a pretty simple wrapper around TypeId+Parameters: ObjectFactory
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    20
  TypeId GetTypeId (void) const;
ffd1c96afe4b a pretty simple wrapper around TypeId+Parameters: ObjectFactory
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    21
ffd1c96afe4b a pretty simple wrapper around TypeId+Parameters: ObjectFactory
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    22
  Ptr<Object> Create (void) const;
2483
a6097b0414b3 add templated version of ObjectFactory::Create
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2459
diff changeset
    23
  template <typename T>
a6097b0414b3 add templated version of ObjectFactory::Create
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2459
diff changeset
    24
  Ptr<T> Create (void) const;
2395
ffd1c96afe4b a pretty simple wrapper around TypeId+Parameters: ObjectFactory
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    25
ffd1c96afe4b a pretty simple wrapper around TypeId+Parameters: ObjectFactory
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    26
private:
ffd1c96afe4b a pretty simple wrapper around TypeId+Parameters: ObjectFactory
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    27
  TypeId m_tid;
2459
91662d921a83 Attributes -> AttributeList
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2458
diff changeset
    28
  AttributeList m_parameters;
2395
ffd1c96afe4b a pretty simple wrapper around TypeId+Parameters: ObjectFactory
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    29
};
ffd1c96afe4b a pretty simple wrapper around TypeId+Parameters: ObjectFactory
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    30
ffd1c96afe4b a pretty simple wrapper around TypeId+Parameters: ObjectFactory
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    31
} // namespace ns3
ffd1c96afe4b a pretty simple wrapper around TypeId+Parameters: ObjectFactory
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    32
2483
a6097b0414b3 add templated version of ObjectFactory::Create
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2459
diff changeset
    33
namespace ns3 {
a6097b0414b3 add templated version of ObjectFactory::Create
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2459
diff changeset
    34
a6097b0414b3 add templated version of ObjectFactory::Create
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2459
diff changeset
    35
template <typename T>
a6097b0414b3 add templated version of ObjectFactory::Create
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2459
diff changeset
    36
Ptr<T> 
a6097b0414b3 add templated version of ObjectFactory::Create
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2459
diff changeset
    37
ObjectFactory::Create (void) const
a6097b0414b3 add templated version of ObjectFactory::Create
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2459
diff changeset
    38
{
a6097b0414b3 add templated version of ObjectFactory::Create
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2459
diff changeset
    39
  return Create ()->GetObject<T> ();
a6097b0414b3 add templated version of ObjectFactory::Create
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2459
diff changeset
    40
}
a6097b0414b3 add templated version of ObjectFactory::Create
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2459
diff changeset
    41
a6097b0414b3 add templated version of ObjectFactory::Create
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2459
diff changeset
    42
} // namespace ns3
a6097b0414b3 add templated version of ObjectFactory::Create
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2459
diff changeset
    43
2395
ffd1c96afe4b a pretty simple wrapper around TypeId+Parameters: ObjectFactory
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    44
#endif /* OBJECT_FACTORY_H */