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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 */
7
8#ifndef TYPE_NAME_H
9#define TYPE_NAME_H
10
11#include "fatal-error.h"
12
13#include <string>
14
15/**
16 * \file
17 * \ingroup attributeimpl
18 * ns3::TypeNameGet() function declarations.
19 */
20
21namespace ns3
22{
23
24/**
25 * \ingroup attributeimpl
26 *
27 * Type name strings for AttributeValue types.
28 * Custom classes should add a template specialization of this function
29 * using the macro \c TYPENAMEGET_DEFINE(T).
30 *
31 * \tparam T \explicit The type.
32 * \returns The type name as a string.
33 */
34template <typename T>
35std::string
37{
38 NS_FATAL_ERROR("Type name not defined.");
39 return "unknown";
40}
41
42/**
43 * \ingroup attributeimpl
44 *
45 * Macro that defines a template specialization for \c TypeNameGet<T>() .
46 *
47 * \param T The type.
48 */
49#define TYPENAMEGET_DEFINE(T) \
50 template <> \
51 inline std::string TypeNameGet<T>() \
52 { \
53 return #T; \
54 }
55
56/**
57 * \ingroup attributeimpl
58 * ns3::TypeNameGet() specialization for numeric types.
59 * \returns The numeric type name as a string.
60 * @{
61 */
73TYPENAMEGET_DEFINE(long double);
74/** @} */
75
76} // namespace ns3
77
78#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:49
std::string TypeNameGet()
Type name strings for AttributeValue types.
Definition type-name.h:36
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Every class exported by the ns3 library is enclosed in the ns3 namespace.