View | Details | Raw Unified | Return to bug 1604
Collapse All | Expand All

(-)a/doc/doxygen.conf (+3 lines)
 Lines 1672-1677    Link Here 
1672
                         ATTRIBUTE_CHECKER_IMPLEMENT \
1672
                         ATTRIBUTE_CHECKER_IMPLEMENT \
1673
                         ATTRIBUTE_CHECKER_IMPLEMENT_WITH_NAME \
1673
                         ATTRIBUTE_CHECKER_IMPLEMENT_WITH_NAME \
1674
                         ATTRIBUTE_CONVERTER_DEFINE \
1674
                         ATTRIBUTE_CONVERTER_DEFINE \
1675
			 ATTRIBUTE_GETDEFAULT_DEFINE \
1676
			 ATTRIBUTE_GETDEFAULT_IMPLEMENT \
1677
			 ATTRIBUTE_GETDEFAULT_IMPLEMENT_WITH_NAME \
1675
                         ATTRIBUTE_HELPER_CPP \
1678
                         ATTRIBUTE_HELPER_CPP \
1676
                         ATTRIBUTE_HELPER_HEADER \
1679
                         ATTRIBUTE_HELPER_HEADER \
1677
                         ATTRIBUTE_VALUE_DEFINE \
1680
                         ATTRIBUTE_VALUE_DEFINE \
(-)a/src/core/model/attribute-helper.h (-12 / +134 lines)
 Lines 22-27    Link Here 
22
22
23
#include "attribute.h"
23
#include "attribute.h"
24
#include "attribute-accessor-helper.h"
24
#include "attribute-accessor-helper.h"
25
#include "config.h"
25
#include <sstream>
26
#include <sstream>
26
#include "fatal-error.h"
27
#include "fatal-error.h"
27
28
 Lines 29-35    Link Here 
29
30
30
/**
31
/**
31
 * \ingroup attribute
32
 * \ingroup attribute
32
 * \defgroup attributehelper Attribute Helper
33
 * \defgroup attributehelper Attribute Helpers
33
 *
34
 *
34
 * All these macros can be used to generate automatically the code
35
 * All these macros can be used to generate automatically the code
35
 * for subclasses of AttributeValue, AttributeAccessor, and, AttributeChecker,
36
 * for subclasses of AttributeValue, AttributeAccessor, and, AttributeChecker,
 Lines 127-134    Link Here 
127
  return Ptr<AttributeChecker> (checker, false);
128
  return Ptr<AttributeChecker> (checker, false);
128
}
129
}
129
130
130
}
131
  
131
132
/**
132
/**
133
 * \ingroup attributehelper
133
 * \ingroup attributehelper
134
 *
134
 *
 Lines 192-199    Link Here 
192
                             Ptr<const AttributeChecker> checker);      \
192
                             Ptr<const AttributeChecker> checker);      \
193
  private:                                                              \
193
  private:                                                              \
194
    type m_value;                                                       \
194
    type m_value;                                                       \
195
  };
195
  }
196
197
196
198
/**
197
/**
199
 * \ingroup attributehelper
198
 * \ingroup attributehelper
 Lines 247-252    Link Here 
247
  class type ## Checker : public AttributeChecker {};                   \
246
  class type ## Checker : public AttributeChecker {};                   \
248
  Ptr<const AttributeChecker> Make ## type ## Checker (void)
247
  Ptr<const AttributeChecker> Make ## type ## Checker (void)
249
248
249
/**
250
 * \ingroup attributehelper
251
 *
252
 * Declare the Config::GetDefaultValue<>() specializations for \p type.
253
 *
254
 * \param type The return type.
255
 *
256
 * This macro declares the Config::GetDefaultValue<>() specialization
257
 * returning the current default configuration value of an attribute,
258
 * as a \c type.  If the attribute at the configuration path is not
259
 * compatible with the requested type, the function will raise a
260
 * fatal error.
261
 *
262
 * This macro is typically invoked in the class header file.
263
 *
264
 * \note This macro must be invoked from <tt>namespace ns3</tt>.
265
 *
266
 * \see
267
 *   GetDefaultValue<>()
268
 */
269
#define ATTRIBUTE_GETDEFAULT_DEFINE(type)                               \
270
  namespace Config {                                                    \
271
    template<> type                                                     \
272
      GetDefaultValue<type> (const std::string attributePath);          \
273
  } /* namespace Config */
