--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/core/global-value.cc Sat Feb 23 05:23:59 2008 +0100
@@ -0,0 +1,128 @@
+#include "global-value.h"
+#include "fatal-error.h"
+#include "object.h"
+
+namespace ns3 {
+
+GlobalValue::GlobalValue (std::string name, std::string help,
+ Attribute initialValue,
+ Ptr<const AttributeChecker> checker)
+ : m_name (name),
+ m_help (help),
+ m_initialValue (initialValue),
+ m_checker (checker)
+{
+ if (m_checker == 0)
+ {
+ NS_FATAL_ERROR ("Checker should no be zero.");
+ }
+ GetVector ()->push_back (this);
+}
+
+std::string
+GlobalValue::GetName (void) const
+{
+ return m_name;
+}
+std::string
+GlobalValue::GetHelp (void) const
+{
+ return m_help;
+}
+Attribute
+GlobalValue::GetValue (void) const
+{
+ return m_initialValue;
+}
+Ptr<const AttributeChecker>
+GlobalValue::GetChecker (void) const
+{
+ return m_checker;
+}
+
+void
+GlobalValue::SetValue (Attribute value)
+{
+ if (!m_checker->Check (value))
+ {
+ NS_FATAL_ERROR ("Invalid new value.");
+ }
+ m_initialValue = value;
+}
+
+void
+GlobalValue::Bind (std::string name, Attribute value)
+{
+ for (Iterator i = Begin (); i != End (); i++)
+ {
+ if ((*i)->GetName () == name)
+ {
+ (*i)->SetValue (value);
+ return;
+ }
+ }
+ // since we did not find a matching GlobalValue,
+ // we attempt to configure the global parameters list.
+ AttributeList::GetGlobal ()->Set (name, value);
+}
+GlobalValue::Iterator
+GlobalValue::Begin (void)
+{
+ return GetVector ()->begin ();
+}
+GlobalValue::Iterator
+GlobalValue::End (void)
+{
+ return GetVector ()->end ();
+}
+GlobalValue::Vector *
+GlobalValue::GetVector (void)
+{
+ static Vector vector;
+ return &vector;
+}
+
+} // namespace ns3
+
+#ifdef RUN_SELF_TESTS
+
+#include "test.h"
+#include "uinteger.h"
+
+namespace {
+
+static ns3::GlobalValue g_uint = ns3::GlobalValue ("TestUint", "help text",
+ ns3::Uinteger (10),
+ ns3::MakeUintegerChecker<uint32_t> ());
+
+}
+
+namespace ns3 {
+
+class GlobalValueTests : public Test
+{
+public:
+ GlobalValueTests ();
+ virtual bool RunTests (void);
+private:
+};
+
+
+GlobalValueTests::GlobalValueTests ()
+ : Test ("GlobalValue")
+{}
+bool
+GlobalValueTests::RunTests (void)
+{
+ bool result = true;
+
+ NS_TEST_ASSERT_EQUAL (10, Uinteger (g_uint.GetValue ()).Get ());
+
+ return result;
+}
+
+static GlobalValueTests g_initialValueTests;
+
+} // namespace ns3
+
+#endif /* RUN_SELF_TESTS */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/core/global-value.h Sat Feb 23 05:23:59 2008 +0100
@@ -0,0 +1,43 @@
+#ifndef GLOBAL_VALUE_H
+#define GLOBAL_VALUE_H
+
+#include <string>
+#include <vector>
+#include "ptr.h"
+#include "attribute.h"
+
+
+namespace ns3 {
+
+class GlobalValue
+{
+ typedef std::vector<GlobalValue *> Vector;
+public:
+ typedef Vector::const_iterator Iterator;
+
+ GlobalValue (std::string name, std::string help,
+ Attribute initialValue,
+ Ptr<const AttributeChecker> checker);
+
+ std::string GetName (void) const;
+ std::string GetHelp (void) const;
+ Attribute GetValue (void) const;
+ Ptr<const AttributeChecker> GetChecker (void) const;
+
+ void SetValue (Attribute value);
+
+ static void Bind (std::string name, Attribute value);
+
+ static Iterator Begin (void);
+ static Iterator End (void);
+private:
+ static Vector *GetVector (void);
+ std::string m_name;
+ std::string m_help;
+ Attribute m_initialValue;
+ Ptr<const AttributeChecker> m_checker;
+};
+
+} // namespace ns3
+
+#endif /* GLOBAL_VALUE_H */
--- a/src/core/initial-value.cc Fri Feb 22 00:22:16 2008 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,128 +0,0 @@
-#include "initial-value.h"
-#include "fatal-error.h"
-#include "object.h"
-
-namespace ns3 {
-
-InitialValue::InitialValue (std::string name, std::string help,
- Attribute initialValue,
- Ptr<const AttributeChecker> checker)
- : m_name (name),
- m_help (help),
- m_initialValue (initialValue),
- m_checker (checker)
-{
- if (m_checker == 0)
- {
- NS_FATAL_ERROR ("Checker should no be zero.");
- }
- GetVector ()->push_back (this);
-}
-
-std::string
-InitialValue::GetName (void) const
-{
- return m_name;
-}
-std::string
-InitialValue::GetHelp (void) const
-{
- return m_help;
-}
-Attribute
-InitialValue::GetValue (void) const
-{
- return m_initialValue;
-}
-Ptr<const AttributeChecker>
-InitialValue::GetChecker (void) const
-{
- return m_checker;
-}
-
-void
-InitialValue::SetValue (Attribute value)
-{
- if (!m_checker->Check (value))
- {
- NS_FATAL_ERROR ("Invalid new value.");
- }
- m_initialValue = value;
-}
-
-void
-InitialValue::Bind (std::string name, Attribute value)
-{
- for (Iterator i = Begin (); i != End (); i++)
- {
- if ((*i)->GetName () == name)
- {
- (*i)->SetValue (value);
- return;
- }
- }
- // since we did not find a matching InitialValue,
- // we attempt to configure the global parameters list.
- AttributeList::GetGlobal ()->Set (name, value);
-}
-InitialValue::Iterator
-InitialValue::Begin (void)
-{
- return GetVector ()->begin ();
-}
-InitialValue::Iterator
-InitialValue::End (void)
-{
- return GetVector ()->end ();
-}
-InitialValue::Vector *
-InitialValue::GetVector (void)
-{
- static Vector vector;
- return &vector;
-}
-
-} // namespace ns3
-
-#ifdef RUN_SELF_TESTS
-
-#include "test.h"
-#include "uinteger.h"
-
-namespace {
-
-static ns3::InitialValue g_uint = ns3::InitialValue ("TestUint", "help text",
- ns3::Uinteger (10),
- ns3::MakeUintegerChecker<uint32_t> ());
-
-}
-
-namespace ns3 {
-
-class InitialValueTests : public Test
-{
-public:
- InitialValueTests ();
- virtual bool RunTests (void);
-private:
-};
-
-
-InitialValueTests::InitialValueTests ()
- : Test ("InitialValue")
-{}
-bool
-InitialValueTests::RunTests (void)
-{
- bool result = true;
-
- NS_TEST_ASSERT_EQUAL (10, Uinteger (g_uint.GetValue ()).Get ());
-
- return result;
-}
-
-static InitialValueTests g_initialValueTests;
-
-} // namespace ns3
-
-#endif /* RUN_SELF_TESTS */
--- a/src/core/initial-value.h Fri Feb 22 00:22:16 2008 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +0,0 @@
-#ifndef INITIAL_VALUE_H
-#define INITIAL_VALUE_H
-
-#include <string>
-#include <vector>
-#include "ptr.h"
-#include "attribute.h"
-
-
-namespace ns3 {
-
-class InitialValue
-{
- typedef std::vector<InitialValue *> Vector;
-public:
- typedef Vector::const_iterator Iterator;
-
- InitialValue (std::string name, std::string help,
- Attribute initialValue,
- Ptr<const AttributeChecker> checker);
-
- std::string GetName (void) const;
- std::string GetHelp (void) const;
- Attribute GetValue (void) const;
- Ptr<const AttributeChecker> GetChecker (void) const;
-
- void SetValue (Attribute value);
-
- static void Bind (std::string name, Attribute value);
-
- static Iterator Begin (void);
- static Iterator End (void);
-private:
- static Vector *GetVector (void);
- std::string m_name;
- std::string m_help;
- Attribute m_initialValue;
- Ptr<const AttributeChecker> m_checker;
-};
-
-} // namespace ns3
-
-#endif /* INITIAL_VALUE_H */
--- a/src/core/wscript Fri Feb 22 00:22:16 2008 +0100
+++ b/src/core/wscript Sat Feb 23 05:23:59 2008 +0100
@@ -62,7 +62,7 @@
'double.cc',
'object-factory.cc',
'object-vector.cc',
- 'initial-value.cc',
+ 'global-value.cc',
'event-trace-source.cc',
'trace-source-accessor.cc',
]
@@ -118,7 +118,7 @@
'enum.h',
'object-factory.h',
'attribute-helper.h',
- 'initial-value.h',
+ 'global-value.h',
'event-trace-source.h',
'integer-trace-source.h',
'trace-source-accessor.h',