From 8bac0c2ba3f7fcd9c1508dc5bbef69d372576778 Mon Sep 17 00:00:00 2001 From: Mathieu Lacage Date: Mon, 18 Feb 2008 03:01:42 +0100 Subject: [PATCH] move checker creation function to .cc file. --- src/core/fp-value.cc | 22 ++++++++++++++++++++++ src/core/fp-value.h | 26 ++------------------------ src/core/int-value.cc | 22 ++++++++++++++++++++++ src/core/int-value.h | 27 +-------------------------- src/core/uint-value.cc | 23 +++++++++++++++++++++++ src/core/uint-value.h | 25 ++----------------------- 6 files changed, 72 insertions(+), 73 deletions(-) diff --git a/src/core/fp-value.cc b/src/core/fp-value.cc index 0bf63bc0f..c7cb53c27 100644 --- a/src/core/fp-value.cc +++ b/src/core/fp-value.cc @@ -59,4 +59,26 @@ FpValue::operator PValue () const return PValue::Create (*this); } +Ptr MakeFpChecker (double min, double max) +{ + struct Checker : public AttributeChecker + { + Checker (double minValue, double maxValue) + : m_minValue (minValue), + m_maxValue (maxValue) {} + virtual bool Check (PValue value) const { + const FpValue *v = value.DynCast (); + if (v == 0) + { + return false; + } + return v->Get () >= m_minValue && v->Get () <= m_maxValue; + } + double m_minValue; + double m_maxValue; + } *checker = new Checker (min, max); + return Ptr (checker, false); +} + + } // namespace ns3 diff --git a/src/core/fp-value.h b/src/core/fp-value.h index c44fd908d..c147b73d6 100644 --- a/src/core/fp-value.h +++ b/src/core/fp-value.h @@ -34,8 +34,8 @@ Ptr MakeFpParamSpec (T1 a1, T2 a2); template Ptr MakeFpChecker (void); -template -Ptr MakeFpChecker (T min, T max); + +Ptr MakeFpChecker (double min, double max); @@ -60,28 +60,6 @@ Ptr MakeFpChecker (void) return MakeFpChecker (-std::numeric_limits::max (), std::numeric_limits::max ()); } -template -Ptr MakeFpChecker (T min, T max) -{ - struct Checker : public AttributeChecker - { - Checker (double minValue, double maxValue) - : m_minValue (minValue), - m_maxValue (maxValue) {} - virtual bool Check (PValue value) const { - const FpValue *v = value.DynCast (); - if (v == 0) - { - return false; - } - return v->Get () >= m_minValue && v->Get () <= m_maxValue; - } - double m_minValue; - double m_maxValue; - } *checker = new Checker (min, max); - return Ptr (checker, false); -} - } // namespace ns3 diff --git a/src/core/int-value.cc b/src/core/int-value.cc index bf8c8f3d9..accb3522b 100644 --- a/src/core/int-value.cc +++ b/src/core/int-value.cc @@ -59,5 +59,27 @@ IntValue::operator PValue () const return PValue::Create (*this); } +Ptr +MakeIntChecker (int64_t min, int64_t max) +{ + struct IntChecker : public AttributeChecker + { + IntChecker (int64_t minValue, int64_t maxValue) + : m_minValue (minValue), + m_maxValue (maxValue) {} + virtual bool Check (PValue value) const { + const IntValue *v = value.DynCast (); + if (v == 0) + { + return false; + } + return v->Get () >= m_minValue && v->Get () <= m_maxValue; + } + int64_t m_minValue; + int64_t m_maxValue; + } *checker = new IntChecker (min, max); + return Ptr (checker, false); +} + } // namespace ns3 diff --git a/src/core/int-value.h b/src/core/int-value.h index a66aa22bc..20b93df8d 100644 --- a/src/core/int-value.h +++ b/src/core/int-value.h @@ -34,8 +34,7 @@ Ptr MakeIntParamSpec (T1 a1, T2 a2); template Ptr MakeIntChecker (void); -template -Ptr MakeIntChecker (T min, T max); +Ptr MakeIntChecker (int64_t min, int64_t max); } // namespace ns3 @@ -61,30 +60,6 @@ MakeIntChecker (void) std::numeric_limits::max ()); } -template -Ptr -MakeIntChecker (T min, T max) -{ - struct IntChecker : public AttributeChecker - { - IntChecker (int64_t minValue, int64_t maxValue) - : m_minValue (minValue), - m_maxValue (maxValue) {} - virtual bool Check (PValue value) const { - const IntValue *v = value.DynCast (); - if (v == 0) - { - return false; - } - return v->Get () >= m_minValue && v->Get () <= m_maxValue; - } - int64_t m_minValue; - int64_t m_maxValue; - } *checker = new IntChecker (min, max); - return Ptr (checker, false); -} - - } // namespace ns3 #endif /* INT_VALUE_H */ diff --git a/src/core/uint-value.cc b/src/core/uint-value.cc index 28632e733..687df5a76 100644 --- a/src/core/uint-value.cc +++ b/src/core/uint-value.cc @@ -59,4 +59,27 @@ UintValue::operator PValue () const return PValue::Create (*this); } + +Ptr MakeUintChecker (uint64_t min, uint64_t max) +{ + struct Checker : public AttributeChecker + { + Checker (uint64_t minValue, uint64_t maxValue) + : m_minValue (minValue), + m_maxValue (maxValue) {} + virtual bool Check (PValue value) const { + const UintValue *v = value.DynCast (); + if (v == 0) + { + return false; + } + return v->Get () >= m_minValue && v->Get () <= m_maxValue; + } + uint64_t m_minValue; + uint64_t m_maxValue; + } *checker = new Checker (min, max); + return Ptr (checker, false); +} + + } // namespace ns3 diff --git a/src/core/uint-value.h b/src/core/uint-value.h index 93b7451e3..12770dfe7 100644 --- a/src/core/uint-value.h +++ b/src/core/uint-value.h @@ -33,8 +33,8 @@ Ptr MakeUintParamSpec (T1 a1, T2 a2); template Ptr MakeUintChecker (void); -template -Ptr MakeUintChecker (T min, T max); + +Ptr MakeUintChecker (uint64_t min, uint64_t max); } // namespace ns3 @@ -59,27 +59,6 @@ Ptr MakeUintChecker (void) return MakeUintChecker (std::numeric_limits::min (), std::numeric_limits::max ()); } -template -Ptr MakeUintChecker (T min, T max) -{ - struct Checker : public AttributeChecker - { - Checker (uint64_t minValue, uint64_t maxValue) - : m_minValue (minValue), - m_maxValue (maxValue) {} - virtual bool Check (PValue value) const { - const UintValue *v = value.DynCast (); - if (v == 0) - { - return false; - } - return v->Get () >= m_minValue && v->Get () <= m_maxValue; - } - uint64_t m_minValue; - uint64_t m_maxValue; - } *checker = new Checker (min, max); - return Ptr (checker, false); -} } // namespace ns3