274
250
275
251
/**
276
/**
252
 * \ingroup attributehelper
277
 * \ingroup attributehelper
 Lines 345-356    Link Here 
345
  Ptr<const AttributeChecker> Make ## type ## Checker (void) {          \
370
  Ptr<const AttributeChecker> Make ## type ## Checker (void) {          \
346
    return MakeSimpleAttributeChecker<type ## Value,type ## Checker>    \
371
    return MakeSimpleAttributeChecker<type ## Value,type ## Checker>    \
347
      (# type "Value", name);                                           \
372
      (# type "Value", name);                                           \
348
  }                                                                     \
373
  }
374
375
376
namespace Config {
377
  
378
/**
379
 * \ingroup config
380
 * Config::GetDefaultValue<>() helper to fetch an attribute path as
381
 * the base AttributeValue.
382
 *
383
 * \param attributePath The configuration path for the attribute.
384
 * \returns The AttributeValue.
385
 *
386
 * \internal
387
 * This is declared in attribute-helper.h to break an include cycle.
388
 * The implementation is in config.cc.
389
 */
390
Ptr<const AttributeValue>
391
GetDefaultAttributeValue (const std::string attributePath);
392
  
393
}  // namespace Config
394
349
395
350
/**
396
/**
351
 * \ingroup attributehelper
397
 * \ingroup attributehelper
352
 *
398
 *
353
 * Declare the attribute value, accessor and checkers for class \p type
399
 * Define the Config::GetDefaultValue<>() specialization for the attribute
400
 * value class \c \typeValue, for underlying class \p type.
401
 *
402
 * \param type The underlying type name.
403
 * \param typeValue The derived AttributeValue class corresponding to
404
 * \c type.
405
 *
406
 * This macro implements the Config::GetDefaultValue<>() specialization
407
 * returning the current default configuration value of an attribute
408
 * as a \c type.  If the attribute at the configuration path is not
409
 * compatible with the requested type, the function will raise a
410
 * fatal error.
411
 *
412
 * This macro is typically invoked in the source file.
413
 *
414
 * \note This macro must be invoked from <tt>namespace ns3</tt>.
415
 *
416
 * \see Config::GetDefaultValue<>()
417
 */
418
#define ATTRIBUTE_GETDEFAULT_IMPLEMENT_WITH_NAME(type,typeValue)        \
419
  namespace Config {                                                    \
420
    template<> type                                                     \
421
      GetDefaultValue<type> (const std::string attributePath)           \
422
      {                                                                 \
423
        Ptr<const AttributeValue> attrValue =                           \
424
          GetDefaultAttributeValue (attributePath);                     \
425
        Ptr<const typeValue> attr =                                     \
426
          DynamicCast<const typeValue> (attrValue);                     \
427
        if (!attr) {                                                    \
428
          NS_FATAL_ERROR ("Unable to convert attribute \""              \
429
                          << attributePath << "\" to type "             \
430
                          << #typeValue );                              \
431
        }                                                               \
432
        return attr->Get ();                                            \
433
      }                                                                 \
434
  } /* namespace Config */
435
436
437
/**
438
 * \ingroup attributehelper
439
 *
440
 * Define the Config::GetDefaultValue<>() specialization for the attribute
441
 * value class \p \<Name>Value, for underlying class \p Name.
442
 *
443
 * \param Name The underlying type name.
444
 *
445
 * This macro implements the Config::GetDefaultValue<>() specialization
446
 * returning the current default configuration value of an attribute,
447
 * as a \c Name.  If the attribute at the configuration path is not
448
 * compatible with the requested type, the function will raise a
449
 * fatal error.
450
 *
451
 * This macro is typically invoked in the source file.
452
 *
453
 * \note This macro must be invoked from <tt>namespace ns3</tt>.
454
 *
455
 * \see Config::GetDefaultValue<>()
456
 */
457
#define ATTRIBUTE_GETDEFAULT_IMPLEMENT(Name)                            \
458
  ATTRIBUTE_GETDEFAULT_IMPLEMENT_WITH_NAME(Name, Name ## Value)
459
460
/**
461
 * \ingroup attributehelper
462
 *
463
 * Declare the attribute value, accessor, checkers and
464
 * Config::GetDefaultValue<>() specialization for class \p type
354
 *
465
 *
355
 * \param type the name of the class
466
 * \param type the name of the class
356
 *
467
 *
 Lines 363-382    Link Here 
363
 *   - The AttributeChecker class \p \<type>Checker
474
 *   - The AttributeChecker class \p \<type>Checker
364
 *     and the \c MakeTypeChecker function,
475
 *     and the \c MakeTypeChecker function,
365
 *
476
 *
477
 *   - The Config::GetDefaultValue<>() specialization for getting the default
478
 *     configuration value of an attribute as a \p type,
479
 *
366
 * for class \p type.
480
 * for class \p type.
367
 *
481
 *
368
 * This macro should be invoked outside of the class
482
 * This macro should be invoked outside of the class
369
 * declaration in its public header.
483
 * declaration in its public header, normally in <tt>namespace ns3<tt>.
370
 */
484
 */
371
#define ATTRIBUTE_HELPER_HEADER(type)                                   \
485
#define ATTRIBUTE_HELPER_HEADER(type)                                   \
372
  ATTRIBUTE_VALUE_DEFINE (type);                                        \
486
  ATTRIBUTE_VALUE_DEFINE (type);                                        \
373
  ATTRIBUTE_ACCESSOR_DEFINE (type);                                     \
487
  ATTRIBUTE_ACCESSOR_DEFINE (type);                                     \
374
  ATTRIBUTE_CHECKER_DEFINE (type);
488
  ATTRIBUTE_CHECKER_DEFINE (type);                                      \
489
  ATTRIBUTE_GETDEFAULT_DEFINE (type)
375
490
376
/**
491
/**
377
 * \ingroup attributehelper
492
 * \ingroup attributehelper
378
 *
493
 *
379
 * Define the attribute value, accessor and checkers for class \p type
494
 * Define the attribute value, accessor, checkers and
495
 * Config::GetDefaultValue<>() specialization for class \p type
380
 *
496
 *
381
 * \param type the name of the class
497
 * \param type the name of the class
382
 *
498
 *
 Lines 386-398    Link Here 
386
 *
502
 *
387
 *   - The \c MakeTypeChecker function,
503
 *   - The \c MakeTypeChecker function,
388
 *
504
 *
505
 *   - The Config::GetDefaultValue<>() specialization,
506
 *
389
 * for class \p type.
507
 * for class \p type.
390
 *
508
 *
391
 * This macro should be invoked from the class implementation file.
509
 * This macro should be invoked from the class implementation file,
510
 * normally in <tt>namespace ns3</tt>.
392
 */
511
 */
393
#define ATTRIBUTE_HELPER_CPP(type)                                      \
512
#define ATTRIBUTE_HELPER_CPP(type)                                      \
394
  ATTRIBUTE_CHECKER_IMPLEMENT (type);                                   \
513
  ATTRIBUTE_CHECKER_IMPLEMENT (type);                                   \
395
  ATTRIBUTE_VALUE_IMPLEMENT (type);
514
  ATTRIBUTE_VALUE_IMPLEMENT (type);                                     \
515
  ATTRIBUTE_GETDEFAULT_IMPLEMENT (type)
396
516
517
  
518
}  // namespace ns3
397
519
398
#endif /* ATTRIBUTE_HELPER_H */
520
#endif /* ATTRIBUTE_HELPER_H */
(-)a/src/core/model/callback.h (-1 / +16 lines)
 Lines 1718-1730    Link Here 
1718
  virtual bool DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker);
