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
type-id.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
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19
*/
20
#ifndef TYPE_ID_H
21
#define TYPE_ID_H
22
23
#include "
attribute.h
"
24
#include "
attribute-accessor-helper.h
"
25
#include "
trace-source-accessor.h
"
26
#include "
attribute-helper.h
"
27
#include "
callback.h
"
28
#include <string>
29
#include <stdint.h>
30
31
namespace
ns3 {
32
33
class
ObjectBase;
34
44
class
TypeId
45
{
46
public
:
50
enum
AttributeFlag
{
51
ATTR_GET
= 1<<0,
52
ATTR_SET
= 1<<1,
53
ATTR_CONSTRUCT
= 1<<2,
54
ATTR_SGC
=
ATTR_GET
|
ATTR_SET
|
ATTR_CONSTRUCT
,
55
};
56
struct
AttributeInformation
{
57
std::string
name
;
58
std::string
help
;
59
uint32_t
flags
;
60
ns3::Ptr<const ns3::AttributeValue>
originalInitialValue
;
61
ns3::Ptr<const ns3::AttributeValue>
initialValue
;
62
ns3::Ptr<const ns3::AttributeAccessor>
accessor
;
63
ns3::Ptr<const ns3::AttributeChecker>
checker
;
64
};
65
struct
TraceSourceInformation
{
66
std::string
name
;
67
std::string
help
;
68
ns3::Ptr<const ns3::TraceSourceAccessor>
accessor
;
69
};
70
79
static
TypeId
LookupByName
(std::string name);
86
static
bool
LookupByNameFailSafe
(std::string name,
TypeId
*tid);
87
91
static
uint32_t
GetRegisteredN
(
void
);
96
static
TypeId
GetRegistered
(uint32_t i);
97
104
explicit
TypeId
(
const
char
* name);
105
115
TypeId
GetParent
(
void
)
const
;
116
117
bool
HasParent
(
void
)
const
;
118
128
bool
IsChildOf
(
TypeId
other)
const
;
129
133
std::string
GetGroupName
(
void
)
const
;
134
138
std::string
GetName
(
void
)
const
;
139
143
bool
HasConstructor
(
void
)
const
;
144
148
uint32_t
GetAttributeN
(
void
)
const
;
154
struct
TypeId::AttributeInformation
GetAttribute
(uint32_t i) const;
160
std::string
GetAttributeFullName
(uint32_t i)
const
;
161
166
Callback<ObjectBase *>
GetConstructor
(
void
)
const
;
167
172
bool
MustHideFromDocumentation
(
void
)
const
;
173
174
178
uint32_t
GetTraceSourceN
(
void
)
const
;
183
struct
TypeId::TraceSourceInformation
GetTraceSource
(uint32_t i) const;
184
192
TypeId
SetParent
(
TypeId
tid);
199
template
<
typename
T>
200
TypeId
SetParent
(
void
);
201
210
TypeId
SetGroupName
(std::string groupName);
211
218
template
<
typename
T>
219
TypeId
AddConstructor
(
void
);
220
232
TypeId
AddAttribute
(std::string name,
233
std::string help,
234
const
AttributeValue
&initialValue,
235
Ptr<const AttributeAccessor>
accessor,
236
Ptr<const AttributeChecker>
checker);
237
243
bool
SetAttributeInitialValue
(uint32_t i,
244
Ptr<const AttributeValue>
initialValue);
245
258
TypeId
AddAttribute
(std::string name,
259
std::string help,
260
uint32_t flags,
261
const
AttributeValue
&initialValue,
262
Ptr<const AttributeAccessor>
accessor,
263
Ptr<const AttributeChecker>
checker);
264
273
TypeId
AddTraceSource
(std::string name,
274
std::string help,
275
Ptr<const TraceSourceAccessor>
accessor);
276
277
TypeId
HideFromDocumentation
(
void
);
278
285
bool
LookupAttributeByName
(std::string name,
struct
AttributeInformation
*info)
const
;
293
Ptr<const TraceSourceAccessor>
LookupTraceSourceByName
(std::string name)
const
;
294
302
uint16_t
GetUid
(
void
)
const
;
311
void
SetUid
(uint16_t tid);
312
313
// construct an invalid TypeId.
314
inline
TypeId
();
315
inline
TypeId
(
const
TypeId
&o);
316
inline
TypeId
&
operator =
(
const
TypeId
&o);
317
inline
~TypeId
();
318
319
private
:
320
friend
class
AttributeList
;
321
friend
bool
operator ==
(
TypeId
a,
TypeId
b);
322
friend
bool
operator !=
(
TypeId
a,
TypeId
b);
323
friend
bool
operator <
(
TypeId
a,
TypeId
b);
324
325
326
explicit
TypeId
(uint16_t tid);
327
void
DoAddConstructor
(
Callback<ObjectBase *>
callback);
328
329
uint16_t
m_tid
;
330
};
331
332
std::ostream &
operator <<
(std::ostream &os,
TypeId
tid);
333
std::istream &
operator >>
(std::istream &is,
TypeId
&tid);
334
inline
bool
operator ==
(
TypeId
a,
TypeId
b);
335
inline
bool
operator !=
(
TypeId
a,
TypeId
b);
336
bool
operator <
(
TypeId
a,
TypeId
b);
337
344
ATTRIBUTE_HELPER_HEADER
(
TypeId
);
345
346
}
// namespace ns3
347
348
namespace
ns3 {
349
350
TypeId::TypeId
()
351
: m_tid (0) {
352
}
353
TypeId::TypeId
(
const
TypeId
&o)
354
: m_tid (o.m_tid) {
355
}
356
TypeId
&
TypeId::operator =
(
const
TypeId
&o)
357
{
358
m_tid
= o.
m_tid
;
359
return
*
this
;
360
}
361
TypeId::~TypeId
()
362
{
363
}
364
inline
bool
operator ==
(
TypeId
a,
TypeId
b)
365
{
366
return
a.
m_tid
== b.
m_tid
;
367
}
368
369
inline
bool
operator !=
(
TypeId
a,
TypeId
b)
370
{
371
return
a.
m_tid
!= b.
m_tid
;
372
}
373
374
375
/*************************************************************************
376
* The TypeId implementation which depends on templates
377
*************************************************************************/
378
379
template
<
typename
T>
380
TypeId
381
TypeId::SetParent
(
void
)
382
{
383
return
SetParent
(T::GetTypeId ());
384
}
385
386
template
<
typename
T>
387
TypeId
388
TypeId::AddConstructor
(
void
)
389
{
390
struct
Maker {
391
static
ObjectBase
*
Create
() {
392
ObjectBase
* base =
new
T ();
393
return
base;
394
}
395
};
396
Callback<ObjectBase *>
cb =
MakeCallback
(&
Maker::Create
);
397
DoAddConstructor
(cb);
398
return
*
this
;
399
}
400
401
}
// namespace ns3
402
403
#endif
/* TYPE_ID_H */
src
core
model
type-id.h
Generated on Tue May 14 2013 11:08:18 for ns-3 by
1.8.1.2