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 "
hash.h
"
29
#include <string>
30
#include <stdint.h>
31
32
namespace
ns3 {
33
34
class
ObjectBase;
35
49
class
TypeId
50
{
51
public
:
55
enum
AttributeFlag
{
56
ATTR_GET
= 1<<0,
57
ATTR_SET
= 1<<1,
58
ATTR_CONSTRUCT
= 1<<2,
59
ATTR_SGC
=
ATTR_GET
|
ATTR_SET
|
ATTR_CONSTRUCT
,
60
};
61
struct
AttributeInformation
{
62
std::string
name
;
63
std::string
help
;
64
uint32_t
flags
;
65
Ptr<const AttributeValue>
originalInitialValue
;
66
Ptr<const AttributeValue>
initialValue
;
67
Ptr<const AttributeAccessor>
accessor
;
68
Ptr<const AttributeChecker>
checker
;
69
};
70
struct
TraceSourceInformation
{
71
std::string
name
;
72
std::string
help
;
73
Ptr<const TraceSourceAccessor>
accessor
;
74
};
75
79
typedef
uint32_t
hash_t
;
80
89
static
TypeId
LookupByName
(std::string name);
96
static
bool
LookupByNameFailSafe
(std::string name,
TypeId
*tid);
104
static
TypeId
LookupByHash
(
hash_t
hash);
111
static
bool
LookupByHashFailSafe
(
hash_t
hash,
TypeId
*tid);
112
116
static
uint32_t
GetRegisteredN
(
void
);
121
static
TypeId
GetRegistered
(uint32_t i);
122
129
explicit
TypeId
(
const
char
* name);
130
140
TypeId
GetParent
(
void
)
const
;
141
142
bool
HasParent
(
void
)
const
;
143
153
bool
IsChildOf
(
TypeId
other)
const
;
154
158
std::string
GetGroupName
(
void
)
const
;
159
163
std::string
GetName
(
void
)
const
;
164
168
hash_t
GetHash
(
void
)
const
;
169
173
bool
HasConstructor
(
void
)
const
;
174
178
uint32_t
GetAttributeN
(
void
)
const
;
184
struct
TypeId::AttributeInformation
GetAttribute
(uint32_t i) const;
190
std::string
GetAttributeFullName
(uint32_t i)
const
;
191
196
Callback<ObjectBase *>
GetConstructor
(
void
)
const
;
197
202
bool
MustHideFromDocumentation
(
void
)
const
;
203
204
208
uint32_t
GetTraceSourceN
(
void
)
const
;
213
struct
TypeId::TraceSourceInformation
GetTraceSource
(uint32_t i) const;
214
222
TypeId
SetParent
(
TypeId
tid);
229
template
<
typename
T>
230
TypeId
SetParent
(
void
);
231
240
TypeId
SetGroupName
(std::string groupName);
241
248
template
<
typename
T>
249
TypeId
AddConstructor
(
void
);
250
262
TypeId
AddAttribute
(std::string name,
263
std::string help,
264
const
AttributeValue
&initialValue,
265
Ptr<const AttributeAccessor>
accessor,
266
Ptr<const AttributeChecker>
checker);
267
273
bool
SetAttributeInitialValue
(uint32_t i,
274
Ptr<const AttributeValue>
initialValue);
275
288
TypeId
AddAttribute
(std::string name,
289
std::string help,
290
uint32_t flags,
291
const
AttributeValue
&initialValue,
292
Ptr<const AttributeAccessor>
accessor,
293
Ptr<const AttributeChecker>
checker);
294
303
TypeId
AddTraceSource
(std::string name,
304
std::string help,
305
Ptr<const TraceSourceAccessor>
accessor);
306
307
TypeId
HideFromDocumentation
(
void
);
308
315
bool
LookupAttributeByName
(std::string name,
struct
AttributeInformation
*info)
const
;
323
Ptr<const TraceSourceAccessor>
LookupTraceSourceByName
(std::string name)
const
;
324
332
uint16_t
GetUid
(
void
)
const
;
341
void
SetUid
(uint16_t tid);
342
343
// construct an invalid TypeId.
344
inline
TypeId
();
345
inline
TypeId
(
const
TypeId
&o);
346
inline
TypeId
&
operator =
(
const
TypeId
&o);
347
inline
~TypeId
();
348
349
private
:
350
friend
class
AttributeList
;
351
friend
bool
operator ==
(
TypeId
a,
TypeId
b);
352
friend
bool
operator !=
(
TypeId
a,
TypeId
b);
353
friend
bool
operator <
(
TypeId
a,
TypeId
b);
354
355
356
explicit
TypeId
(uint16_t tid);
357
void
DoAddConstructor
(
Callback<ObjectBase *>
callback);
358
359
uint16_t
m_tid
;
360
};
361
362
std::ostream &
operator <<
(std::ostream &os,
TypeId
tid);
363
std::istream &
operator >>
(std::istream &is,
TypeId
&tid);
364
inline
bool
operator ==
(
TypeId
a,
TypeId
b);
365
inline
bool
operator !=
(
TypeId
a,
TypeId
b);
366
bool
operator <
(
TypeId
a,
TypeId
b);
367
374
ATTRIBUTE_HELPER_HEADER
(
TypeId
);
375
376
}
// namespace ns3
377
378
namespace
ns3 {
379
380
TypeId::TypeId
()
381
: m_tid (0) {
382
}
383
TypeId::TypeId
(
const
TypeId
&o)
384
: m_tid (o.m_tid) {
385
}
386
TypeId
&
TypeId::operator =
(
const
TypeId
&o)
387
{
388
m_tid
= o.
m_tid
;
389
return
*
this
;
390
}
391
TypeId::~TypeId
()
392
{
393
}
394
inline
bool
operator ==
(
TypeId
a,
TypeId
b)
395
{
396
return
a.
m_tid
== b.
m_tid
;
397
}
398
399
inline
bool
operator !=
(
TypeId
a,
TypeId
b)
400
{
401
return
a.
m_tid
!= b.
m_tid
;
402
}
403
404
405
/*************************************************************************
406
* The TypeId implementation which depends on templates
407
*************************************************************************/
408
409
template
<
typename
T>
410
TypeId
411
TypeId::SetParent
(
void
)
412
{
413
return
SetParent
(T::GetTypeId ());
414
}
415
416
template
<
typename
T>
417
TypeId
418
TypeId::AddConstructor
(
void
)
419
{
420
struct
Maker {
421
static
ObjectBase
*
Create
() {
422
ObjectBase
* base =
new
T ();
423
return
base;
424
}
425
};
426
Callback<ObjectBase *>
cb =
MakeCallback
(&
Maker::Create
);
427
DoAddConstructor
(cb);
428
return
*
this
;
429
}
430
431
}
// namespace ns3
432
433
#endif
/* TYPE_ID_H */
src
core
model
type-id.h
Generated on Fri Aug 30 2013 01:42:47 for ns-3 by
1.8.1.2