1718
  virtual bool DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker);
1719
private:
1719
private:
1720
  CallbackBase m_value;                 //!< the CallbackBase
1720
  CallbackBase m_value;                 //!< the CallbackBase
1721
};
1721
1722
};  // class CallbackValue
1722
1723
1723
ATTRIBUTE_ACCESSOR_DEFINE (Callback);
1724
ATTRIBUTE_ACCESSOR_DEFINE (Callback);
1724
ATTRIBUTE_CHECKER_DEFINE (Callback);
1725
ATTRIBUTE_CHECKER_DEFINE (Callback);
1726
/*
1727
  Can't implement Config::GetDefault<> specialization for
1728
  Callback<R, T1, T2, T3, T4, T5, T6, T7, T8, T9>
1729
1730
  This ends up being a function partial specialization,
1731
  which isn't allowed.
1732
            
1733
ATTRIBUTE_GETDEFAULT_DEFINE (Callback);
1734
*/
1725
1735
1726
} // namespace ns3
1736
} // namespace ns3
1727
1737
1738
1739
/********************************************************************
1740
 *  Implementation of templates defined above
1741
 ********************************************************************/
1742
1728
namespace ns3 {
1743
namespace ns3 {
1729
1744
1730
template <typename T>
1745
template <typename T>
(-)a/src/core/model/command-line.h (+4 lines)
 Lines 197-202    Link Here 
197
 *       exit (-1);
197
 *       exit (-1);
198
 *     }
198
 *     }
199
 * \endcode
199
 * \endcode
200
 *
201
 * \todo Treat non-option arguments like traditional \c getopt(), by
202
 * permuting non-option arguments to the end and providing a query function
203
 * for the equivalent of \c optind.
200
 */
204
 */
201
class CommandLine
205
class CommandLine
202
{
206
{
(-)a/src/core/model/config.cc (+44 lines)
 Lines 776-781    Link Here 
776
  return Singleton<ConfigImpl>::Get ()->GetRootNamespaceObject (i);
776
  return Singleton<ConfigImpl>::Get ()->GetRootNamespaceObject (i);
777
}
777
}
778
778
779
/**
780
 * \ingroup config
781
 * GetDefaultValue<>() helper to fetch the TypeId::AttributeInformation.
782
 *
783
 * \param attributePath The configuration path for the attribute.
784
 * \returns The TypeId::AttributeInformation.
785
 *
786
 * This is internal to the Config system.
787
 */
