--- a/src/common/data-rate.cc Fri Feb 15 03:52:56 2008 +0100
+++ b/src/common/data-rate.cc Fri Feb 15 05:38:29 2008 +0100
@@ -125,6 +125,8 @@
namespace ns3 {
+VALUE_HELPER_CPP (DataRate);
+
DataRate::DataRate ()
: m_bps (0)
{}
@@ -173,15 +175,6 @@
return m_bps;
}
-DataRate::DataRate (PValue value)
-{
- *this = ClassValueHelperExtractFrom<DataRate,DataRateValue> (value);
-}
-DataRate::operator PValue () const
-{
- return ClassValueHelperConvertTo<DataRate,DataRateValue> (this);
-}
-
DataRate MakeDataRate (std::string rate)
{
uint64_t bps;
--- a/src/common/data-rate.h Fri Feb 15 03:52:56 2008 +0100
+++ b/src/common/data-rate.h Fri Feb 15 05:38:29 2008 +0100
@@ -28,7 +28,7 @@
#include "ns3/nstime.h"
#include "ns3/default-value.h"
#include "ns3/value.h"
-#include "ns3/class-value-helper.h"
+#include "ns3/value-helper.h"
namespace ns3 {
@@ -80,9 +80,8 @@
* \return The underlying bitrate in bits per second
*/
uint64_t GetBitRate() const;
-
- DataRate (PValue value);
- operator PValue () const;
+
+ VALUE_HELPER_HEADER_1 (DataRate);
private:
uint64_t m_bps;
static uint64_t Parse(const std::string);
@@ -93,16 +92,7 @@
std::ostream &operator << (std::ostream &os, const DataRate &rate);
std::istream &operator >> (std::istream &is, DataRate &rate);
-class DataRateValue : public Value {};
-class DataRateParamSpec : public ParamSpec {};
-
-template <typename T1>
-Ptr<ParamSpec>
-MakeDataRateParamSpec (T1 a1, DataRate initialValue);
-
-template <typename T1, typename T2>
-Ptr<ParamSpec>
-MakeDataRateParamSpec (T1 a1, T2 a2, DataRate initialValue);
+VALUE_HELPER_HEADER_2 (DataRate);
/**
* \param lhs
@@ -130,24 +120,4 @@
} //namespace ns3
-namespace ns3 {
-
-template <typename T1>
-Ptr<ParamSpec>
-MakeDataRateParamSpec (T1 a1, DataRate initialValue)
-{
- return MakeClassValueHelperParamSpec<DataRate,DataRateValue,DataRateParamSpec>
- (a1, initialValue);
-}
-
-template <typename T1, typename T2>
-Ptr<ParamSpec>
-MakeDataRateParamSpec (T1 a1, T2 a2, DataRate initialValue)
-{
- return MakeClassValueHelperParamSpec<DataRate,DataRateValue,DataRateParamSpec>
- (a1, a2, initialValue);
-}
-
-} // namespace ns3
-
#endif /* DATA_RATE_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/core/value-helper.h Fri Feb 15 05:38:29 2008 +0100
@@ -0,0 +1,38 @@
+#ifndef VALUE_HELPER_H
+#define VALUE_HELPER_H
+
+#include "class-value-helper.h"
+
+#define VALUE_HELPER_HEADER_1(type) \
+ type (PValue value); \
+ operator PValue () const;
+
+#define VALUE_HELPER_HEADER_2(type) \
+ class type##Value : public Value {}; \
+ class type##ParamSpec : public ParamSpec {}; \
+ template <typename T1> \
+ Ptr<ParamSpec> Make##type##ParamSpec (T1 a1, \
+ type initialValue) \
+ { \
+ return MakeClassValueHelperParamSpec< type , \
+ type##Value, type##ParamSpec> (a1, initialValue); \
+ } \
+ template <typename T1, typename T2> \
+ Ptr<ParamSpec> Make##type##ParamSpec (T1 a1, T2 a2, \
+ type initialValue) \
+ { \
+ return MakeClassValueHelperParamSpec<type, \
+ type##Value,type##ParamSpec> (a1, a2, initialValue); \
+ }
+
+#define VALUE_HELPER_CPP(type) \
+ type::type (PValue value) \
+ { \
+ *this = ClassValueHelperExtractFrom<type,type##Value> (value); \
+ } \
+ type::operator PValue () const \
+ { \
+ return ClassValueHelperConvertTo<type,type##Value> (this); \
+ }
+
+#endif /* VALUE_HELPER_H */
--- a/src/core/wscript Fri Feb 15 03:52:56 2008 +0100
+++ b/src/core/wscript Fri Feb 15 05:38:29 2008 +0100
@@ -114,5 +114,6 @@
'enum-value.h',
'object-factory.h',
'class-value-helper.h',
+ 'value-helper.h',
]
--- a/src/mobility/rectangle.cc Fri Feb 15 03:52:56 2008 +0100
+++ b/src/mobility/rectangle.cc Fri Feb 15 05:38:29 2008 +0100
@@ -119,14 +119,7 @@
}
-Rectangle::Rectangle (PValue value)
-{
- *this = ClassValueHelperExtractFrom<Rectangle,RectangleValue> (value);
-}
-Rectangle::operator PValue () const
-{
- return ClassValueHelperConvertTo<Rectangle,RectangleValue> (this);
-}
+VALUE_HELPER_CPP (Rectangle);
std::ostream &
operator << (std::ostream &os, const Rectangle &rectangle)
--- a/src/mobility/rectangle.h Fri Feb 15 03:52:56 2008 +0100
+++ b/src/mobility/rectangle.h Fri Feb 15 05:38:29 2008 +0100
@@ -21,7 +21,7 @@
#define RECTANGLE_H
#include "ns3/value.h"
-#include "ns3/class-value-helper.h"
+#include "ns3/value-helper.h"
namespace ns3 {
@@ -62,40 +62,13 @@
double yMin;
double yMax;
- Rectangle (PValue value);
- operator PValue () const;
+ VALUE_HELPER_HEADER_1 (Rectangle);
};
std::ostream &operator << (std::ostream &os, const Rectangle &rectangle);
std::istream &operator >> (std::istream &is, Rectangle &rectangle);
-
-class RectangleValue : public Value {};
-class RectangleParamSpec : public ParamSpec {};
-
-template <typename T1>
-Ptr<ParamSpec> MakeRectangleParamSpec (T1 a1,
- Rectangle initialValue);
-template <typename T1, typename T2>
-Ptr<ParamSpec> MakeRectangleParamSpec (T1 a1, T2 a2,
- Rectangle initialValue);
-
-} // namespace ns3
-
-namespace ns3 {
-
-template <typename T1>
-Ptr<ParamSpec> MakeRectangleParamSpec (T1 a1,
- Rectangle initialValue)
-{
- return MakeClassValueHelperParamSpec<Rectangle,RectangleValue,RectangleParamSpec> (a1, initialValue);
-}
-template <typename T1, typename T2>
-Ptr<ParamSpec> MakeRectangleParamSpec (T1 a1, T2 a2,
- Rectangle initialValue)
-{
- return MakeClassValueHelperParamSpec<Rectangle,RectangleValue,RectangleParamSpec> (a1, a2, initialValue);
-}
+VALUE_HELPER_HEADER_2 (Rectangle);
} // namespace ns3
--- a/src/mobility/vector.cc Fri Feb 15 03:52:56 2008 +0100
+++ b/src/mobility/vector.cc Fri Feb 15 05:38:29 2008 +0100
@@ -24,6 +24,8 @@
namespace ns3 {
+VALUE_HELPER_CPP (Vector);
+
Vector::Vector (double _x, double _y, double _z)
: x (_x),
@@ -37,16 +39,6 @@
z (0.0)
{}
-Vector::Vector (PValue value)
-{
- *this = ClassValueHelperExtractFrom<Vector,VectorValue> (value);
-}
-Vector::operator PValue () const
-{
- return ClassValueHelperConvertTo<Vector,VectorValue> (this);
-}
-
-
double
CalculateDistance (const Vector &a, const Vector &b)
{
--- a/src/mobility/vector.h Fri Feb 15 03:52:56 2008 +0100
+++ b/src/mobility/vector.h Fri Feb 15 05:38:29 2008 +0100
@@ -21,7 +21,7 @@
#define VECTOR_H
#include "ns3/value.h"
-#include "ns3/class-value-helper.h"
+#include "ns3/value-helper.h"
namespace ns3 {
@@ -58,46 +58,16 @@
*/
double z;
- Vector (PValue value);
- operator PValue () const;
+ VALUE_HELPER_HEADER_1 (Vector);
};
double CalculateDistance (const Vector &a, const Vector &b);
-class VectorValue : public Value {};
-class VectorParamSpec : public ParamSpec {};
+VALUE_HELPER_HEADER_2 (Vector);
std::ostream &operator << (std::ostream &os, const Vector &vector);
std::istream &operator >> (std::istream &is, Vector &vector);
-template <typename T1>
-Ptr<ParamSpec>
-MakeVectorParamSpec (T1 a1, const Vector &initialValue);
-
-template <typename T1, typename T2>
-Ptr<ParamSpec>
-MakeVectorParamSpec (T1 a1, T2 a2,
- const Vector &initialValue);
-
-} // namespace ns3
-
-namespace ns3 {
-
-template <typename T1>
-Ptr<ParamSpec>
-MakeVectorParamSpec (T1 a1, const Vector &initialValue)
-{
- return MakeClassValueHelperParamSpec<Vector,VectorValue,VectorParamSpec> (a1, initialValue);
-}
-
-template <typename T1, typename T2>
-Ptr<ParamSpec>
-MakeVectorParamSpec (T1 a1, T2 a2,
- const Vector &initialValue)
-{
- return MakeClassValueHelperParamSpec<Vector,VectorValue,VectorParamSpec> (a1, a2, initialValue);
-}
-
} // namespace ns3
#endif /* VECTOR_H */
--- a/src/node/address.h Fri Feb 15 03:52:56 2008 +0100
+++ b/src/node/address.h Fri Feb 15 05:38:29 2008 +0100
@@ -4,7 +4,7 @@
#include <stdint.h>
#include <ostream>
#include "ns3/value.h"
-#include "ns3/class-value-helper.h"
+#include "ns3/value-helper.h"
namespace ns3 {
@@ -154,8 +154,7 @@
*/
static uint8_t Register (void);
- Address (PValue value);
- operator PValue () const;
+ VALUE_HELPER_HEADER_1 (Address);
private:
friend bool operator == (const Address &a, const Address &b);
friend bool operator < (const Address &a, const Address &b);
@@ -166,46 +165,15 @@
uint8_t m_data[MAX_SIZE];
};
+VALUE_HELPER_HEADER_2 (Address);
+
bool operator == (const Address &a, const Address &b);
bool operator != (const Address &a, const Address &b);
bool operator < (const Address &a, const Address &b);
std::ostream& operator<< (std::ostream& os, const Address & address);
std::istream& operator>> (std::istream& is, Address & address);
-class AddressValue : public Value {};
-class AddressParamSpec : public ParamSpec {};
-
-template <typename T1>
-Ptr<ParamSpec>
-MakeAddressParamSpec (T1 a1, Address initialValue);
-
-template <typename T1, typename T2>
-Ptr<ParamSpec>
-MakeAddressParamSpec (T1 a1, T2 a2, Address initialValue);
} // namespace ns3
-namespace ns3 {
-
-template <typename T1>
-Ptr<ParamSpec>
-MakeAddressParamSpec (T1 a1, Address initialValue)
-{
- return MakeClassValueHelperParamSpec<Address,AddressValue,AddressParamSpec>
- (a1, initialValue);
-}
-
-template <typename T1, typename T2>
-Ptr<ParamSpec>
-MakeAddressParamSpec (T1 a1, T2 a2, Address initialValue)
-{
- return MakeClassValueHelperParamSpec<Address,AddressValue,AddressParamSpec>
- (a1, a2, initialValue);
-}
-
-
-
-} // namespace ns3
-
-
#endif /* ADDRESS_H */
--- a/src/node/mac48-address.cc Fri Feb 15 03:52:56 2008 +0100
+++ b/src/node/mac48-address.cc Fri Feb 15 05:38:29 2008 +0100
@@ -25,6 +25,8 @@
namespace ns3 {
+VALUE_HELPER_CPP (Mac48Address);
+
#define ASCII_a (0x41)
#define ASCII_z (0x5a)
#define ASCII_A (0x61)
@@ -150,16 +152,6 @@
return broadcast;
}
-Mac48Address::Mac48Address (PValue value)
-{
- *this = ClassValueHelperExtractFrom<Mac48Address,Mac48AddressValue> (value);
-}
-Mac48Address::operator PValue () const
-{
- return ClassValueHelperConvertTo<Mac48Address,Mac48AddressValue> (this);
-}
-
-
bool operator == (const Mac48Address &a, const Mac48Address &b)
{
return memcmp (a.m_address, b.m_address, 6) == 0;
--- a/src/node/mac48-address.h Fri Feb 15 03:52:56 2008 +0100
+++ b/src/node/mac48-address.h Fri Feb 15 05:38:29 2008 +0100
@@ -23,7 +23,7 @@
#include <stdint.h>
#include <ostream>
#include "ns3/value.h"
-#include "ns3/class-value-helper.h"
+#include "ns3/value-helper.h"
namespace ns3 {
@@ -96,8 +96,7 @@
*/
static Mac48Address GetBroadcast (void);
- Mac48Address (PValue value);
- operator PValue () const;
+ VALUE_HELPER_HEADER_1 (Mac48Address);
private:
/**
* \returns a new Address instance
@@ -112,41 +111,14 @@
uint8_t m_address[6];
};
+VALUE_HELPER_HEADER_2 (Mac48Address);
+
bool operator == (const Mac48Address &a, const Mac48Address &b);
bool operator != (const Mac48Address &a, const Mac48Address &b);
bool operator < (const Mac48Address &a, const Mac48Address &b);
std::ostream& operator<< (std::ostream& os, const Mac48Address & address);
std::istream& operator>> (std::istream& is, const Mac48Address & address);
-class Mac48AddressValue : public Value {};
-class Mac48AddressParamSpec : public ParamSpec {};
-
-template <typename T1>
-Ptr<ParamSpec>
-MakeMac48AddressParamSpec (T1 a1, Mac48Address address);
-
-template <typename T1, typename T2>
-Ptr<ParamSpec>
-MakeMac48AddressParamSpec (T1 a1, T2 a2, Mac48Address address);
-
-} // namespace ns3
-
-namespace ns3 {
-
-template <typename T1>
-Ptr<ParamSpec>
-MakeMac48AddressParamSpec (T1 a1, Mac48Address address)
-{
- return MakeClassValueHelperParamSpec<Mac48Address,Mac48AddressValue,Mac48AddressParamSpec> (a1, address);
-}
-
-template <typename T1, typename T2>
-Ptr<ParamSpec>
-MakeMac48AddressParamSpec (T1 a1, T2 a2, Mac48Address address)
-{
- return MakeClassValueHelperParamSpec<Mac48Address,Mac48AddressValue,Mac48AddressParamSpec> (a1, a2, address);
-}
-
} // namespace ns3
#endif /* MAC48_ADDRESS_H */