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 ATTRIBUTE_H | 20 #ifndef ATTRIBUTE_H |
21 #define ATTRIBUTE_H | 21 #define ATTRIBUTE_H |
22 | 22 |
23 #include <string> | 23 #include <string> |
24 #include <stdint.h> | 24 #include <stdint.h> |
25 #include "ptr.h" | 25 #include "ptr.h" |
26 #include "simple-ref-count.h" | 26 #include "simple-ref-count.h" |
27 | 27 |
| 28 #include "ns3/ns3-module.h" |
| 29 #define NS3_MODULE NS3_CORE_MODULE |
| 30 #include "ns3/ns3-export.h" |
| 31 · |
28 /** | 32 /** |
29 * \file | 33 * \file |
30 * \ingroup attribute | 34 * \ingroup attribute |
31 * ns3::AttributeValue, ns3::AttributeAccessor and | 35 * ns3::AttributeValue, ns3::AttributeAccessor and |
32 * ns3::AttributeChecker declarations. | 36 * ns3::AttributeChecker declarations. |
33 */ | 37 */ |
34 | 38 |
35 namespace ns3 { | 39 namespace ns3 { |
36 | 40 |
37 class AttributeAccessor; | 41 class AttributeAccessor; |
(...skipping 20 matching lines...) Expand all Loading... |
58 /** | 62 /** |
59 * | 63 * |
60 * \ingroup attribute | 64 * \ingroup attribute |
61 * | 65 * |
62 * \brief Hold a value for an Attribute. | 66 * \brief Hold a value for an Attribute. |
63 * | 67 * |
64 * Instances of this class should always be wrapped into an Attribute object. | 68 * Instances of this class should always be wrapped into an Attribute object. |
65 * Most subclasses of this base class are implemented by the· | 69 * Most subclasses of this base class are implemented by the· |
66 * ATTRIBUTE_HELPER_* macros. | 70 * ATTRIBUTE_HELPER_* macros. |
67 */ | 71 */ |
68 class AttributeValue : public SimpleRefCount<AttributeValue> | 72 class NS3_EXPORT AttributeValue : public SimpleRefCount<AttributeValue> |
69 { | 73 { |
70 public: | 74 public: |
71 AttributeValue (); | 75 AttributeValue (); |
72 virtual ~AttributeValue (); | 76 virtual ~AttributeValue (); |
73 | 77 |
74 /** | 78 /** |
75 * \returns a deep copy of this class, wrapped into an Attribute object. | 79 * \returns a deep copy of this class, wrapped into an Attribute object. |
76 */ | 80 */ |
77 virtual Ptr<AttributeValue> Copy (void) const = 0; | 81 virtual Ptr<AttributeValue> Copy (void) const = 0; |
78 /** | 82 /** |
(...skipping 25 matching lines...) Expand all Loading... |
104 /** | 108 /** |
105 * \brief allow setting and getting the value of an attribute. | 109 * \brief allow setting and getting the value of an attribute. |
106 * | 110 * |
107 * \ingroup attribute | 111 * \ingroup attribute |
108 * | 112 * |
109 * The goal of this class is to hide from the user how an attribute | 113 * The goal of this class is to hide from the user how an attribute |
110 * is actually set or get to or from a class instance. Implementations | 114 * is actually set or get to or from a class instance. Implementations |
111 * of this base class are usually provided through the MakeAccessorHelper | 115 * of this base class are usually provided through the MakeAccessorHelper |
112 * template functions, hidden behind an ATTRIBUTE_HELPER_* macro. | 116 * template functions, hidden behind an ATTRIBUTE_HELPER_* macro. |
113 */ | 117 */ |
114 class AttributeAccessor : public SimpleRefCount<AttributeAccessor> | 118 class NS3_EXPORT AttributeAccessor : public SimpleRefCount<AttributeAccessor> |
115 { | 119 { |
116 public: | 120 public: |
117 AttributeAccessor (); | 121 AttributeAccessor (); |
118 virtual ~AttributeAccessor (); | 122 virtual ~AttributeAccessor (); |
119 | 123 |
120 /** | 124 /** |
121 * \param [in,out] object The object instance to set the value in | 125 * \param [in,out] object The object instance to set the value in |
122 * \param [in] value The value to set | 126 * \param [in] value The value to set |
123 * \returns true if the value could be set successfully, false otherwise. | 127 * \returns true if the value could be set successfully, false otherwise. |
124 * | 128 * |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 * | 160 * |
157 * Each type of attribute has an associated unique AttributeChecker | 161 * Each type of attribute has an associated unique AttributeChecker |
158 * subclass. The type of the subclass can be safely used by users | 162 * subclass. The type of the subclass can be safely used by users |
159 * to infer the type of the associated attribute. i.e., we expect | 163 * to infer the type of the associated attribute. i.e., we expect |
160 * binding authors to use the checker associated to an attribute | 164 * binding authors to use the checker associated to an attribute |
161 * to detect the type of the associated attribute. | 165 * to detect the type of the associated attribute. |
162 * | 166 * |
163 * Most subclasses of this base class are implemented by the· | 167 * Most subclasses of this base class are implemented by the· |
164 * ATTRIBUTE_HELPER_HEADER and ATTRIBUTE_HELPER_CPP macros. | 168 * ATTRIBUTE_HELPER_HEADER and ATTRIBUTE_HELPER_CPP macros. |
165 */ | 169 */ |
166 class AttributeChecker : public SimpleRefCount<AttributeChecker> | 170 class NS3_EXPORT AttributeChecker : public SimpleRefCount<AttributeChecker> |
167 { | 171 { |
168 public: | 172 public: |
169 AttributeChecker (); | 173 AttributeChecker (); |
170 virtual ~AttributeChecker (); | 174 virtual ~AttributeChecker (); |
171 | 175 |
172 /** | 176 /** |
173 * Create a valid value from the argument value, | 177 * Create a valid value from the argument value, |
174 * or reinterpret the argument as a string. | 178 * or reinterpret the argument as a string. |
175 * | 179 * |
176 * \param [in] value The AttributeValue to check | 180 * \param [in] value The AttributeValue to check |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 * \return true if copy was successful | 226 * \return true if copy was successful |
223 */ | 227 */ |
224 virtual bool Copy (const AttributeValue &source, AttributeValue &destination)
const = 0; | 228 virtual bool Copy (const AttributeValue &source, AttributeValue &destination)
const = 0; |
225 }; | 229 }; |
226 | 230 |
227 /** | 231 /** |
228 * \brief A class for an empty attribute value. | 232 * \brief A class for an empty attribute value. |
229 * | 233 * |
230 * \ingroup attribute | 234 * \ingroup attribute |
231 */ | 235 */ |
232 class EmptyAttributeValue : public AttributeValue | 236 class NS3_EXPORT EmptyAttributeValue : public AttributeValue |
233 { | 237 { |
234 public: | 238 public: |
235 /** Default constructor. */ | 239 /** Default constructor. */ |
236 EmptyAttributeValue (); | 240 EmptyAttributeValue (); |
237 private: | 241 private: |
238 /** | 242 /** |
239 * \returns a deep copy of this class, wrapped into an Attribute object. | 243 * \returns a deep copy of this class, wrapped into an Attribute object. |
240 */ | 244 */ |
241 virtual Ptr<AttributeValue> Copy (void) const; | 245 virtual Ptr<AttributeValue> Copy (void) const; |
242 /** | 246 /** |
(...skipping 12 matching lines...) Expand all Loading... |
255 * In the trivial case of EmptyAttributeValue, this should always return true | 259 * In the trivial case of EmptyAttributeValue, this should always return true |
256 */ | 260 */ |
257 virtual bool DeserializeFromString (std::string value, Ptr<const AttributeChec
ker> checker); | 261 virtual bool DeserializeFromString (std::string value, Ptr<const AttributeChec
ker> checker); |
258 }; | 262 }; |
259 | 263 |
260 /** | 264 /** |
261 * \brief An accessor for EmptyAttributeValue | 265 * \brief An accessor for EmptyAttributeValue |
262 * | 266 * |
263 * Does nothing, since every EmptyAttributeValue is the same. | 267 * Does nothing, since every EmptyAttributeValue is the same. |
264 */ | 268 */ |
265 class EmptyAttributeAccessor : public AttributeAccessor | 269 class NS3_EXPORT EmptyAttributeAccessor : public AttributeAccessor |
266 { | 270 { |
267 public: | 271 public: |
268 EmptyAttributeAccessor (); | 272 EmptyAttributeAccessor (); |
269 ~EmptyAttributeAccessor (); | 273 ~EmptyAttributeAccessor (); |
270 virtual bool Set (ObjectBase * object, const AttributeValue &value) const; | 274 virtual bool Set (ObjectBase * object, const AttributeValue &value) const; |
271 virtual bool Get (const ObjectBase * object, AttributeValue &attribute) const; | 275 virtual bool Get (const ObjectBase * object, AttributeValue &attribute) const; |
272 virtual bool HasGetter (void) const; | 276 virtual bool HasGetter (void) const; |
273 virtual bool HasSetter (void) const; | 277 virtual bool HasSetter (void) const; |
274 }; | 278 }; |
275 | 279 |
276 /** | 280 /** |
277 * \ingroup attribute | 281 * \ingroup attribute |
278 * | 282 * |
279 * \brief Create an empty AttributeAccessor. | 283 * \brief Create an empty AttributeAccessor. |
280 * | 284 * |
281 * \returns The empty AttributeAccessor (runtime exception if used) | 285 * \returns The empty AttributeAccessor (runtime exception if used) |
282 */ | 286 */ |
283 static inline Ptr<const AttributeAccessor> | 287 static inline Ptr<const AttributeAccessor> |
284 MakeEmptyAttributeAccessor () | 288 MakeEmptyAttributeAccessor () |
285 { | 289 { |
286 return Ptr<const AttributeAccessor> (new EmptyAttributeAccessor (), false); | 290 return Ptr<const AttributeAccessor> (new EmptyAttributeAccessor (), false); |
287 } | 291 } |
288 | 292 |
289 /** | 293 /** |
290 * \brief A checker for EmptyAttributeValue | 294 * \brief A checker for EmptyAttributeValue |
291 * | 295 * |
292 * Does nothing, since every EmptyAttributeValue does not contain anything and | 296 * Does nothing, since every EmptyAttributeValue does not contain anything and |
293 * is, of course, valid. | 297 * is, of course, valid. |
294 */ | 298 */ |
295 class EmptyAttributeChecker : public AttributeChecker | 299 class NS3_EXPORT EmptyAttributeChecker : public AttributeChecker |
296 { | 300 { |
297 public: | 301 public: |
298 EmptyAttributeChecker (); | 302 EmptyAttributeChecker (); |
299 ~EmptyAttributeChecker (); | 303 ~EmptyAttributeChecker (); |
300 virtual bool Check (const AttributeValue &value) const; | 304 virtual bool Check (const AttributeValue &value) const; |
301 virtual std::string GetValueTypeName (void) const; | 305 virtual std::string GetValueTypeName (void) const; |
302 virtual bool HasUnderlyingTypeInformation (void) const; | 306 virtual bool HasUnderlyingTypeInformation (void) const; |
303 virtual std::string GetUnderlyingTypeInformation (void) const; | 307 virtual std::string GetUnderlyingTypeInformation (void) const; |
304 virtual Ptr<AttributeValue> Create (void) const; | 308 virtual Ptr<AttributeValue> Create (void) const; |
305 virtual bool Copy (const AttributeValue &source, AttributeValue &destination)
const; | 309 virtual bool Copy (const AttributeValue &source, AttributeValue &destination)
const; |
306 }; | 310 }; |
307 | 311 |
308 /** | 312 /** |
309 * \ingroup attribute | 313 * \ingroup attribute |
310 * | 314 * |
311 * \brief Create an empty AttributeChecker. | 315 * \brief Create an empty AttributeChecker. |
312 * | 316 * |
313 * \returns The empty AttributeChecker (runtime exception if used) | 317 * \returns The empty AttributeChecker (runtime exception if used) |
314 */ | 318 */ |
315 static inline Ptr<AttributeChecker> | 319 static inline Ptr<AttributeChecker> |
316 MakeEmptyAttributeChecker () | 320 MakeEmptyAttributeChecker () |
317 { | 321 { |
318 return Ptr<AttributeChecker> (new EmptyAttributeChecker (), false); | 322 return Ptr<AttributeChecker> (new EmptyAttributeChecker (), false); |
319 } | 323 } |
320 | 324 |
321 } // namespace ns3 | 325 } // namespace ns3 |
322 | 326 |
323 #endif /* ATTRIBUTE_H */ | 327 #endif /* ATTRIBUTE_H */ |
OLD | NEW |