788
Ptr<struct TypeId::AttributeInformation>
789
GetAttributeInformation(const std::string attributePath)
790
{
791
  NS_LOG_FUNCTION (attributePath);
792
  // Attribute name is last token
793
  size_t colon = attributePath.rfind ("::");
794
  const std::string typeName = attributePath.substr (0, colon);
795
  NS_LOG_DEBUG ("typeName: '" << typeName << "', colon: " << colon);
796
  
797
  TypeId tid;
798
  if (!TypeId::LookupByNameFailSafe (typeName, &tid))
799
    {
800
      NS_FATAL_ERROR ("Unknown type=" << typeName);
801
    }
802
803
  const std::string attrName = attributePath.substr (colon + 2);
804
  Ptr<struct TypeId::AttributeInformation> info =
805
    Create<struct TypeId::AttributeInformation> ();
806
  if (!tid.LookupAttributeByName (attrName, PeekPointer (info)) )
807
    {
808
      NS_FATAL_ERROR ("Attribute not found: " << attributePath);
809
    }
810
  return info;
811
}
812
813
Ptr<const AttributeValue>
814
GetDefaultAttributeValue (const std::string attributePath)
815
{
816
  Ptr<struct TypeId::AttributeInformation> info =
817
    GetAttributeInformation (attributePath);
818
  Ptr<const AttributeValue> attr = info->initialValue;
819
  return attr;
820
}
821
822
779
} // namespace Config
823
} // namespace Config
780
824
781
} // namespace ns3
825
} // namespace ns3
(-)a/src/core/model/config.h (+36 lines)
 Lines 247-252    Link Here 
247
 */
247
 */
248
Ptr<Object> GetRootNamespaceObject (uint32_t i);
248
Ptr<Object> GetRootNamespaceObject (uint32_t i);
249
249
250
/**
251
 * \ingroup config
252
 * Get the current default value for an attribute.
253
 *
254
 * The current default is the initial value which would be
255
 * used by new instances of the type, including any
256
 * CommandLine or environment variable configuration.
257
 *
258
 * \tparam R The type to return.
259
 * \param attributePath The configuration path for the attribute.
260
 * \returns The default value.
261
 *
262
 * GetDefaultValue<>() will raise a fatal error if the attribute
263
 * can't be converted to the desired type.
264
 *
265
 * \internal
266
 *
267
 * GetDefaultValue<>() proceeds by first looking up the default value as a base
268
 * AttributeValue, then attempting to upcast to the derived AttributeValue
269
 * type associated with the requested return type, then finally
270
 * getting the default value from the derived AttributeValue.
271
 *
272
 * For example, if the desired return type is an ns3::DataRate, the
273
 * base AttributeValue will be upcast to a DataRateValue.  If this fails
274
 * GetDefaultValue<>() will raise a fatal error.
275
 *
276
 * There is no generic template declaration; only specializations
277
 * of this template exist.  Specializations are declared and implemented
278
 * by the ATTRIBUTE_GETDEFAULT_DEFINE() and ATTRIBUTE_GETDEFAULT_IMPLEMENT()
279
 * macros, which are normally invoked by the ATTRIBUTE_HELPER_HEADER() and
280
 * ATTRIBUTE_HELPER_CPP() macros.
281
 */
282
template <typename R>
283
R
284
GetDefaultValue (const std::string attributePath);
285
250
} // namespace Config
286
} // namespace Config
251
287
252
} // namespace ns3
288
} // namespace ns3
(-)a/src/core/model/double.cc (+1 lines)
 Lines 27-32    Link Here 
