src/core/object-factory.h
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Mon, 10 Mar 2008 00:46:44 +0100
changeset 2582 3e28107b870f
parent 2555 469bcb4d0010
child 2583 c09faa6c90bf
permissions -rw-r--r--
rename old VALUE leftovers
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
ffd1c96afe4b a pretty simple wrapper around TypeId+Parameters: ObjectFactory
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    19
  TypeId GetTypeId (void) const;
ffd1c96afe4b a pretty simple wrapper around TypeId+Parameters: ObjectFactory
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    20
ffd1c96afe4b a pretty simple wrapper around TypeId+Parameters: ObjectFactory
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    21
  Ptr<Object> Create (void) const;
2483
a6097b0414b3 add templated version of ObjectFactory::Create
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2459
diff changeset
    22
  template <typename T>
a6097b0414b3 add templated version of ObjectFactory::Create
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2459
diff changeset
    23
  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
    24
2582
3e28107b870f rename old VALUE leftovers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2555
diff changeset
    25
  ATTRIBUTE_HELPER_HEADER_1 (ObjectFactory);
2395
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
2555
469bcb4d0010 give Attribute power to ObjectFactory class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2507
diff changeset
    31
std::ostream & operator << (std::ostream &os, const ObjectFactory &factory);
469bcb4d0010 give Attribute power to ObjectFactory class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2507
diff changeset
    32
std::istream & operator >> (std::istream &is, ObjectFactory &factory);
469bcb4d0010 give Attribute power to ObjectFactory class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2507
diff changeset
    33
2582
3e28107b870f rename old VALUE leftovers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2555
diff changeset
    34
ATTRIBUTE_HELPER_HEADER_2 (ObjectFactory);
2555
469bcb4d0010 give Attribute power to ObjectFactory class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2507
diff changeset
    35
2395
ffd1c96afe4b a pretty simple wrapper around TypeId+Parameters: ObjectFactory
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    36
} // namespace ns3
ffd1c96afe4b a pretty simple wrapper around TypeId+Parameters: ObjectFactory
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    37
2483
a6097b0414b3 add templated version of ObjectFactory::Create
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2459
diff changeset
    38
namespace ns3 {
a6097b0414b3 add templated version of ObjectFactory::Create
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2459
diff changeset
    39
a6097b0414b3 add templated version of ObjectFactory::Create
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2459
diff changeset
    40
template <typename T>
a6097b0414b3 add templated version of ObjectFactory::Create
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2459
diff changeset
    41
Ptr<T> 
a6097b0414b3 add templated version of ObjectFactory::Create
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2459
diff changeset
    42
ObjectFactory::Create (void) const
a6097b0414b3 add templated version of ObjectFactory::Create
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2459
diff changeset
    43
{
2507
092b9687568d Use a temporary to avoid confusing the compiler.
Mathieu Lacage <Mathieu.Lacage@sophia.inria.fr>
parents: 2502
diff changeset
    44
  Ptr<Object> object = Create ();
092b9687568d Use a temporary to avoid confusing the compiler.
Mathieu Lacage <Mathieu.Lacage@sophia.inria.fr>
parents: 2502
diff changeset
    45
  return object->GetObject<T> ();
2483
a6097b0414b3 add templated version of ObjectFactory::Create
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2459
diff changeset
    46
}
a6097b0414b3 add templated version of ObjectFactory::Create
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2459
diff changeset
    47
a6097b0414b3 add templated version of ObjectFactory::Create
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2459
diff changeset
    48
} // namespace ns3
a6097b0414b3 add templated version of ObjectFactory::Create
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2459
diff changeset
    49
2395
ffd1c96afe4b a pretty simple wrapper around TypeId+Parameters: ObjectFactory
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    50
#endif /* OBJECT_FACTORY_H */