author | Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
Mon, 10 Mar 2008 14:52:08 -0700 | |
changeset 2586 | 50d78910a997 |
parent 2583 | c09faa6c90bf |
child 2631 | 365595f1f9a8 |
permissions | -rw-r--r-- |
2586
50d78910a997
add missing copyright/license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2583
diff
changeset
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
50d78910a997
add missing copyright/license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2583
diff
changeset
|
2 |
/* |
50d78910a997
add missing copyright/license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2583
diff
changeset
|
3 |
* Copyright (c) 2008 INRIA |
50d78910a997
add missing copyright/license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2583
diff
changeset
|
4 |
* |
50d78910a997
add missing copyright/license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2583
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
50d78910a997
add missing copyright/license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2583
diff
changeset
|
6 |
* it under the terms of the GNU General Public License version 2 as |
50d78910a997
add missing copyright/license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2583
diff
changeset
|
7 |
* published by the Free Software Foundation; |
50d78910a997
add missing copyright/license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2583
diff
changeset
|
8 |
* |
50d78910a997
add missing copyright/license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2583
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
50d78910a997
add missing copyright/license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2583
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
50d78910a997
add missing copyright/license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2583
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
50d78910a997
add missing copyright/license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2583
diff
changeset
|
12 |
* GNU General Public License for more details. |
50d78910a997
add missing copyright/license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2583
diff
changeset
|
13 |
* |
50d78910a997
add missing copyright/license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2583
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
50d78910a997
add missing copyright/license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2583
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
50d78910a997
add missing copyright/license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2583
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
50d78910a997
add missing copyright/license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2583
diff
changeset
|
17 |
* |
50d78910a997
add missing copyright/license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2583
diff
changeset
|
18 |
* Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
50d78910a997
add missing copyright/license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2583
diff
changeset
|
19 |
*/ |
2395
ffd1c96afe4b
a pretty simple wrapper around TypeId+Parameters: ObjectFactory
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
20 |
#include "object-factory.h" |
ffd1c96afe4b
a pretty simple wrapper around TypeId+Parameters: ObjectFactory
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
21 |
#include <sstream> |
ffd1c96afe4b
a pretty simple wrapper around TypeId+Parameters: ObjectFactory
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
22 |
|
ffd1c96afe4b
a pretty simple wrapper around TypeId+Parameters: ObjectFactory
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
23 |
namespace ns3 { |
ffd1c96afe4b
a pretty simple wrapper around TypeId+Parameters: ObjectFactory
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
24 |
|
ffd1c96afe4b
a pretty simple wrapper around TypeId+Parameters: ObjectFactory
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
25 |
ObjectFactory::ObjectFactory () |
ffd1c96afe4b
a pretty simple wrapper around TypeId+Parameters: ObjectFactory
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
26 |
{} |
ffd1c96afe4b
a pretty simple wrapper around TypeId+Parameters: ObjectFactory
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
27 |
|
ffd1c96afe4b
a pretty simple wrapper around TypeId+Parameters: ObjectFactory
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
28 |
void |
ffd1c96afe4b
a pretty simple wrapper around TypeId+Parameters: ObjectFactory
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
29 |
ObjectFactory::SetTypeId (TypeId tid) |
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 |
m_tid = tid; |
ffd1c96afe4b
a pretty simple wrapper around TypeId+Parameters: ObjectFactory
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
32 |
} |
ffd1c96afe4b
a pretty simple wrapper around TypeId+Parameters: ObjectFactory
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
33 |
void |
ffd1c96afe4b
a pretty simple wrapper around TypeId+Parameters: ObjectFactory
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
34 |
ObjectFactory::SetTypeId (std::string tid) |
ffd1c96afe4b
a pretty simple wrapper around TypeId+Parameters: ObjectFactory
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
35 |
{ |
ffd1c96afe4b
a pretty simple wrapper around TypeId+Parameters: ObjectFactory
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
36 |
m_tid = TypeId::LookupByName (tid); |
ffd1c96afe4b
a pretty simple wrapper around TypeId+Parameters: ObjectFactory
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
37 |
} |
ffd1c96afe4b
a pretty simple wrapper around TypeId+Parameters: ObjectFactory
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
38 |
void |
2488
c35c4f282206
add an extra overload of SetTypeId to avoid overload resolution confusions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2433
diff
changeset
|
39 |
ObjectFactory::SetTypeId (const char *tid) |
c35c4f282206
add an extra overload of SetTypeId to avoid overload resolution confusions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2433
diff
changeset
|
40 |
{ |
c35c4f282206
add an extra overload of SetTypeId to avoid overload resolution confusions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2433
diff
changeset
|
41 |
m_tid = TypeId::LookupByName (tid); |
c35c4f282206
add an extra overload of SetTypeId to avoid overload resolution confusions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2433
diff
changeset
|
42 |
} |
c35c4f282206
add an extra overload of SetTypeId to avoid overload resolution confusions.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2433
diff
changeset
|
43 |
void |
2433
3a98e1db7f80
PValue -> Attribute
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2395
diff
changeset
|
44 |
ObjectFactory::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
|
45 |
{ |
2522
7c9d1c314beb
report attribute setting errors as early as possible.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2502
diff
changeset
|
46 |
if (name == "") |
7c9d1c314beb
report attribute setting errors as early as possible.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2502
diff
changeset
|
47 |
{ |
7c9d1c314beb
report attribute setting errors as early as possible.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2502
diff
changeset
|
48 |
return; |
7c9d1c314beb
report attribute setting errors as early as possible.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2502
diff
changeset
|
49 |
} |
2583
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2582
diff
changeset
|
50 |
m_parameters.SetWithTid (m_tid, name, value); |
2395
ffd1c96afe4b
a pretty simple wrapper around TypeId+Parameters: ObjectFactory
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
51 |
} |
ffd1c96afe4b
a pretty simple wrapper around TypeId+Parameters: ObjectFactory
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
52 |
|
ffd1c96afe4b
a pretty simple wrapper around TypeId+Parameters: ObjectFactory
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
53 |
TypeId |
ffd1c96afe4b
a pretty simple wrapper around TypeId+Parameters: ObjectFactory
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
54 |
ObjectFactory::GetTypeId (void) const |
ffd1c96afe4b
a pretty simple wrapper around TypeId+Parameters: ObjectFactory
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
55 |
{ |
ffd1c96afe4b
a pretty simple wrapper around TypeId+Parameters: ObjectFactory
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
56 |
return m_tid; |
ffd1c96afe4b
a pretty simple wrapper around TypeId+Parameters: ObjectFactory
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
57 |
} |
ffd1c96afe4b
a pretty simple wrapper around TypeId+Parameters: ObjectFactory
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
58 |
|
ffd1c96afe4b
a pretty simple wrapper around TypeId+Parameters: ObjectFactory
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
59 |
Ptr<Object> |
ffd1c96afe4b
a pretty simple wrapper around TypeId+Parameters: ObjectFactory
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
60 |
ObjectFactory::Create (void) const |
ffd1c96afe4b
a pretty simple wrapper around TypeId+Parameters: ObjectFactory
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
61 |
{ |
ffd1c96afe4b
a pretty simple wrapper around TypeId+Parameters: ObjectFactory
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
62 |
Ptr<Object> object = m_tid.CreateObject (m_parameters); |
ffd1c96afe4b
a pretty simple wrapper around TypeId+Parameters: ObjectFactory
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
63 |
return object; |
ffd1c96afe4b
a pretty simple wrapper around TypeId+Parameters: ObjectFactory
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
64 |
} |
ffd1c96afe4b
a pretty simple wrapper around TypeId+Parameters: ObjectFactory
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
65 |
|
2555
469bcb4d0010
give Attribute power to ObjectFactory class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2522
diff
changeset
|
66 |
std::ostream & operator << (std::ostream &os, const ObjectFactory &factory) |
469bcb4d0010
give Attribute power to ObjectFactory class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2522
diff
changeset
|
67 |
{ |
2583
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2582
diff
changeset
|
68 |
// XXX |
2555
469bcb4d0010
give Attribute power to ObjectFactory class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2522
diff
changeset
|
69 |
return os; |
469bcb4d0010
give Attribute power to ObjectFactory class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2522
diff
changeset
|
70 |
} |
469bcb4d0010
give Attribute power to ObjectFactory class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2522
diff
changeset
|
71 |
std::istream & operator >> (std::istream &is, ObjectFactory &factory) |
469bcb4d0010
give Attribute power to ObjectFactory class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2522
diff
changeset
|
72 |
{ |
2583
c09faa6c90bf
doxygen doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2582
diff
changeset
|
73 |
// XXX |
2555
469bcb4d0010
give Attribute power to ObjectFactory class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2522
diff
changeset
|
74 |
return is; |
469bcb4d0010
give Attribute power to ObjectFactory class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2522
diff
changeset
|
75 |
} |
469bcb4d0010
give Attribute power to ObjectFactory class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2522
diff
changeset
|
76 |
|
469bcb4d0010
give Attribute power to ObjectFactory class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2522
diff
changeset
|
77 |
|
2582
3e28107b870f
rename old VALUE leftovers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2555
diff
changeset
|
78 |
ATTRIBUTE_HELPER_CPP (ObjectFactory); |
2555
469bcb4d0010
give Attribute power to ObjectFactory class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2522
diff
changeset
|
79 |
|
2395
ffd1c96afe4b
a pretty simple wrapper around TypeId+Parameters: ObjectFactory
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
80 |
} // namespace ns3 |