27
NS_LOG_COMPONENT_DEFINE ("Double");
27
NS_LOG_COMPONENT_DEFINE ("Double");
28
28
29
ATTRIBUTE_VALUE_IMPLEMENT_WITH_NAME (double, Double);
29
ATTRIBUTE_VALUE_IMPLEMENT_WITH_NAME (double, Double);
30
ATTRIBUTE_GETDEFAULT_IMPLEMENT_WITH_NAME (double, DoubleValue);
30
31
31
namespace internal {
32
namespace internal {
32
33
(-)a/src/core/model/double.h (+1 lines)
 Lines 34-39    Link Here 
34
 */
34
 */
35
ATTRIBUTE_VALUE_DEFINE_WITH_NAME (double, Double);
35
ATTRIBUTE_VALUE_DEFINE_WITH_NAME (double, Double);
36
ATTRIBUTE_ACCESSOR_DEFINE (Double);
36
ATTRIBUTE_ACCESSOR_DEFINE (Double);
37
ATTRIBUTE_GETDEFAULT_DEFINE (double);
37
38
38
template <typename T>
39
template <typename T>
39
Ptr<const AttributeChecker> MakeDoubleChecker (void);
40
Ptr<const AttributeChecker> MakeDoubleChecker (void);
(-)a/src/core/model/global-value.h (-8 / +24 lines)
 Lines 32-49    Link Here 
32
/**
32
/**
33
 * \ingroup Core
33
 * \ingroup Core
34
 *
34
 *
35
 * \brief hold a so-called 'global value'.
35
 * \brief Hold a so-called 'global value'.
36
 *
37
 * A GlobalValue will get its value from (in order):
38
 *   - The initial value configured where it is defined,
39
 *   - From the \c NS_GLOBAL_VALUE environment variable,
40
 *   - From the command line,
41
 *   - By explicit call to SetValue() or Bind().
36
 *
42
 *
37
 * Instances of this class are expected to be allocated as static 
43
 * Instances of this class are expected to be allocated as static 
38
 * global variables and should be used to store configurable global state.
44
 * global variables and should be used to store configurable global state.
39
 * GlobalValues can be set directly by calling ns3::GlobalValue::SetValue
45
 * For example:
40
 * but they can also be set through the NS_GLOBAL_VALUE environment variable.
46
 * \code
41
 * For example, NS_GLOBAL_VALUE='Name=Value;OtherName=OtherValue;' would set
47
 *   // source.cc:
42
 * global values Name and OtherName to Value and OtherValue respectively. 
48
 *   static GlobalValue g_myGlobal =
49
 *     GlobalValue ("myGlobal", "My global value for ...",
50
 *                  IntegerValue (12),
51
 *                  MakeIntegerChecker ());
52
 * \endcode
43
 *
53
 *
44
 * Users of the ns3::CommandLine class also get the ability to set global 
54
 * GlobalValues can be set directly by calling GlobalValue::SetValue()
45
 * values through commandline arguments to their program: --Name=Value will
55
 * but they can also be set through the \c NS_GLOBAL_VALUE environment variable.
46
 * set global value Name to Value.
56
 * For example, \c NS_GLOBAL_VALUE='Name=Value;OtherName=OtherValue;' would set
57
 * global values \c Name and \c OtherName to \c Value and \c OtherValue,
58
 * respectively. 
59
 *
60
 * Users of the CommandLine class also get the ability to set global 
61
 * values through command line arguments to their program:
62
 * \c --Name=Value will set global value \c Name to \c Value.
47
 */
63
 */
48
class GlobalValue
64
class GlobalValue
49
{
65
{
(-)a/src/core/model/integer.cc (+1 lines)
 Lines 27-32    Link Here 
27
NS_LOG_COMPONENT_DEFINE ("Integer");
27
NS_LOG_COMPONENT_DEFINE ("Integer");
28
28
29
ATTRIBUTE_VALUE_IMPLEMENT_WITH_NAME (int64_t, Integer);
29
ATTRIBUTE_VALUE_IMPLEMENT_WITH_NAME (int64_t, Integer);
30
ATTRIBUTE_GETDEFAULT_IMPLEMENT_WITH_NAME (int64_t, IntegerValue);
30
31
31
namespace internal {
32
namespace internal {
32
33
(-)a/src/core/model/integer.h (+1 lines)
 Lines 37-42    Link Here 
37
 */
37
 */
38
ATTRIBUTE_VALUE_DEFINE_WITH_NAME (int64_t, Integer);
38
ATTRIBUTE_VALUE_DEFINE_WITH_NAME (int64_t, Integer);
39
ATTRIBUTE_ACCESSOR_DEFINE (Integer);
39
ATTRIBUTE_ACCESSOR_DEFINE (Integer);
40
ATTRIBUTE_GETDEFAULT_DEFINE (int64_t);
40
41
41
template <typename T>
42
template <typename T>
42
Ptr<const AttributeChecker> MakeIntegerChecker (void);
43
Ptr<const AttributeChecker> MakeIntegerChecker (void);
(-)a/src/core/model/nstime.h (+1 lines)
 Lines 919-924    Link Here 
919
 * \brief Attribute for objects of type ns3::Time
919
 * \brief Attribute for objects of type ns3::Time
920
 */
920
 */
921
ATTRIBUTE_VALUE_DEFINE (Time);
921
ATTRIBUTE_VALUE_DEFINE (Time);
922
ATTRIBUTE_GETDEFAULT_DEFINE (Time);
922
923
923
/**
924
/**
924
 *  Attribute accessor function for Time
925
 *  Attribute accessor function for Time
(-)a/src/core/model/type-id.h (-2 / +3 lines)
 Lines 60-66    Link Here 
60
    ATTR_CONSTRUCT = 1<<2, /**< The attribute can be written at construction-time */
60
    ATTR_CONSTRUCT = 1<<2, /**< The attribute can be written at construction-time */
61
    ATTR_SGC = ATTR_GET | ATTR_SET | ATTR_CONSTRUCT, /**< The attribute can be read, and written at any time */
61
    ATTR_SGC = ATTR_GET | ATTR_SET | ATTR_CONSTRUCT, /**< The attribute can be read, and written at any time */
62
  };
62
  };
63
  struct AttributeInformation {
63
  struct AttributeInformation : public SimpleRefCount<AttributeInformation>
64
  {
64
    std::string name;
65
    std::string name;
65
    std::string help;
66
    std::string help;
66
    uint32_t flags;
67
    uint32_t flags;
 Lines 412-418    Link Here 
412
 * \brief hold objects of type ns3::TypeId
413
 * \brief hold objects of type ns3::TypeId
413
 */
414
 */
414
415
415
416
  
416
ATTRIBUTE_HELPER_HEADER (TypeId);
417
ATTRIBUTE_HELPER_HEADER (TypeId);
417
418
418
} // namespace ns3 
419
} // namespace ns3 
(-)a/src/core/test/attribute-test-suite.cc (-2 / +14 lines)
 Lines 72-79    Link Here 
72
{
72
{
73
  return is;
73
  return is;
74
}
74
}
75
ATTRIBUTE_HELPER_HEADER (ValueClassTest);
75
76
ATTRIBUTE_HELPER_CPP (ValueClassTest);
76
ATTRIBUTE_VALUE_DEFINE (ValueClassTest);
77
ATTRIBUTE_ACCESSOR_DEFINE (ValueClassTest);
78
ATTRIBUTE_CHECKER_DEFINE (ValueClassTest);
79
80
namespace ns3 {
81
ATTRIBUTE_GETDEFAULT_DEFINE (ValueClassTest);
82
}
83
84
ATTRIBUTE_CHECKER_IMPLEMENT (ValueClassTest);
85
ATTRIBUTE_VALUE_IMPLEMENT (ValueClassTest);
86
namespace ns3 {
87
ATTRIBUTE_GETDEFAULT_IMPLEMENT (ValueClassTest);
88
}
77
89
78
class Derived : public Object
90
class Derived : public Object
79
{
91
{
(-)a/src/internet/model/tcp-option-rfc793.h (-1 / +1 lines)
 Lines 20-26    Link Here 
20
#ifndef TCPOPTIONRFC793_H
20
#ifndef TCPOPTIONRFC793_H
21
#define TCPOPTIONRFC793_H
21
#define TCPOPTIONRFC793_H
22
22
23
#include "tcp-option.h"
23
#include "ns3/tcp-option.h"
24
24
25
namespace ns3 {
25
namespace ns3 {
26
26
(-)a/src/internet/model/tcp-option-ts.h (-1 / +1 lines)
 Lines 21-27    Link Here 
21
#ifndef TCP_OPTION_TS_H
21
#ifndef TCP_OPTION_TS_H
22
#define TCP_OPTION_TS_H
22
#define TCP_OPTION_TS_H
23
23
24
#include "tcp-option.h"
24
#include "ns3/tcp-option.h"
25
#include "ns3/timer.h"
25
#include "ns3/timer.h"
26
26
27
namespace ns3 {
27
namespace ns3 {
(-)a/src/internet/model/tcp-option-winscale.h (-1 / +1 lines)
 Lines 22-28    Link Here 
22
#ifndef TCP_OPTION_WINSCALE_H
22
#ifndef TCP_OPTION_WINSCALE_H
23
#define TCP_OPTION_WINSCALE_H
23
#define TCP_OPTION_WINSCALE_H
24
24
25
#include "tcp-option.h"
25
#include "ns3/tcp-option.h"
26
26
27
namespace ns3 {
27
namespace ns3 {
28
28
(-)a/src/internet/test/tcp-header-test.cc (-2 / +1 lines)
 Lines 23-30    Link Here 
23
#include "ns3/core-module.h"
23
#include "ns3/core-module.h"
24
#include "ns3/tcp-header.h"
24
#include "ns3/tcp-header.h"
25
#include "ns3/buffer.h"
25
#include "ns3/buffer.h"
26
26
#include "ns3-private/tcp-option-rfc793.h"
27
#include "../src/internet/model/tcp-option-rfc793.h"
28
27
29
namespace ns3 {
28
namespace ns3 {
30
29
(-)a/src/internet/test/tcp-option-test.cc (-2 / +2 lines)
 Lines 20-27    Link Here 
20
#include "ns3/test.h"
20
#include "ns3/test.h"
21
#include "ns3/core-module.h"
21
#include "ns3/core-module.h"
22
#include "ns3/tcp-option.h"
22
#include "ns3/tcp-option.h"
23
#include "../src/internet/model/tcp-option-winscale.h"
23
#include "ns3-private/tcp-option-winscale.h"
24
#include "../src/internet/model/tcp-option-ts.h"
24
#include "ns3-private/tcp-option-ts.h"
25
25
26
#include <string.h>
26
#include <string.h>
27
27
(-)a/src/internet/test/tcp-timestamp-test.cc (-1 / +1 lines)
 Lines 45-51    Link Here 
45
#include "ns3/udp-l4-protocol.h"
45
#include "ns3/udp-l4-protocol.h"
46
#include "ns3/tcp-l4-protocol.h"
46
#include "ns3/tcp-l4-protocol.h"
47
47
48
#include "../src/internet/model/tcp-option-ts.h"
48
#include "ns3-private/tcp-option-ts.h"
49
49
50
namespace ns3 {
50
namespace ns3 {
51
51
(-)a/src/internet/wscript (+7 lines)
 Lines 244-249    Link Here 
244
        'test/rtt-test.cc',
244
        'test/rtt-test.cc',
245
        'test/codel-queue-test-suite.cc',
245
        'test/codel-queue-test-suite.cc',
246
        ]
246
        ]
247
    privateheaders = bld(features='ns3privateheader')
248
    privateheaders.module = 'internet'
249
    privateheaders.source = [
250
        'model/tcp-option-winscale.h',
251
        'model/tcp-option-ts.h',
252
        'model/tcp-option-rfc793.h',
253
        ]
247
    headers = bld(features='ns3header')
254
    headers = bld(features='ns3header')
248
    headers.module = 'internet'
255
    headers.module = 'internet'
249
    headers.source = [
256
    headers.source = [
(-)a/src/mesh/model/dot11s/ie-dot11s-id.cc (-2 / +5 lines)
 Lines 151-158    Link Here 
151
  return is;
151
  return is;
152
}
152
}
153
153
154
ATTRIBUTE_HELPER_CPP (IeMeshId);
154
ATTRIBUTE_VALUE_IMPLEMENT (IeMeshId);
155
155
ATTRIBUTE_CHECKER_IMPLEMENT (IeMeshId);
156
156
157
} // namespace dot11s
157
} // namespace dot11s
158
159
ATTRIBUTE_GETDEFAULT_IMPLEMENT (ns3::dot11s::IeMeshId);
160
158
} // namespace ns3
161
} // namespace ns3
(-)a/src/mesh/model/dot11s/ie-dot11s-id.h (-5 / +6 lines)
 Lines 58-69    Link Here 
58
58
59
std::ostream &operator << (std::ostream &os, const IeMeshId &meshId);
59
std::ostream &operator << (std::ostream &os, const IeMeshId &meshId);
60
60
61
/**
61
ATTRIBUTE_VALUE_DEFINE (IeMeshId);
62
 * \class ns3::IeMeshIdValue
62
ATTRIBUTE_ACCESSOR_DEFINE (IeMeshId);
63
 * \brief hold objects of type ns3::IeMeshId
63
ATTRIBUTE_CHECKER_DEFINE (IeMeshId);
64
 */
65
64
66
ATTRIBUTE_HELPER_HEADER (IeMeshId);
67
} // namespace dot11s
65
} // namespace dot11s
66
  
67
ATTRIBUTE_GETDEFAULT_DEFINE (ns3::dot11s::IeMeshId);
68
  
68
} // namespace ns3
69
} // namespace ns3
69
#endif /* MESH_ID_H */
70
#endif /* MESH_ID_H */
(-)a/src/uan/model/uan-tx-mode.cc (-2 / +1 lines)
 Lines 300-306    Link Here 
300
  return is;
300
  return is;
301
}
301
}
302
302
303
ATTRIBUTE_HELPER_CPP (UanModesList)
303
ATTRIBUTE_HELPER_CPP (UanModesList);
304
  ;
305
304
306
} // namespace ns3
305
} // namespace ns3
(-)a/src/wscript (+92 lines)
 Lines 530-535    Link Here 
530
            return 0
530
            return 0
531
531
532
532
533
@TaskGen.feature('ns3privateheader')
534
@TaskGen.after_method('process_rule')
535
def apply_ns3privateheader(self):
536
    if self.module is None:
537
        raise WafError("'module' missing on ns3headers object %s" % self)
538
    ns3_dir_node = self.bld.path.find_dir("ns3-private")
539
    for filename in set(self.to_list(self.source)):
540
        src_node = self.path.find_resource(filename)
541
        if src_node is None:
542
            raise WafError("source ns3 header file %s not found" % (filename,))
543
        dst_node = ns3_dir_node.find_or_declare(src_node.name)
544
        assert dst_node is not None
545
        task = self.create_task('ns3privateheader')
546
        task.mode = getattr(self, 'mode', 'install')
547
        if task.mode == 'install':
548
            task.set_inputs([src_node])
549
            task.set_outputs([dst_node])
550
        else:
551
            task.header_to_remove = dst_node
552
    self.headers = set(self.to_list(self.source))
553
    self.source = '' # tell WAF not to process these files further
554
555
class ns3privateheader_task(Task.Task):
556
    before = 'cxx gen_ns3_module_header'
557
    after = 'ns3_header'
558
    color = 'BLUE'
559
560
    def __str__(self):
561
        "string to display to the user"
562
        env = self.env
563
        src_str = ' '.join([a.nice_path(env) for a in self.inputs])
564
        tgt_str = ' '.join([a.nice_path(env) for a in self.outputs])
565
        if self.outputs: sep = ' -> '
566
        else: sep = ''
567
        if self.mode == 'remove':
568
            return 'rm-ns3-header %s\n' % (self.header_to_remove.abspath(),)
569
        return 'install-ns3-header: %s%s%s\n' % (src_str, sep, tgt_str)
570
571
    def __repr__(self):
572
        return str(self)
573
574
    def uid(self):
575
        try:
576
            return self.uid_
577
        except AttributeError:
578
            m = Utils.md5()
579
            up = m.update
580
            up(self.__class__.__name__.encode())
581
            for x in self.inputs + self.outputs:
582
                up(x.abspath().encode())
583
            up(self.mode)
584
            if self.mode == 'remove':
585
                up(self.header_to_remove.abspath().encode())
586
            self.uid_ = m.digest()
587
            return self.uid_
588
589
    def runnable_status(self):
590
        if self.mode == 'remove':
591
            if os.path.exists(self.header_to_remove.abspath()):
592
                return Task.RUN_ME
593
            else:
594
                return Task.SKIP_ME
595
        else:
596
            return super(ns3privateheader_task, self).runnable_status()
597
598
    def run(self):
599
        if self.mode == 'install':
600
            assert len(self.inputs) == len(self.outputs)
601
            inputs = [node.abspath() for node in self.inputs]
602
            outputs = [node.abspath() for node in self.outputs]
603
            for src, dst in zip(inputs, outputs):
604
                try:
605
                    os.chmod(dst, 0600)
606
                except OSError:
607
                    pass
608
                shutil.copy2(src, dst)
609
                ## make the headers in builddir read-only, to prevent
610
                ## accidental modification
611
                os.chmod(dst, 0400)
612
            return 0
613
        else:
614
            assert len(self.inputs) == 0
615
            assert len(self.outputs) == 0
616
            out_file_name = self.header_to_remove.abspath()
617
            try:
618
                os.unlink(out_file_name)
619
            except OSError, ex:
620
                if ex.errno != 2:
621
                    raise
622
            return 0
623
624
533
class gen_ns3_module_header_task(Task.Task):
625
class gen_ns3_module_header_task(Task.Task):
534
    before = 'cxx'
626
    before = 'cxx'
535
    after = 'ns3header'
627
    after = 'ns3header'
(-)a/wscript (-2 / +7 lines)
 Lines 331-337    Link Here 
331
            if conf.check_compilation_flag('-march=native'):
331
            if conf.check_compilation_flag('-march=native'):
332
                env.append_value('CXXFLAGS', '-march=native') 
332
                env.append_value('CXXFLAGS', '-march=native') 
333
            env.append_value('CXXFLAGS', '-fstrict-overflow')
333
            env.append_value('CXXFLAGS', '-fstrict-overflow')
334
            if conf.env['CC_VERSION'] == cc_version_warn_strict_overflow:
334
            if conf.env['CC_VERSION'] >= cc_version_warn_strict_overflow:
335
                env.append_value('CXXFLAGS', '-Wstrict-overflow=5')
335
                env.append_value('CXXFLAGS', '-Wstrict-overflow=5')
336
336
337
        if sys.platform == 'win32':
337
        if sys.platform == 'win32':
 Lines 807-812    Link Here 
807
                if ("ns3-%s" % obj.module) not in modules:
807
                if ("ns3-%s" % obj.module) not in modules:
808
                    obj.mode = 'remove' # tell it to remove headers instead of installing 
808
                    obj.mode = 'remove' # tell it to remove headers instead of installing 
809
809
810
            # disable the ns3privateheader_taskgen
811
            if 'ns3privateheader' in getattr(obj, "features", []):
812
                if ("ns3-%s" % obj.module) not in modules:
813
                    obj.mode = 'remove' # tell it to remove headers instead of installing 
814
810
            # disable pcfile taskgens for disabled modules
815
            # disable pcfile taskgens for disabled modules
811
            if 'ns3pcfile' in getattr(obj, "features", []):
816
            if 'ns3pcfile' in getattr(obj, "features", []):
812
                if obj.module not in bld.env.NS3_ENABLED_MODULES:
817
                if obj.module not in bld.env.NS3_ENABLED_MODULES:
 Lines 855-861    Link Here 
855
            program_obj = wutils.find_program(program_name, bld.env)
860
            program_obj = wutils.find_program(program_name, bld.env)
856
            program_obj.use.append('ns3-visualizer')
861
            program_obj.use.append('ns3-visualizer')
857
        for gen in bld.all_task_gen:
862
        for gen in bld.all_task_gen:
858
            if type(gen).__name__ in ['ns3header_taskgen', 'ns3moduleheader_taskgen']:
863
            if type(gen).__name__ in ['ns3header_taskgen', 'ns3privateheader_taskgen', 'ns3moduleheader_taskgen']:
859
                gen.post()
864
                gen.post()
860
        bld.env['PRINT_BUILT_MODULES_AT_END'] = False 
865
        bld.env['PRINT_BUILT_MODULES_AT_END'] = False 
861
866

Return to bug 1604