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 */
ns3::ATTRIBUTE_HELPER_HEADER
ATTRIBUTE_HELPER_HEADER(ObjectFactory)
ns3::operator>>
std::istream & operator>>(std::istream &is, Angles &a)
initialize a struct Angles from input
Definition:
angles.cc:49
ns3::ObjectFactory::GetTypeId
TypeId GetTypeId(void) const
Definition:
object-factory.cc:83
ns3::Ptr< Object >
ns3::ObjectFactory::m_parameters
AttributeConstructionList m_parameters
Definition:
object-factory.h:88
ns3::AttributeValue
Hold a value for an Attribute.
Definition:
attribute.h:56
ns3::ObjectFactory::SetTypeId
void SetTypeId(TypeId tid)
Definition:
object-factory.cc:41
ns3::ObjectFactory::ObjectFactory
ObjectFactory()
Definition:
object-factory.cc:29
attribute-construction-list.h
ns3::EmptyAttributeValue
A class for an empty attribute value.
Definition:
attribute.h:222
ns3::ObjectFactory::Create
Ptr< Object > Create(void) const
Definition:
object-factory.cc:90
ns3::CreateObjectWithAttributes
Ptr< T > CreateObjectWithAttributes(std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue(), std::string n8="", const AttributeValue &v8=EmptyAttributeValue(), std::string n9="", const AttributeValue &v9=EmptyAttributeValue())
Definition:
object-factory.h:155
ns3::AttributeConstructionList
Definition:
attribute-construction-list.h:28
ns3::operator<<
std::ostream & operator<<(std::ostream &os, const Angles &a)
print a struct Angles to output
Definition:
angles.cc:43
type-id.h
ns3::ObjectFactory::Set
void Set(std::string name, const AttributeValue &value)
Definition:
object-factory.cc:59
object.h
ns3::ObjectFactory::operator>>
friend std::istream & operator>>(std::istream &is, ObjectFactory &factory)
Definition:
object-factory.cc:118
ns3::ObjectFactory
instantiate subclasses of ns3::Object.
Definition:
object-factory.h:39
ns3::ObjectFactory::operator<<
friend std::ostream & operator<<(std::ostream &os, const ObjectFactory &factory)
Definition:
object-factory.cc:103
ns3::ObjectFactory::m_tid
TypeId m_tid
Definition:
object-factory.h:87
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:49
src
core
model
object-factory.h
Generated on Sat Apr 19 2014 14:06:52 for ns-3 by
1.8.6