--- a/src/core/boolean-value.h Thu Feb 21 00:00:18 2008 +0100
+++ b/src/core/boolean-value.h Thu Feb 21 00:19:31 2008 +0100
@@ -2,56 +2,31 @@
#define BOOLEAN_VALUE_H
#include "attribute.h"
-#include "param-spec-helper.h"
-#include "ptr.h"
+#include "value-helper.h"
namespace ns3 {
-class BooleanValue : public AttributeValue
+class Boolean
{
public:
- BooleanValue (bool value);
+ Boolean ();
+ Boolean (bool value);
void Set (bool value);
bool Get (void) const;
- virtual Attribute Copy (void) const;
- virtual std::string SerializeToString (Ptr<const AttributeChecker> checker) const;
- virtual bool DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker);
+ operator bool () const;
- BooleanValue (Attribute value);
- operator Attribute () const;
+ ATTRIBUTE_CONVERTER_DEFINE (Boolean);
private:
bool m_value;
};
-class BooleanAccessor : public AttributeAccessor {};
-
-
-template <typename T1>
-Ptr<const AttributeAccessor> MakeBooleanAccessor (T1 a1);
-
-template <typename T1, typename T2>
-Ptr<const AttributeAccessor> MakeBooleanAccessor (T1 a1, T2 a2);
-
-Ptr<const AttributeChecker> MakeBooleanChecker (void);
-
-} // namespace ns3
-
+std::ostream & operator << (std::ostream &os, const Boolean &value);
+std::istream & operator >> (std::istream &is, Boolean &value);
-// Implementation of template functions below.
-namespace ns3 {
-
-template <typename T1>
-Ptr<const AttributeAccessor> MakeBooleanAccessor (T1 a1)
-{
- return MakeAccessorHelper<BooleanAccessor,BooleanValue> (a1);
-}
-
-template <typename T1, typename T2>
-Ptr<const AttributeAccessor> MakeBooleanAccessor (T1 a1, T2 a2)
-{
- return MakeAccessorHelper<BooleanAccessor,BooleanValue> (a1, a2);
-}
+ATTRIBUTE_VALUE_DEFINE (Boolean);
+ATTRIBUTE_CHECKER_DEFINE (Boolean);
+ATTRIBUTE_ACCESSOR_DEFINE (Boolean);
} // namespace ns3
--- a/src/core/value-test.cc Thu Feb 21 00:00:18 2008 +0100
+++ b/src/core/value-test.cc Thu Feb 21 00:19:31 2008 +0100
@@ -42,11 +42,11 @@
static TypeId tid = TypeId ("AccessorObjectTest")
.SetParent<Object> ()
.AddParameter ("TestBoolName", "help text",
- BooleanValue (false),
+ Boolean (false),
MakeBooleanAccessor (&AccessorObjectTest::m_boolTest),
MakeBooleanChecker ())
.AddParameter ("TestBoolA", "help text",
- BooleanValue (false),
+ Boolean (false),
MakeBooleanAccessor (&AccessorObjectTest::DoSetTestB,
&AccessorObjectTest::DoGetTestB),
MakeBooleanChecker ())
@@ -172,31 +172,31 @@
NS_TEST_ASSERT (params.Set ("AccessorObjectTest::TestBoolName", "false"));
p = CreateObject<AccessorObjectTest> (params);
CHECK_GET_STR (p, "TestBoolName", "false");
- CHECK_GET_PARAM (p, "TestBoolName", BooleanValue, false);
+ CHECK_GET_PARAM (p, "TestBoolName", Boolean, false);
NS_TEST_ASSERT (p->Set ("TestBoolName", "true"));
CHECK_GET_STR (p, "TestBoolName", "true");
- CHECK_GET_PARAM (p, "TestBoolName", BooleanValue, true);
+ CHECK_GET_PARAM (p, "TestBoolName", Boolean, true);
- NS_TEST_ASSERT (p->Set ("TestBoolName", BooleanValue (false)));
+ NS_TEST_ASSERT (p->Set ("TestBoolName", Boolean (false)));
CHECK_GET_STR (p, "TestBoolName", "false");
- CHECK_GET_PARAM (p, "TestBoolName", BooleanValue, false);
+ CHECK_GET_PARAM (p, "TestBoolName", Boolean, false);
p = CreateObjectWith<AccessorObjectTest> ("TestBoolName", "true");
CHECK_GET_STR (p, "TestBoolName", "true");
- CHECK_GET_PARAM (p, "TestBoolName", BooleanValue, true);
+ CHECK_GET_PARAM (p, "TestBoolName", Boolean, true);
- p = CreateObjectWith<AccessorObjectTest> ("TestBoolName", BooleanValue (true));
+ p = CreateObjectWith<AccessorObjectTest> ("TestBoolName", Boolean (true));
CHECK_GET_STR (p, "TestBoolName", "true");
- CHECK_GET_PARAM (p, "TestBoolName", BooleanValue, true);
+ CHECK_GET_PARAM (p, "TestBoolName", Boolean, true);
NS_TEST_ASSERT (p->Set ("TestBoolA", "false"));
CHECK_GET_STR (p, "TestBoolA", "false");
- CHECK_GET_PARAM (p, "TestBoolA", BooleanValue, false);
+ CHECK_GET_PARAM (p, "TestBoolA", Boolean, false);
NS_TEST_ASSERT (p->Set ("TestBoolA", "true"));
CHECK_GET_STR (p, "TestBoolA", "true");
- CHECK_GET_PARAM (p, "TestBoolA", BooleanValue, true);
+ CHECK_GET_PARAM (p, "TestBoolA", Boolean, true);
Ptr<Derived> derived = p->Get ("TestPtr");