--- a/samples/main-grid-topology.cc Thu Feb 21 19:13:39 2008 +0100
+++ b/samples/main-grid-topology.cc Thu Feb 21 19:16:00 2008 +0100
@@ -7,7 +7,6 @@
#include "ns3/mobility-helper.h"
#include "ns3/uinteger.h"
#include "ns3/double.h"
-#include "ns3/enum-value.h"
using namespace ns3;
--- a/src/core/attribute-test.cc Thu Feb 21 19:13:39 2008 +0100
+++ b/src/core/attribute-test.cc Thu Feb 21 19:16:00 2008 +0100
@@ -4,7 +4,7 @@
#include "boolean.h"
#include "integer.h"
#include "uinteger.h"
-#include "enum-value.h"
+#include "enum.h"
#include "random-variable.h"
#include "double.h"
#include "object-vector.h"
--- a/src/core/enum-value.cc Thu Feb 21 19:13:39 2008 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,182 +0,0 @@
-#include "enum-value.h"
-#include "fatal-error.h"
-#include <sstream>
-
-namespace ns3 {
-
-
-Enum::Enum (int v)
- : m_v (v)
-{}
-void
-Enum::Set (int v)
-{
- m_v = v;
-}
-int
-Enum::Get (void) const
-{
- return m_v;
-}
-
-Attribute
-Enum::Copy (void) const
-{
- return Attribute::Create<Enum> (*this);
-}
-std::string
-Enum::SerializeToString (Ptr<const AttributeChecker> checker) const
-{
- const EnumChecker *p = dynamic_cast<const EnumChecker *> (PeekPointer (checker));
- NS_ASSERT (p != 0);
- for (EnumChecker::ValueSet::const_iterator i = p->m_valueSet.begin (); i != p->m_valueSet.end (); i++)
- {
- if (i->first == m_v)
- {
- return i->second;
- }
- }
-
- NS_FATAL_ERROR ("The user has set an invalid C++ value in this Enum");
- // quiet compiler.
- return "";
-}
-bool
-Enum::DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker)
-{
- const EnumChecker *p = dynamic_cast<const EnumChecker *> (PeekPointer (checker));
- NS_ASSERT (p != 0);
- for (EnumChecker::ValueSet::const_iterator i = p->m_valueSet.begin (); i != p->m_valueSet.end (); i++)
- {
- if (i->second == value)
- {
- m_v = i->first;
- return true;
- }
- }
- return false;
-}
-
-Enum::Enum (Attribute value)
-{
- const Enum *v = value.DynCast<const Enum *> ();
- if (v == 0)
- {
- NS_FATAL_ERROR ("assigning non-Enum value to Enum value.");
- }
- m_v = v->m_v;
-}
-Enum::operator Attribute () const
-{
- return Attribute::Create<Enum> (*this);
-}
-
-
-
-EnumChecker::EnumChecker ()
-{}
-
-void
-EnumChecker::AddDefault (int v, std::string name)
-{
- m_valueSet.push_front (std::make_pair (v, name));
-}
-void
-EnumChecker::Add (int v, std::string name)
-{
- m_valueSet.push_back (std::make_pair (v, name));
-}
-bool
-EnumChecker::Check (Attribute value) const
-{
- const Enum *p = value.DynCast<const Enum *> ();
- if (p == 0)
- {
- return false;
- }
- for (ValueSet::const_iterator i = m_valueSet.begin (); i != m_valueSet.end (); i++)
- {
- if (i->first == p->Get ())
- {
- return true;
- }
- }
- return false;
-}
-
-Ptr<const AttributeChecker>
-MakeEnumChecker (int v1, std::string n1,
- int v2, std::string n2,
- int v3, std::string n3,
- int v4, std::string n4,
- int v5, std::string n5,
- int v6, std::string n6,
- int v7, std::string n7,
- int v8, std::string n8,
- int v9, std::string n9,
- int v10, std::string n10,
- int v11, std::string n11,
- int v12, std::string n12)
-{
- Ptr<EnumChecker> checker = Create<EnumChecker> ();
- checker->AddDefault (v1, n1);
- if (n2 == "")
- {
- return checker;
- }
- checker->Add (v2, n2);
- if (n3 == "")
- {
- return checker;
- }
- checker->Add (v3, n3);
- if (n4 == "")
- {
- return checker;
- }
- checker->Add (v4, n4);
- if (n5 == "")
- {
- return checker;
- }
- checker->Add (v5, n5);
- if (n6 == "")
- {
- return checker;
- }
- checker->Add (v6, n6);
- if (n7 == "")
- {
- return checker;
- }
- checker->Add (v7, n7);
- if (n8 == "")
- {
- return checker;
- }
- checker->Add (v8, n8);
- if (n9 == "")
- {
- return checker;
- }
- checker->Add (v9, n9);
- if (n10 == "")
- {
- return checker;
- }
- checker->Add (v10, n10);
- if (n11 == "")
- {
- return checker;
- }
- checker->Add (v11, n11);
- if (n12 == "")
- {
- return checker;
- }
- checker->Add (v12, n12);
- return checker;
-}
-
-
-} // namespace ns3
--- a/src/core/enum-value.h Thu Feb 21 19:13:39 2008 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,82 +0,0 @@
-#ifndef ENUM_VALUE_H
-#define ENUM_VALUE_H
-
-#include "attribute.h"
-#include "attribute-accessor-helper.h"
-#include <list>
-
-namespace ns3 {
-
-class Enum : public AttributeValue
-{
-public:
- Enum (int v);
- void Set (int v);
- int 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);
-
- Enum (Attribute value);
- operator Attribute () const;
-private:
- int m_v;
-};
-
-class EnumAccessor : public AttributeAccessor {};
-class EnumChecker : public AttributeChecker
-{
-public:
- EnumChecker ();
-
- void AddDefault (int v, std::string name);
- void Add (int v, std::string name);
-
- virtual bool Check (Attribute value) const;
-
-private:
- friend class Enum;
- typedef std::list<std::pair<int,std::string> > ValueSet;
- ValueSet m_valueSet;
-};
-
-template <typename T1>
-Ptr<const AttributeAccessor> MakeEnumAccessor (T1 a1);
-
-template <typename T1, typename T2>
-Ptr<const AttributeAccessor> MakeEnumAccessor (T1 a1, T2 a2);
-
-Ptr<const AttributeChecker> MakeEnumChecker (int v1, std::string n1,
- int v2 = 0, std::string n2 = "",
- int v3 = 0, std::string n3 = "",
- int v4 = 0, std::string n4 = "",
- int v5 = 0, std::string n5 = "",
- int v6 = 0, std::string n6 = "",
- int v7 = 0, std::string n7 = "",
- int v8 = 0, std::string n8 = "",
- int v9 = 0, std::string n9 = "",
- int v10 = 0, std::string n10 = "",
- int v11 = 0, std::string n11 = "",
- int v12 = 0, std::string n12 = "");
-
-
-} // namespace ns3
-
-namespace ns3 {
-
-template <typename T1>
-Ptr<const AttributeAccessor> MakeEnumAccessor (T1 a1)
-{
- return MakeAccessorHelper<EnumAccessor,Enum> (a1);
-}
-
-template <typename T1, typename T2>
-Ptr<const AttributeAccessor> MakeEnumAccessor (T1 a1, T2 a2)
-{
- return MakeAccessorHelper<EnumAccessor,Enum> (a1, a2);
-}
-
-} // namespace ns3
-
-#endif /* ENUM_VALUE_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/core/enum.cc Thu Feb 21 19:16:00 2008 +0100
@@ -0,0 +1,182 @@
+#include "enum.h"
+#include "fatal-error.h"
+#include <sstream>
+
+namespace ns3 {
+
+
+Enum::Enum (int v)
+ : m_v (v)
+{}
+void
+Enum::Set (int v)
+{
+ m_v = v;
+}
+int
+Enum::Get (void) const
+{
+ return m_v;
+}
+
+Attribute
+Enum::Copy (void) const
+{
+ return Attribute::Create<Enum> (*this);
+}
+std::string
+Enum::SerializeToString (Ptr<const AttributeChecker> checker) const
+{
+ const EnumChecker *p = dynamic_cast<const EnumChecker *> (PeekPointer (checker));
+ NS_ASSERT (p != 0);
+ for (EnumChecker::ValueSet::const_iterator i = p->m_valueSet.begin (); i != p->m_valueSet.end (); i++)
+ {
+ if (i->first == m_v)
+ {
+ return i->second;
+ }
+ }
+
+ NS_FATAL_ERROR ("The user has set an invalid C++ value in this Enum");
+ // quiet compiler.
+ return "";
+}
+bool
+Enum::DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker)
+{
+ const EnumChecker *p = dynamic_cast<const EnumChecker *> (PeekPointer (checker));
+ NS_ASSERT (p != 0);
+ for (EnumChecker::ValueSet::const_iterator i = p->m_valueSet.begin (); i != p->m_valueSet.end (); i++)
+ {
+ if (i->second == value)
+ {
+ m_v = i->first;
+ return true;
+ }
+ }
+ return false;
+}
+
+Enum::Enum (Attribute value)
+{
+ const Enum *v = value.DynCast<const Enum *> ();
+ if (v == 0)
+ {
+ NS_FATAL_ERROR ("assigning non-Enum value to Enum value.");
+ }
+ m_v = v->m_v;
+}
+Enum::operator Attribute () const
+{
+ return Attribute::Create<Enum> (*this);
+}
+
+
+
+EnumChecker::EnumChecker ()
+{}
+
+void
+EnumChecker::AddDefault (int v, std::string name)
+{
+ m_valueSet.push_front (std::make_pair (v, name));
+}
+void
+EnumChecker::Add (int v, std::string name)
+{
+ m_valueSet.push_back (std::make_pair (v, name));
+}
+bool
+EnumChecker::Check (Attribute value) const
+{
+ const Enum *p = value.DynCast<const Enum *> ();
+ if (p == 0)
+ {
+ return false;
+ }
+ for (ValueSet::const_iterator i = m_valueSet.begin (); i != m_valueSet.end (); i++)
+ {
+ if (i->first == p->Get ())
+ {
+ return true;
+ }
+ }
+ return false;
+}
+
+Ptr<const AttributeChecker>
+MakeEnumChecker (int v1, std::string n1,
+ int v2, std::string n2,
+ int v3, std::string n3,
+ int v4, std::string n4,
+ int v5, std::string n5,
+ int v6, std::string n6,
+ int v7, std::string n7,
+ int v8, std::string n8,
+ int v9, std::string n9,
+ int v10, std::string n10,
+ int v11, std::string n11,
+ int v12, std::string n12)
+{
+ Ptr<EnumChecker> checker = Create<EnumChecker> ();
+ checker->AddDefault (v1, n1);
+ if (n2 == "")
+ {
+ return checker;
+ }
+ checker->Add (v2, n2);
+ if (n3 == "")
+ {
+ return checker;
+ }
+ checker->Add (v3, n3);
+ if (n4 == "")
+ {
+ return checker;
+ }
+ checker->Add (v4, n4);
+ if (n5 == "")
+ {
+ return checker;
+ }
+ checker->Add (v5, n5);
+ if (n6 == "")
+ {
+ return checker;
+ }
+ checker->Add (v6, n6);
+ if (n7 == "")
+ {
+ return checker;
+ }
+ checker->Add (v7, n7);
+ if (n8 == "")
+ {
+ return checker;
+ }
+ checker->Add (v8, n8);
+ if (n9 == "")
+ {
+ return checker;
+ }
+ checker->Add (v9, n9);
+ if (n10 == "")
+ {
+ return checker;
+ }
+ checker->Add (v10, n10);
+ if (n11 == "")
+ {
+ return checker;
+ }
+ checker->Add (v11, n11);
+ if (n12 == "")
+ {
+ return checker;
+ }
+ checker->Add (v12, n12);
+ return checker;
+}
+
+
+} // namespace ns3
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/core/enum.h Thu Feb 21 19:16:00 2008 +0100
@@ -0,0 +1,82 @@
+#ifndef ENUM_VALUE_H
+#define ENUM_VALUE_H
+
+#include "attribute.h"
+#include "attribute-accessor-helper.h"
+#include <list>
+
+namespace ns3 {
+
+class Enum : public AttributeValue
+{
+public:
+ Enum (int v);
+ void Set (int v);
+ int 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);
+
+ Enum (Attribute value);
+ operator Attribute () const;
+private:
+ int m_v;
+};
+
+class EnumAccessor : public AttributeAccessor {};
+class EnumChecker : public AttributeChecker
+{
+public:
+ EnumChecker ();
+
+ void AddDefault (int v, std::string name);
+ void Add (int v, std::string name);
+
+ virtual bool Check (Attribute value) const;
+
+private:
+ friend class Enum;
+ typedef std::list<std::pair<int,std::string> > ValueSet;
+ ValueSet m_valueSet;
+};
+
+template <typename T1>
+Ptr<const AttributeAccessor> MakeEnumAccessor (T1 a1);
+
+template <typename T1, typename T2>
+Ptr<const AttributeAccessor> MakeEnumAccessor (T1 a1, T2 a2);
+
+Ptr<const AttributeChecker> MakeEnumChecker (int v1, std::string n1,
+ int v2 = 0, std::string n2 = "",
+ int v3 = 0, std::string n3 = "",
+ int v4 = 0, std::string n4 = "",
+ int v5 = 0, std::string n5 = "",
+ int v6 = 0, std::string n6 = "",
+ int v7 = 0, std::string n7 = "",
+ int v8 = 0, std::string n8 = "",
+ int v9 = 0, std::string n9 = "",
+ int v10 = 0, std::string n10 = "",
+ int v11 = 0, std::string n11 = "",
+ int v12 = 0, std::string n12 = "");
+
+
+} // namespace ns3
+
+namespace ns3 {
+
+template <typename T1>
+Ptr<const AttributeAccessor> MakeEnumAccessor (T1 a1)
+{
+ return MakeAccessorHelper<EnumAccessor,Enum> (a1);
+}
+
+template <typename T1, typename T2>
+Ptr<const AttributeAccessor> MakeEnumAccessor (T1 a1, T2 a2)
+{
+ return MakeAccessorHelper<EnumAccessor,Enum> (a1, a2);
+}
+
+} // namespace ns3
+
+#endif /* ENUM_VALUE_H */
--- a/src/core/wscript Thu Feb 21 19:13:39 2008 +0100
+++ b/src/core/wscript Thu Feb 21 19:16:00 2008 +0100
@@ -58,7 +58,7 @@
'attribute-test.cc',
'integer.cc',
'uinteger.cc',
- 'enum-value.cc',
+ 'enum.cc',
'double.cc',
'object-factory.cc',
'object-vector.cc',
@@ -113,7 +113,7 @@
'integer.h',
'uinteger.h',
'double.h',
- 'enum-value.h',
+ 'enum.h',
'object-factory.h',
'attribute-helper.h',
'initial-value.h',
--- a/src/mobility/position-allocator.cc Thu Feb 21 19:13:39 2008 +0100
+++ b/src/mobility/position-allocator.cc Thu Feb 21 19:16:00 2008 +0100
@@ -21,7 +21,7 @@
#include "ns3/random-variable.h"
#include "ns3/double.h"
#include "ns3/integer.h"
-#include "ns3/enum-value.h"
+#include "ns3/enum.h"
#include "ns3/log.h"
#include <cmath>
--- a/src/mobility/random-walk-2d-mobility-model.cc Thu Feb 21 19:13:39 2008 +0100
+++ b/src/mobility/random-walk-2d-mobility-model.cc Thu Feb 21 19:16:00 2008 +0100
@@ -19,7 +19,7 @@
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
*/
#include "random-walk-2d-mobility-model.h"
-#include "ns3/enum-value.h"
+#include "ns3/enum.h"
#include "ns3/simulator.h"
#include "ns3/log.h"
#include <cmath>