A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
type-name.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2007 Georgia Tech Research Corporation
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 */
18
19#ifndef TYPE_NAME_H
20#define TYPE_NAME_H
21
22#include "fatal-error.h"
23
24#include <string>
25
26/**
27 * \file
28 * \ingroup attributeimpl
29 * ns3::TypeNameGet() function declarations.
30 */
31
32namespace ns3
33{
34
35/**
36 * \ingroup attributeimpl
37 *
38 * Type name strings for AttributeValue types.
39 * Custom classes should add a template specialization of this function
40 * using the macro \c TYPE_NAME_GET_DEFINE(T).
41 *
42 * \tparam T \explicit The type.
43 * \returns The type name as a string.
44 */
45template <typename T>
46std::string
48{
49 NS_FATAL_ERROR("Type name not defined.");
50 return "unknown";
51}
52
53/**
54 * \ingroup attributeimpl
55 *
56 * Macro that defines a template specialization for \c TypeNameGet<T>() .
57 *
58 * \param T The type.
59 */
60#define TYPENAMEGET_DEFINE(T) \
61 template <> \
62 inline std::string TypeNameGet<T>() \
63 { \
64 return #T; \
65 }
66
67/**
68 * \ingroup attributeimpl
69 * ns3::TypeNameGet() specialization for numeric types.
70 * \returns The numeric type name as a string.
71 * @{
72 */
84TYPENAMEGET_DEFINE(long double);
85/** @} */
86
87} // namespace ns3
88
89#endif /* TYPE_NAME_H */
NS_FATAL_x macro definitions.
#define TYPENAMEGET_DEFINE(T)
Macro that defines a template specialization for TypeNameGet<T>() .
Definition: type-name.h:60
std::string TypeNameGet()
Type name strings for AttributeValue types.
Definition: type-name.h:47
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:179
Every class exported by the ns3 library is enclosed in the ns3 namespace.