A Discrete-Event Network Simulator
API
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 
32 namespace ns3
33 {
34 
45 template <typename T>
46 std::string
48 {
49  NS_FATAL_ERROR("Type name not defined.");
50  return "unknown";
51 }
52 
60 #define TYPENAMEGET_DEFINE(T) \
61  template <> \
62  inline std::string TypeNameGet<T>() \
63  { \
64  return #T; \
65  }
66 
84 TYPENAMEGET_DEFINE(long double);
87 } // namespace ns3
88 
89 #endif /* TYPE_NAME_H */
NS_FATAL_x macro definitions.
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
TYPENAMEGET_DEFINE(Time)
ns3::TypeNameGet<Time>() specialization.
Every class exported by the ns3 library is enclosed in the ns3 namespace.