A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
object-factory.h
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2008 INRIA
4
*
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License version 2 as
7
* published by the Free Software Foundation;
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
*
18
* Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19
*/
20
#ifndef OBJECT_FACTORY_H
21
#define OBJECT_FACTORY_H
22
23
#include "
attribute-construction-list.h
"
24
#include "
object.h
"
25
#include "
type-id.h
"
26
27
namespace
ns3 {
28
29
class
AttributeValue;
30
39
class
ObjectFactory
40
{
41
public
:
42
ObjectFactory
();
43
ObjectFactory
(std::string typeId);
44
48
void
SetTypeId
(
TypeId
tid);
52
void
SetTypeId
(
const
char
*tid);
56
void
SetTypeId
(std::string tid);
61
void
Set
(std::string name,
const
AttributeValue
&value);
62
67
TypeId
GetTypeId
(
void
)
const
;
68
72
Ptr<Object>
Create
(
void
)
const
;
80
template
<
typename
T>
81
Ptr<T>
Create
(
void
)
const
;
82
83
private
:
84
friend
std::ostream &
operator <<
(std::ostream &os,
const
ObjectFactory
&factory);
85
friend
std::istream &
operator >>
(std::istream &is,
ObjectFactory
&factory);
86
87
TypeId
m_tid
;
88
AttributeConstructionList
m_parameters
;
89
};
90
91
std::ostream &
operator <<
(std::ostream &os,
const
ObjectFactory
&factory);
92
std::istream &
operator >>
(std::istream &is,
ObjectFactory
&factory);
93
94
119
template
<
typename
T>
120
Ptr<T>
121
CreateObjectWithAttributes
(std::string n1 =
""
,
const
AttributeValue
& v1 =
EmptyAttributeValue
(),
122
std::string n2 =
""
,
const
AttributeValue
& v2 =
EmptyAttributeValue
(),
123
std::string n3 =
""
,
const
AttributeValue
& v3 =
EmptyAttributeValue
(),
124
std::string n4 =
""
,
const
AttributeValue
& v4 =
EmptyAttributeValue
(),
125
std::string n5 =
""
,
const
AttributeValue
& v5 =
EmptyAttributeValue
(),
126
std::string n6 =
""
,
const
AttributeValue
& v6 =
EmptyAttributeValue
(),
127
std::string n7 =
""
,
const
AttributeValue
& v7 =
EmptyAttributeValue
(),
128
std::string n8 =
""
,
const
AttributeValue
& v8 =
EmptyAttributeValue
(),
129
std::string n9 =
""
,
const
AttributeValue
& v9 =
EmptyAttributeValue
());
130
131
132
133
139
ATTRIBUTE_HELPER_HEADER
(
ObjectFactory
);
140
141
}
// namespace ns3
142
143
namespace
ns3 {
144
145
template
<
typename
T>
146
Ptr<T>
147
ObjectFactory::Create
(
void
)
const
148
{
149
Ptr<Object>
object
=
Create
();
150
return
object
->GetObject<T> ();
151
}
152
153
template
<
typename
T>
154
Ptr<T>
155
CreateObjectWithAttributes
(std::string n1,
const
AttributeValue
& v1,
156
std::string n2,
const
AttributeValue
& v2,
157
std::string n3,
const
AttributeValue
& v3,
158
std::string n4,
const
AttributeValue
& v4,
159
std::string n5,
const
AttributeValue
& v5,
160
std::string n6,
const
AttributeValue
& v6,
161
std::string n7,
const
AttributeValue
& v7,
162
std::string n8,
const
AttributeValue
& v8,
163
std::string n9,
const
AttributeValue
& v9)
164
{
165
ObjectFactory
factory;
166
factory.
SetTypeId
(T::GetTypeId ());
167
factory.
Set
(n1, v1);
168
factory.
Set
(n2, v2);
169
factory.
Set
(n3, v3);
170
factory.
Set
(n4, v4);
171
factory.
Set
(n5, v5);
172
factory.
Set
(n6, v6);
173
factory.
Set
(n7, v7);
174
factory.
Set
(n8, v8);
175
factory.
Set
(n9, v9);
176
return
factory.
Create
<T> ();
177
}
178
179
180
}
// namespace ns3
181
182
#endif
/* OBJECT_FACTORY_H */
src
core
model
object-factory.h
Generated on Tue Nov 13 2012 10:32:10 for ns-3 by
1.8.1.2