Left: | ||
Right: |
LEFT | RIGHT |
---|---|
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 |
(...skipping 26 matching lines...) Expand all Loading... | |
37 * \ingroup attribute | 37 * \ingroup attribute |
38 * \defgroup attributehelper Attribute Helper | 38 * \defgroup attributehelper Attribute Helper |
39 * | 39 * |
40 * All these macros can be used to generate automatically the code | 40 * All these macros can be used to generate automatically the code |
41 * for subclasses of AttributeValue, AttributeAccessor, and, AttributeChecker, | 41 * for subclasses of AttributeValue, AttributeAccessor, and, AttributeChecker, |
42 * which can be used to give attribute powers to a normal class. i.e., | 42 * which can be used to give attribute powers to a normal class. i.e., |
43 * the user class can then effectively be made an attribute. | 43 * the user class can then effectively be made an attribute. |
44 * | 44 * |
45 * There are two kinds of helper macros: | 45 * There are two kinds of helper macros: |
46 * -# The simple macros. | 46 * -# The simple macros. |
47 * - ATTRIBUTE_HELPER_HEADER_LIB(type,lib) for libraries | 47 * - ATTRIBUTE_HELPER_HEADER_LIB(type,lib) for classes that can be used by o ther modules |
48 * - ATTRIBUTE_HELPER_CPP_LIB(type,lib) for libraries | 48 * - ATTRIBUTE_HELPER_CPP_LIB(type,lib) for classes that can be used by othe r modules |
49 * or | 49 * or |
50 * - ATTRIBUTE_HELPER_HEADER(type,lib) for self contained programs | 50 * - ATTRIBUTE_HELPER_HEADER(type,lib) for classes that are only used in the this executable unit |
51 * - ATTRIBUTE_HELPER_CPP(type,lib) for self contained programs | 51 * - ATTRIBUTE_HELPER_CPP(type,lib) for classes that are only used in the th is executable unit |
Peter Barnes
2018/04/17 00:04:12
Need to clarify what's a library, and what's a sel
ammo6818-vandals.uidaho.edu
2018/05/02 05:06:31
Changed to:
* There are two kinds of helper macr
| |
52 * -# The more complex macros. | 52 * -# The more complex macros. |
53 * | 53 * |
54 * The simple macros are implemented in terms of the complex | 54 * The simple macros are implemented in terms of the complex |
55 * macros and should generally be preferred over the complex macros. | 55 * macros and should generally be preferred over the complex macros. |
56 * | 56 * |
57 * \note | 57 * \note |
58 * Because these macros generate class and function definitions, it's | 58 * Because these macros generate class and function definitions, it's |
59 * difficult to document the results directly. Instead, we use a | 59 * difficult to document the results directly. Instead, we use a |
60 * set of functions in print-introspected-doxygen.cc to generate | 60 * set of functions in print-introspected-doxygen.cc to generate |
61 * most of the APi documentation. When using these macros, | 61 * most of the APi documentation. When using these macros, |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
203 virtual Ptr<AttributeValue> Copy (void) const; \ | 203 virtual Ptr<AttributeValue> Copy (void) const; \ |
204 virtual std::string \ | 204 virtual std::string \ |
205 SerializeToString (Ptr<const AttributeChecker> checker) const; \ | 205 SerializeToString (Ptr<const AttributeChecker> checker) const; \ |
206 virtual bool \ | 206 virtual bool \ |
207 DeserializeFromString (std::string value, \ | 207 DeserializeFromString (std::string value, \ |
208 Ptr<const AttributeChecker> checker); \ | 208 Ptr<const AttributeChecker> checker); \ |
209 private: \ | 209 private: \ |
210 type m_value; \ | 210 type m_value; \ |
211 }; | 211 }; |
212 | 212 |
213 #define ATTRIBUTE_VALUE_DEFINE_WITH_NAME(type,name) \ | 213 #define ATTRIBUTE_VALUE_DEFINE_WITH_NAME(type,name) \ |
Peter Barnes
2018/04/17 00:04:12
Can't this be implemented as
#define ATTRIBUTE_VA
ammo6818-vandals.uidaho.edu
2018/05/02 05:06:31
No,there is a subtle difference on line 191.
| |
214 class name ## Value : public AttributeValue \ | 214 class name ## Value : public AttributeValue \ |
215 { \ | 215 { \ |
216 public: \ | 216 public: \ |
217 name ## Value (); \ | 217 name ## Value (); \ |
218 name ## Value (const type &value); \ | 218 name ## Value (const type &value); \ |
219 void Set (const type &value); \ | 219 void Set (const type &value); \ |
220 type Get (void) const; \ | 220 type Get (void) const; \ |
221 template <typename T> \ | 221 template <typename T> \ |
222 bool GetAccessor (T &value) const { \ | 222 bool GetAccessor (T &value) const { \ |
223 value = T (m_value); \ | 223 value = T (m_value); \ |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
309 * \param [in] type The underlying type name | 309 * \param [in] type The underlying type name |
310 * \param [in] name The token to use in defining the accessor name. | 310 * \param [in] name The token to use in defining the accessor name. |
311 * | 311 * |
312 * This macro implements the \p typeValue class methods | 312 * This macro implements the \p typeValue class methods |
313 * (including the \p typeValue::SerializeToString | 313 * (including the \p typeValue::SerializeToString |
314 * and \p typeValue::DeserializeFromString methods). | 314 * and \p typeValue::DeserializeFromString methods). |
315 * | 315 * |
316 * Typically invoked in the source file | 316 * Typically invoked in the source file |
317 */ | 317 */ |
318 #define ATTRIBUTE_VALUE_IMPLEMENT_WITH_NAME_LIB(type,name,lib) \ | 318 #define ATTRIBUTE_VALUE_IMPLEMENT_WITH_NAME_LIB(type,name,lib) \ |
319 ATTRIBUTE_VALUE_IMPLEMENT_WITH_NAME(type,name) | 319 ATTRIBUTE_VALUE_IMPLEMENT_WITH_NAME(type,name) |
Peter Barnes
2018/04/17 00:04:12
All the implementation macros discard the lib argu
ammo6818-vandals.uidaho.edu
2018/05/02 05:06:31
This was done to make it easier for the developers
| |
320 | 320 |
321 #define ATTRIBUTE_VALUE_IMPLEMENT_WITH_NAME(type,name) \ | 321 #define ATTRIBUTE_VALUE_IMPLEMENT_WITH_NAME(type,name) \ |
322 name ## Value::name ## Value () \ | 322 name ## Value::name ## Value () \ |
323 : m_value () {} \ | 323 : m_value () {} \ |
324 name ## Value::name ## Value (const type &value) \ | 324 name ## Value::name ## Value (const type &value) \ |
325 : m_value (value) {} \ | 325 : m_value (value) {} \ |
326 void name ## Value::Set (const type &v) { \ | 326 void name ## Value::Set (const type &v) { \ |
327 m_value = v; \ | 327 m_value = v; \ |
328 } \ | 328 } \ |
329 type name ## Value::Get (void) const { \ | 329 type name ## Value::Get (void) const { \ |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
464 #define ATTRIBUTE_HELPER_CPP_LIB(type,lib) \ | 464 #define ATTRIBUTE_HELPER_CPP_LIB(type,lib) \ |
465 ATTRIBUTE_CHECKER_IMPLEMENT_LIB (type,lib); \ | 465 ATTRIBUTE_CHECKER_IMPLEMENT_LIB (type,lib); \ |
466 ATTRIBUTE_VALUE_IMPLEMENT_LIB (type,lib) | 466 ATTRIBUTE_VALUE_IMPLEMENT_LIB (type,lib) |
467 | 467 |
468 #define ATTRIBUTE_HELPER_CPP(type) \ | 468 #define ATTRIBUTE_HELPER_CPP(type) \ |
469 ATTRIBUTE_CHECKER_IMPLEMENT (type); \ | 469 ATTRIBUTE_CHECKER_IMPLEMENT (type); \ |
470 ATTRIBUTE_VALUE_IMPLEMENT (type) | 470 ATTRIBUTE_VALUE_IMPLEMENT (type) |
471 | 471 |
472 | 472 |
473 #endif /* ATTRIBUTE_HELPER_H */ | 473 #endif /* ATTRIBUTE_HELPER_H */ |
LEFT | RIGHT |