OLD | NEW |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2008 INRIA | 3 * Copyright (c) 2008 INRIA |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 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 | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 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 | 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 | 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
17 * | 17 * |
18 * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> | 18 * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
19 */ | 19 */ |
20 #ifndef ENUM_VALUE_H | 20 #ifndef ENUM_VALUE_H |
21 #define ENUM_VALUE_H | 21 #define ENUM_VALUE_H |
22 | 22 |
23 #include "attribute.h" | 23 #include "attribute.h" |
24 #include "attribute-accessor-helper.h" | 24 #include "attribute-accessor-helper.h" |
25 #include <list> | 25 #include <list> |
26 | 26 |
| 27 #include "ns3/ns3-module.h" |
| 28 #define NS3_MODULE NS3_CORE_MODULE |
| 29 #include "ns3/ns3-export.h" |
| 30 |
27 /** | 31 /** |
28 * \file | 32 * \file |
29 * \ingroup attribute_Enum | 33 * \ingroup attribute_Enum |
30 * ns3::EnumValue attribute value declarations. | 34 * ns3::EnumValue attribute value declarations. |
31 */ | 35 */ |
32 | 36 |
33 namespace ns3 { | 37 namespace ns3 { |
34 | 38 |
35 // Additional docs for class EnumValue: | 39 // Additional docs for class EnumValue: |
36 /** | 40 /** |
37 * Hold variables of type \c enum | 41 * Hold variables of type \c enum |
38 * | 42 * |
39 * This class can be used to hold variables of any kind | 43 * This class can be used to hold variables of any kind |
40 * of enum. | 44 * of enum. |
41 * | 45 * |
42 * This is often used with ObjectFactory and Config to bind | 46 * This is often used with ObjectFactory and Config to bind |
43 * the value of a particular enum to an Attribute or Config name. | 47 * the value of a particular enum to an Attribute or Config name. |
44 * For example, | 48 * For example, |
45 * \code | 49 * \code |
46 * Ptr<RateErrorModel> model = CreateObjectWithAttributes<RateErrorModel> ( | 50 * Ptr<RateErrorModel> model = CreateObjectWithAttributes<RateErrorModel> ( |
47 * "ErrorRate", DoubleValue (0.05), | 51 * "ErrorRate", DoubleValue (0.05), |
48 * "ErrorUnit", EnumValue (RateErrorModel::ERROR_UNIT_PACKET)); | 52 * "ErrorUnit", EnumValue (RateErrorModel::ERROR_UNIT_PACKET)); |
49 * | 53 * |
50 * Config::SetDefault ("ns3::RipNg::SplitHorizon", | 54 * Config::SetDefault ("ns3::RipNg::SplitHorizon", |
51 * EnumValue (RipNg::NO_SPLIT_HORIZON)); | 55 * EnumValue (RipNg::NO_SPLIT_HORIZON)); |
52 * \endcode | 56 * \endcode |
53 */ | 57 */ |
54 class EnumValue : public AttributeValue | 58 class NS3_EXPORT EnumValue : public AttributeValue |
55 { | 59 { |
56 public: | 60 public: |
57 EnumValue (); | 61 EnumValue (); |
58 /** | 62 /** |
59 * Construct from an explicit value. | 63 * Construct from an explicit value. |
60 * | 64 * |
61 * \param [in] value The value to begin with. | 65 * \param [in] value The value to begin with. |
62 */ | 66 */ |
63 EnumValue (int value); | 67 EnumValue (int value); |
64 void Set (int value); | 68 void Set (int value); |
(...skipping 10 matching lines...) Expand all Loading... |
75 }; | 79 }; |
76 | 80 |
77 template <typename T> | 81 template <typename T> |
78 bool | 82 bool |
79 EnumValue::GetAccessor (T &value) const | 83 EnumValue::GetAccessor (T &value) const |
80 { | 84 { |
81 value = T (m_value); | 85 value = T (m_value); |
82 return true; | 86 return true; |
83 } | 87 } |
84 | 88 |
85 class EnumChecker : public AttributeChecker | 89 class NS3_EXPORT EnumChecker : public AttributeChecker |
86 { | 90 { |
87 public: | 91 public: |
88 EnumChecker (); | 92 EnumChecker (); |
89 | 93 |
90 /** | 94 /** |
91 * Add a default value. | 95 * Add a default value. |
92 * \param [in] value The value. | 96 * \param [in] value The value. |
93 * \param [in] name Then enum symbol name. | 97 * \param [in] name Then enum symbol name. |
94 */ | 98 */ |
95 void AddDefault (int value, std::string name); | 99 void AddDefault (int value, std::string name); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 * \param [in] n18 The corresponding name. | 174 * \param [in] n18 The corresponding name. |
171 * \param [in] v19 A enum value | 175 * \param [in] v19 A enum value |
172 * \param [in] n19 The corresponding name. | 176 * \param [in] n19 The corresponding name. |
173 * \param [in] v20 An enum value | 177 * \param [in] v20 An enum value |
174 * \param [in] n20 The enum name. | 178 * \param [in] n20 The enum name. |
175 * \param [in] v21 An enum value | 179 * \param [in] v21 An enum value |
176 * \param [in] n21 The corresponding name. | 180 * \param [in] n21 The corresponding name. |
177 * \param [in] v22 A enum value | 181 * \param [in] v22 A enum value |
178 * \param [in] n22 The corresponding name. | 182 * \param [in] n22 The corresponding name. |
179 */· | 183 */· |
180 Ptr<const AttributeChecker> MakeEnumChecker (int v1, std::string n1, | 184 NS3_EXPORT Ptr<const AttributeChecker> MakeEnumChecker (int v1, std::string n1, |
181 int v2 = 0, std::string n2 = "", | 185 int v2 = 0, std::string n2 = "", |
182 int v3 = 0, std::string n3 = "", | 186 int v3 = 0, std::string n3 = "", |
183 int v4 = 0, std::string n4 = "", | 187 int v4 = 0, std::string n4 = "", |
184 int v5 = 0, std::string n5 = "", | 188 int v5 = 0, std::string n5 = "", |
185 int v6 = 0, std::string n6 = "", | 189 int v6 = 0, std::string n6 = "", |
186 int v7 = 0, std::string n7 = "", | 190 int v7 = 0, std::string n7 = "", |
187 int v8 = 0, std::string n8 = "", | 191 int v8 = 0, std::string n8 = "", |
188 int v9 = 0, std::string n9 = "", | 192 int v9 = 0, std::string n9 = "", |
189 int v10 = 0, std::string n10 = "", | 193 int v10 = 0, std::string n10 = "", |
190 int v11 = 0, std::string n11 = "", | 194 int v11 = 0, std::string n11 = "", |
(...skipping 22 matching lines...) Expand all Loading... |
213 | 217 |
214 template <typename T1, typename T2> | 218 template <typename T1, typename T2> |
215 Ptr<const AttributeAccessor> MakeEnumAccessor (T1 a1, T2 a2) | 219 Ptr<const AttributeAccessor> MakeEnumAccessor (T1 a1, T2 a2) |
216 { | 220 { |
217 return MakeAccessorHelper<EnumValue> (a1, a2); | 221 return MakeAccessorHelper<EnumValue> (a1, a2); |
218 } | 222 } |
219 | 223 |
220 } // namespace ns3 | 224 } // namespace ns3 |
221 | 225 |
222 #endif /* ENUM_VALUE_H */ | 226 #endif /* ENUM_VALUE_H */ |
OLD | NEW |