From 063d86c096df93fb27652d2d7ae078b89af2fa96 Mon Sep 17 00:00:00 2001 From: "Peter D. Barnes, Jr" Date: Wed, 25 Mar 2020 15:12:18 -0700 Subject: [PATCH] core: clear check-style -l3 errors --- src/core/model/abort.h | 24 +- src/core/model/assert.h | 42 +- src/core/model/attribute-accessor-helper.h | 120 +-- src/core/model/attribute-construction-list.cc | 18 +- src/core/model/attribute-construction-list.h | 4 +- src/core/model/attribute-helper.h | 54 +- src/core/model/attribute.cc | 32 +- src/core/model/attribute.h | 7 +- src/core/model/boolean.cc | 20 +- src/core/model/boolean.h | 1 + src/core/model/breakpoint.cc | 2 +- src/core/model/breakpoint.h | 4 +- src/core/model/build-profile.h | 17 +- src/core/model/cairo-wideint-private.h | 4 +- src/core/model/cairo-wideint.c | 2 + src/core/model/calendar-scheduler.cc | 6 +- src/core/model/calendar-scheduler.h | 2 +- src/core/model/callback.cc | 21 +- src/core/model/callback.h | 630 ++++++++++------ src/core/model/command-line.cc | 70 +- src/core/model/command-line.h | 125 ++-- src/core/model/config.cc | 168 ++--- src/core/model/config.h | 12 +- src/core/model/default-deleter.h | 3 +- src/core/model/default-simulator-impl.cc | 57 +- src/core/model/default-simulator-impl.h | 5 +- src/core/model/des-metrics.cc | 17 +- src/core/model/des-metrics.h | 20 +- src/core/model/double.cc | 21 +- src/core/model/empty.h | 3 +- src/core/model/enum.cc | 14 +- src/core/model/enum.h | 2 +- src/core/model/event-id.cc | 6 +- src/core/model/event-id.h | 32 +- src/core/model/fatal-impl.cc | 16 +- src/core/model/global-value.cc | 28 +- src/core/model/global-value.h | 31 +- src/core/model/hash-fnv.cc | 22 +- src/core/model/hash-fnv.h | 2 +- src/core/model/hash-function.h | 26 +- src/core/model/hash-murmur3.cc | 20 +- src/core/model/hash-murmur3.h | 8 +- src/core/model/heap-scheduler.h | 2 +- src/core/model/int-to-type.h | 5 +- src/core/model/int64x64-128.cc | 34 +- src/core/model/int64x64-128.h | 32 +- src/core/model/int64x64-cairo.cc | 38 +- src/core/model/int64x64-cairo.h | 22 +- src/core/model/int64x64-double.h | 61 +- src/core/model/int64x64.cc | 25 +- src/core/model/int64x64.h | 4 +- src/core/model/integer.cc | 21 +- src/core/model/list-scheduler.cc | 3 +- src/core/model/log-macros-disabled.h | 34 +- src/core/model/log-macros-enabled.h | 24 +- src/core/model/log.cc | 163 ++--- src/core/model/log.h | 43 +- src/core/model/make-event.cc | 14 +- src/core/model/make-event.h | 183 +++-- src/core/model/math.h | 10 +- src/core/model/names.cc | 39 +- src/core/model/names.h | 16 +- src/core/model/node-printer.cc | 5 +- src/core/model/non-copyable.h | 10 +- src/core/model/nstime.h | 54 +- src/core/model/object-base.cc | 84 +-- src/core/model/object-base.h | 14 +- src/core/model/object-factory.cc | 16 +- src/core/model/object-factory.h | 51 +- src/core/model/object-map.h | 16 +- src/core/model/object-ptr-container.cc | 20 +- src/core/model/object-ptr-container.h | 44 +- src/core/model/object-vector.h | 14 +- src/core/model/object.cc | 52 +- src/core/model/object.h | 42 +- src/core/model/pointer.cc | 6 +- src/core/model/pointer.h | 35 +- src/core/model/ptr.h | 59 +- src/core/model/random-variable-stream.cc | 599 ++++++++------- src/core/model/random-variable-stream.h | 168 ++--- src/core/model/realtime-simulator-impl.cc | 162 ++--- src/core/model/realtime-simulator-impl.h | 15 +- src/core/model/ref-count-base.h | 2 +- src/core/model/rng-seed-manager.cc | 12 +- src/core/model/rng-seed-manager.h | 8 +- src/core/model/rng-stream.cc | 41 +- src/core/model/rng-stream.h | 4 +- src/core/model/show-progress.cc | 60 +- src/core/model/show-progress.h | 13 +- src/core/model/simple-ref-count.h | 6 +- src/core/model/simulation-singleton.h | 12 +- src/core/model/simulator-impl.cc | 4 +- src/core/model/simulator-impl.h | 4 +- src/core/model/simulator.cc | 48 +- src/core/model/simulator.h | 201 ++--- src/core/model/singleton.h | 2 +- src/core/model/synchronizer.cc | 10 +- src/core/model/synchronizer.h | 20 +- src/core/model/system-condition.h | 23 +- src/core/model/system-mutex.h | 19 +- src/core/model/system-path.cc | 81 ++- src/core/model/system-path.h | 140 ++-- src/core/model/system-thread.cc | 14 +- src/core/model/system-thread.h | 34 +- src/core/model/system-wall-clock-ms.h | 7 +- src/core/model/test.cc | 160 ++-- src/core/model/test.h | 686 +++++++++--------- src/core/model/time-printer.cc | 11 +- src/core/model/time.cc | 66 +- src/core/model/timer-impl.h | 113 ++- src/core/model/timer.h | 2 +- src/core/model/trace-source-accessor.cc | 6 +- src/core/model/trace-source-accessor.h | 14 +- src/core/model/traced-callback.h | 68 +- src/core/model/traced-value.h | 286 +++++--- src/core/model/type-id.cc | 287 ++++---- src/core/model/type-id.h | 76 +- src/core/model/type-name.cc | 4 +- src/core/model/type-name.h | 2 +- src/core/model/type-traits.h | 359 ++++++--- src/core/model/uinteger.cc | 21 +- src/core/model/uinteger.h | 2 +- src/core/model/unix-fd-reader.cc | 4 +- src/core/model/unix-fd-reader.h | 14 +- src/core/model/unix-system-condition.cc | 35 +- src/core/model/unix-system-mutex.cc | 28 +- src/core/model/unix-system-wall-clock-ms.cc | 19 +- src/core/model/valgrind.h | 4 +- src/core/model/vector.cc | 8 +- src/core/model/vector.h | 24 +- src/core/model/wall-clock-synchronizer.cc | 60 +- src/core/model/wall-clock-synchronizer.h | 14 +- src/core/model/watchdog.h | 18 +- src/core/model/win32-system-wall-clock-ms.cc | 23 +- utils/check-style.py | 17 +- 135 files changed, 3870 insertions(+), 3283 deletions(-) diff --git a/src/core/model/abort.h b/src/core/model/abort.h index 600ed9f6a..274f556be 100644 --- a/src/core/model/abort.h +++ b/src/core/model/abort.h @@ -51,7 +51,7 @@ do { \ std::cerr << "aborted. "; \ NS_FATAL_ERROR (msg); \ - } while (false) + } while (false) /** @@ -76,11 +76,11 @@ */ #define NS_ABORT_IF(cond) \ do { \ - if (cond) \ - { \ - std::cerr << "aborted. cond=\"" << # cond << ", "; \ - NS_FATAL_ERROR_NO_MSG (); \ - } \ + if (cond) \ + { \ + std::cerr << "aborted. cond=\"" << # cond << ", "; \ + NS_FATAL_ERROR_NO_MSG (); \ + } \ } while (false) /** @@ -107,12 +107,12 @@ */ #define NS_ABORT_MSG_IF(cond, msg) \ do { \ - if (cond) \ - { \ - std::cerr << "aborted. cond=\"" << # cond << "\", "; \ - NS_FATAL_ERROR (msg); \ - } \ - } while (false) + if (cond) \ + { \ + std::cerr << "aborted. cond=\"" << # cond << "\", "; \ + NS_FATAL_ERROR (msg); \ + } \ + } while (false) /** * \ingroup fatal diff --git a/src/core/model/assert.h b/src/core/model/assert.h index d9f1b10a3..3f71b473f 100644 --- a/src/core/model/assert.h +++ b/src/core/model/assert.h @@ -59,22 +59,20 @@ * \ingroup assert * * At runtime, in debugging builds, if this condition is not - * true, the program prints the source file, line number and + * true, the program prints the source file, line number and * unverified condition and halts by calling std::terminate * * \param [in] condition Condition to verify. */ -#define NS_ASSERT(condition) \ - do \ - { \ - if (!(condition)) \ - { \ - std::cerr << "assert failed. cond=\"" << \ - # condition << "\", "; \ - NS_FATAL_ERROR_NO_MSG (); \ - } \ - } \ - while (false) +#define NS_ASSERT(condition) \ + do { \ + if (!(condition)) \ + { \ + std::cerr << "assert failed. cond=\"" \ + << # condition << "\", "; \ + NS_FATAL_ERROR_NO_MSG (); \ + } \ + } while (false) /** @@ -88,32 +86,26 @@ * \param [in] message Message to output */ #define NS_ASSERT_MSG(condition, message) \ - do \ - { \ + do { \ if (!(condition)) \ { \ std::cerr << "assert failed. cond=\"" << \ - # condition << "\", "; \ + # condition << "\", "; \ NS_FATAL_ERROR (message); \ } \ - } \ - while (false) + } while (false) #else /* NS3_ASSERT_ENABLE */ #define NS_ASSERT(condition) \ - do \ - { \ + do { \ (void)sizeof (condition); \ - } \ - while (false) + } while (false) #define NS_ASSERT_MSG(condition, message) \ - do \ - { \ + do { \ (void)sizeof (condition); \ - } \ - while (false) + } while (false) #endif /* NS3_ASSERT_ENABLE */ diff --git a/src/core/model/attribute-accessor-helper.h b/src/core/model/attribute-accessor-helper.h index 49f12de70..71d91e2ac 100644 --- a/src/core/model/attribute-accessor-helper.h +++ b/src/core/model/attribute-accessor-helper.h @@ -31,7 +31,7 @@ namespace ns3 { - + /** * \ingroup attributeimpl * @@ -72,7 +72,7 @@ inline Ptr MakeAccessorHelper (T1 a1); - + /** * \ingroup attributeimpl * @@ -118,7 +118,7 @@ inline Ptr MakeAccessorHelper (T1 a1, T2 a2); - + } // namespace ns3 @@ -130,7 +130,7 @@ MakeAccessorHelper (T1 a1, T2 a2); namespace ns3 { - + /** * \ingroup attributeimpl * @@ -145,7 +145,7 @@ struct AccessorTrait typedef typename TypeTraits::ReferencedType>::NonConstType Result; }; - + /** * \ingroup attributeimpl * @@ -161,7 +161,8 @@ class AccessorHelper : public AttributeAccessor { public: /** Constructor */ - AccessorHelper () {} + AccessorHelper () + {} /** * Set the underlying member to the argument AttributeValue. @@ -175,7 +176,8 @@ public: * \param [in] val Generic AttributeValue, to upcast to \p U. * \returns true if the member was set successfully. */ - virtual bool Set (ObjectBase * object, const AttributeValue & val) const { + virtual bool Set (ObjectBase * object, const AttributeValue & val) const + { const U *value = dynamic_cast (&val); if (value == 0) { @@ -201,7 +203,8 @@ public: * \param [out] val Generic AttributeValue, to upcast to \p U. * \returns true if the member value could be retrieved successfully */ - virtual bool Get (const ObjectBase * object, AttributeValue &val) const { + virtual bool Get (const ObjectBase * object, AttributeValue &val) const + { U *value = dynamic_cast (&val); if (value == 0) { @@ -237,7 +240,7 @@ private: }; // class AccessorHelper - + /** * \ingroup attributeimpl * @@ -258,7 +261,7 @@ DoMakeAccessorHelperOne (U T::*memberVariable) /* AttributeAcessor implementation for a class member variable. */ class MemberVariable : public AccessorHelper { -public: + public: /* * Construct from a class data member address. * \param [in] memberVariable The class data member address. @@ -267,8 +270,10 @@ public: : AccessorHelper (), m_memberVariable (memberVariable) {} -private: - virtual bool DoSet (T *object, const V *v) const { + + private: + virtual bool DoSet (T *object, const V *v) const + { typename AccessorTrait::Result tmp; bool ok = v->GetAccessor (tmp); if (!ok) @@ -278,14 +283,17 @@ private: (object->*m_memberVariable) = tmp; return true; } - virtual bool DoGet (const T *object, V *v) const { + virtual bool DoGet (const T *object, V *v) const + { v->Set (object->*m_memberVariable); return true; } - virtual bool HasGetter (void) const { + virtual bool HasGetter (void) const + { return true; } - virtual bool HasSetter (void) const { + virtual bool HasSetter (void) const + { return true; } @@ -294,7 +302,7 @@ private: return Ptr (new MemberVariable (memberVariable), false); } - + /** * \ingroup attributeimpl * @@ -315,7 +323,7 @@ DoMakeAccessorHelperOne (U (T::*getter)(void) const) /* AttributeAccessor implementation with a class get functor method. */ class MemberMethod : public AccessorHelper { -public: + public: /* * Construct from a class get functor method. * \param [in] getter The class get functor method pointer. @@ -324,20 +332,25 @@ public: : AccessorHelper (), m_getter (getter) {} -private: - virtual bool DoSet (T *object, const V *v) const { + + private: + virtual bool DoSet (T *object, const V *v) const + { NS_UNUSED (object); NS_UNUSED (v); return false; } - virtual bool DoGet (const T *object, V *v) const { + virtual bool DoGet (const T *object, V *v) const + { v->Set ((object->*m_getter)()); return true; } - virtual bool HasGetter (void) const { + virtual bool HasGetter (void) const + { return true; } - virtual bool HasSetter (void) const { + virtual bool HasSetter (void) const + { return false; } U (T::*m_getter)(void) const; // The class get functor method pointer. @@ -367,7 +380,7 @@ DoMakeAccessorHelperOne (void (T::*setter)(U)) /* AttributeAccessor implementation with a class set method returning void. */ class MemberMethod : public AccessorHelper { -public: + public: /* * Construct from a class set method. * \param [in] setter The class set method pointer. @@ -376,8 +389,10 @@ public: : AccessorHelper (), m_setter (setter) {} -private: - virtual bool DoSet (T *object, const V *v) const { + + private: + virtual bool DoSet (T *object, const V *v) const + { typename AccessorTrait::Result tmp; bool ok = v->GetAccessor (tmp); if (!ok) @@ -387,15 +402,18 @@ private: (object->*m_setter)(tmp); return true; } - virtual bool DoGet (const T *object, V *v) const { - NS_UNUSED(object); - NS_UNUSED(v); + virtual bool DoGet (const T *object, V *v) const + { + NS_UNUSED (object); + NS_UNUSED (v); return false; } - virtual bool HasGetter (void) const { + virtual bool HasGetter (void) const + { return false; } - virtual bool HasSetter (void) const { + virtual bool HasSetter (void) const + { return true; } void (T::*m_setter)(U); // The class set method pointer, returning void. @@ -403,7 +421,7 @@ private: return Ptr (new MemberMethod (setter), false); } - + /** * \ingroup attributeimpl * @@ -433,7 +451,7 @@ DoMakeAccessorHelperTwo (void (T::*setter)(U), */ class MemberMethod : public AccessorHelper { -public: + public: /* * Construct from class get functor and set methods. * \param [in] setter The class set method pointer, returning void. @@ -445,8 +463,10 @@ public: m_setter (setter), m_getter (getter) {} -private: - virtual bool DoSet (T *object, const W *v) const { + + private: + virtual bool DoSet (T *object, const W *v) const + { typename AccessorTrait::Result tmp; bool ok = v->GetAccessor (tmp); if (!ok) @@ -456,14 +476,17 @@ private: (object->*m_setter)(tmp); return true; } - virtual bool DoGet (const T *object, W *v) const { + virtual bool DoGet (const T *object, W *v) const + { v->Set ((object->*m_getter)()); return true; } - virtual bool HasGetter (void) const { + virtual bool HasGetter (void) const + { return true; } - virtual bool HasSetter (void) const { + virtual bool HasSetter (void) const + { return true; } void (T::*m_setter)(U); // The class set method pointer, returning void. @@ -472,7 +495,7 @@ private: return Ptr (new MemberMethod (setter, getter), false); } - + /** * \ingroup attributeimpl * \copydoc DoMakeAccessorHelperTwo(void(T::*)(U),V(T::*)(void)const) @@ -486,7 +509,7 @@ DoMakeAccessorHelperTwo (V (T::*getter)(void) const, return DoMakeAccessorHelperTwo (setter, getter); } - + /** * \ingroup attributeimpl * @@ -516,7 +539,7 @@ DoMakeAccessorHelperTwo (bool (T::*setter)(U), */ class MemberMethod : public AccessorHelper { -public: + public: /* * Construct from class get functor and set method, returning bool. * \param [in] setter The class set method pointer, returning bool. @@ -528,8 +551,10 @@ public: m_setter (setter), m_getter (getter) {} -private: - virtual bool DoSet (T *object, const W *v) const { + + private: + virtual bool DoSet (T *object, const W *v) const + { typename AccessorTrait::Result tmp; bool ok = v->GetAccessor (tmp); if (!ok) @@ -539,14 +564,17 @@ private: ok = (object->*m_setter)(tmp); return ok; } - virtual bool DoGet (const T *object, W *v) const { + virtual bool DoGet (const T *object, W *v) const + { v->Set ((object->*m_getter)()); return true; } - virtual bool HasGetter (void) const { + virtual bool HasGetter (void) const + { return true; } - virtual bool HasSetter (void) const { + virtual bool HasSetter (void) const + { return true; } bool (T::*m_setter)(U); // The class set method pointer, returning bool. @@ -555,7 +583,7 @@ private: return Ptr (new MemberMethod (setter, getter), false); } - + /** * \ingroup attributeimpl * \copydoc ns3::DoMakeAccessorHelperTwo(bool(T::*)(U),V(T::*)(void)const) diff --git a/src/core/model/attribute-construction-list.cc b/src/core/model/attribute-construction-list.cc index 038842ea0..361af8d83 100644 --- a/src/core/model/attribute-construction-list.cc +++ b/src/core/model/attribute-construction-list.cc @@ -28,14 +28,14 @@ namespace ns3 { -NS_LOG_COMPONENT_DEFINE("AttributeConstructionList"); +NS_LOG_COMPONENT_DEFINE ("AttributeConstructionList"); AttributeConstructionList::AttributeConstructionList () { NS_LOG_FUNCTION (this); } -void +void AttributeConstructionList::Add (std::string name, Ptr checker, Ptr value) { // get rid of any previous value stored in this @@ -58,7 +58,7 @@ AttributeConstructionList::Add (std::string name, Ptr ch m_list.push_back (attr); } -Ptr +Ptr AttributeConstructionList::Find (Ptr checker) const { NS_LOG_FUNCTION (this << checker); @@ -67,23 +67,23 @@ AttributeConstructionList::Find (Ptr checker) const NS_LOG_DEBUG ("Found " << k->name << " " << k->checker << " " << k->value); if (k->checker == checker) { - return k->value; - } - } + return k->value; + } + } return 0; } -AttributeConstructionList::CIterator +AttributeConstructionList::CIterator AttributeConstructionList::Begin (void) const { NS_LOG_FUNCTION (this); - return m_list.begin(); + return m_list.begin (); } AttributeConstructionList::CIterator AttributeConstructionList::End (void) const { NS_LOG_FUNCTION (this); - return m_list.end(); + return m_list.end (); } } // namespace ns3 diff --git a/src/core/model/attribute-construction-list.h b/src/core/model/attribute-construction-list.h index 14881ed3b..5ae3d711e 100644 --- a/src/core/model/attribute-construction-list.h +++ b/src/core/model/attribute-construction-list.h @@ -40,7 +40,7 @@ class AttributeConstructionList { public: /** A single Attribute triple */ - struct Item + struct Item { /** Checker used to validate serialized values. */ Ptr checker; @@ -78,7 +78,7 @@ public: CIterator Begin (void) const; /** \returns The end of the list (iterator to one past the last). */ CIterator End (void) const; - + private: /** The list of Items */ diff --git a/src/core/model/attribute-helper.h b/src/core/model/attribute-helper.h index 8489d3542..bde9b26ce 100644 --- a/src/core/model/attribute-helper.h +++ b/src/core/model/attribute-helper.h @@ -103,22 +103,28 @@ MakeSimpleAttributeChecker (std::string name, std::string underlying) */ struct SimpleAttributeChecker : public BASE { - virtual bool Check (const AttributeValue &value) const { + virtual bool Check (const AttributeValue &value) const + { return dynamic_cast (&value) != 0; } - virtual std::string GetValueTypeName (void) const { + virtual std::string GetValueTypeName (void) const + { return m_type; } - virtual bool HasUnderlyingTypeInformation (void) const { + virtual bool HasUnderlyingTypeInformation (void) const + { return true; } - virtual std::string GetUnderlyingTypeInformation (void) const { + virtual std::string GetUnderlyingTypeInformation (void) const + { return m_underlying; } - virtual Ptr Create (void) const { + virtual Ptr Create (void) const + { return ns3::Create (); } - virtual bool Copy (const AttributeValue &source, AttributeValue &destination) const { + virtual bool Copy (const AttributeValue &source, AttributeValue &destination) const + { const T *src = dynamic_cast (&source); T *dst = dynamic_cast (&destination); if (src == 0 || dst == 0) @@ -146,7 +152,7 @@ MakeSimpleAttributeChecker (std::string name, std::string underlying) * * \param [in] type The name of the class * - * This macro defines and generates the code for the implementation + * This macro defines and generates the code for the implementation * of the \c MakeTypeAccessor template functions. This macro is typically * invoked in a class header to allow users of this class to view and * use the template functions defined here. This macro is implemented @@ -190,16 +196,16 @@ MakeSimpleAttributeChecker (std::string name, std::string underlying) void Set (const type &value); \ type Get (void) const; \ template \ - bool GetAccessor (T &value) const { \ + bool GetAccessor (T & value) const { \ value = T (m_value); \ return true; \ } \ virtual Ptr Copy (void) const; \ virtual std::string \ - SerializeToString (Ptr checker) const; \ + SerializeToString (Ptr checker) const; \ virtual bool \ - DeserializeFromString (std::string value, \ - Ptr checker); \ + DeserializeFromString (std::string value, \ + Ptr checker); \ private: \ type m_value; \ } @@ -262,7 +268,7 @@ MakeSimpleAttributeChecker (std::string name, std::string underlying) * \ingroup attributehelper * * Define the class methods belonging to - * the attribute value class \p nameValue + * the attribute value class \p nameValue * of the underlying class \p type. * * \param [in] type The underlying type name @@ -291,19 +297,19 @@ MakeSimpleAttributeChecker (std::string name, std::string underlying) } \ std::string name ## Value::SerializeToString \ (Ptr checker) const { \ - std::ostringstream oss; \ - oss << m_value; \ - return oss.str (); \ + std::ostringstream oss; \ + oss << m_value; \ + return oss.str (); \ } \ bool name ## Value::DeserializeFromString \ (std::string value, Ptr checker) { \ - std::istringstream iss; \ - iss.str (value); \ - iss >> m_value; \ - NS_ABORT_MSG_UNLESS (iss.eof (), \ - "Attribute value " << "\"" << value << "\"" \ - << " is not properly formatted"); \ - return !iss.bad () && !iss.fail (); \ + std::istringstream iss; \ + iss.str (value); \ + iss >> m_value; \ + NS_ABORT_MSG_UNLESS (iss.eof (), \ + "Attribute value " << "\"" << value << "\"" << \ + " is not properly formatted"); \ + return !iss.bad () && !iss.fail (); \ } /** @@ -338,7 +344,7 @@ MakeSimpleAttributeChecker (std::string name, std::string underlying) #define ATTRIBUTE_CHECKER_IMPLEMENT(type) \ Ptr Make ## type ## Checker (void) { \ return MakeSimpleAttributeChecker \ - (# type "Value", # type); \ + (# type "Value", # type); \ } \ /** @@ -357,7 +363,7 @@ MakeSimpleAttributeChecker (std::string name, std::string underlying) #define ATTRIBUTE_CHECKER_IMPLEMENT_WITH_NAME(type,name) \ Ptr Make ## type ## Checker (void) { \ return MakeSimpleAttributeChecker \ - (# type "Value", name); \ + (# type "Value", name); \ } \ /** diff --git a/src/core/model/attribute.cc b/src/core/model/attribute.cc index 299f6de1f..159a85cce 100644 --- a/src/core/model/attribute.cc +++ b/src/core/model/attribute.cc @@ -35,28 +35,22 @@ namespace ns3 { NS_LOG_COMPONENT_DEFINE ("AttributeValue"); AttributeValue::AttributeValue () -{ -} +{} AttributeValue::~AttributeValue () -{ -} +{} AttributeAccessor::AttributeAccessor () -{ -} +{} AttributeAccessor::~AttributeAccessor () -{ -} +{} AttributeChecker::AttributeChecker () -{ -} +{} AttributeChecker::~AttributeChecker () -{ -} +{} -Ptr +Ptr AttributeChecker::CreateValidValue (const AttributeValue &value) const { NS_LOG_FUNCTION (this << &value); @@ -109,12 +103,10 @@ EmptyAttributeValue::DeserializeFromString (std::string value, Ptr @@ -160,7 +160,7 @@ public: * binding authors to use the checker associated to an attribute * to detect the type of the associated attribute. * - * Most subclasses of this base class are implemented by the + * Most subclasses of this base class are implemented by the * ATTRIBUTE_HELPER_HEADER and ATTRIBUTE_HELPER_CPP macros. */ class AttributeChecker : public SimpleRefCount @@ -207,7 +207,7 @@ public: */ virtual std::string GetUnderlyingTypeInformation (void) const = 0; /** - * \returns a new instance of an AttributeValue (wrapper in an Attribute + * \returns a new instance of an AttributeValue (wrapper in an Attribute * instance) which matches the type of the underlying attribute. * * This method is typically used to create a temporary variable prior @@ -234,6 +234,7 @@ class EmptyAttributeValue : public AttributeValue public: /** Default constructor. */ EmptyAttributeValue (); + private: /** * \returns a deep copy of this class, wrapped into an Attribute object. diff --git a/src/core/model/boolean.cc b/src/core/model/boolean.cc index 7d3aefa6c..5205dac67 100644 --- a/src/core/model/boolean.cc +++ b/src/core/model/boolean.cc @@ -71,14 +71,14 @@ std::ostream & operator << (std::ostream &os, const BooleanValue &value) return os; } -Ptr +Ptr BooleanValue::Copy (void) const { NS_LOG_FUNCTION (this); return Create (*this); } -std::string +std::string BooleanValue::SerializeToString (Ptr checker) const { NS_LOG_FUNCTION (this << checker); @@ -86,27 +86,27 @@ BooleanValue::SerializeToString (Ptr checker) const if (m_value) { return "true"; - } + } else { return "false"; } } -bool +bool BooleanValue::DeserializeFromString (std::string value, Ptr checker) { NS_LOG_FUNCTION (this << value << checker); - if (value == "true" || - value == "1" || - value == "t") + if (value == "true" + || value == "1" + || value == "t") { m_value = true; return true; } - else if (value == "false" || - value == "0" || - value == "f") + else if (value == "false" + || value == "0" + || value == "f") { m_value = false; return true; diff --git a/src/core/model/boolean.h b/src/core/model/boolean.h index 7439c03d1..2308d379b 100644 --- a/src/core/model/boolean.h +++ b/src/core/model/boolean.h @@ -57,6 +57,7 @@ public: virtual Ptr Copy (void) const; virtual std::string SerializeToString (Ptr checker) const; virtual bool DeserializeFromString (std::string value, Ptr checker); + private: bool m_value; }; diff --git a/src/core/model/breakpoint.cc b/src/core/model/breakpoint.cc index a5ce92088..b34d6b7ec 100644 --- a/src/core/model/breakpoint.cc +++ b/src/core/model/breakpoint.cc @@ -56,7 +56,7 @@ BreakpointFallback (void) int *a = 0; /** * we test here to allow a debugger to change the value of - * the variable 'a' to allow the debugger to avoid the + * the variable 'a' to allow the debugger to avoid the * subsequent segfault. */ if (a == 0) diff --git a/src/core/model/breakpoint.h b/src/core/model/breakpoint.h index 8f8169ec5..db1d7ab8d 100644 --- a/src/core/model/breakpoint.h +++ b/src/core/model/breakpoint.h @@ -38,7 +38,7 @@ namespace ns3 { * Modified by the GLib Team and others 1997-2000. See the AUTHORS * file for a list of people on the GLib Team. See the ChangeLog * files for a list of changes. These files are distributed with - * GLib at ftp://ftp.gtk.org/pub/gtk/. + * GLib at ftp://ftp.gtk.org/pub/gtk/. */ /** @@ -79,7 +79,7 @@ namespace ns3 { * for when breakpoint assembly instructions are not available. It * attempts to halt program execution either by a raising SIGTRAP, on * unix systems, or by dereferencing a null pointer. - * + * * Normally you should not call this function directly. */ void BreakpointFallback (void); diff --git a/src/core/model/build-profile.h b/src/core/model/build-profile.h index 4c647fa47..ca5f9985a 100644 --- a/src/core/model/build-profile.h +++ b/src/core/model/build-profile.h @@ -33,13 +33,11 @@ * Build profile no-op macro. * \param [in] code The code to skip. */ -#define NS_BUILD_PROFILE_NOOP(code) \ - do \ - if (false) \ - { \ - code ; \ - } \ - while (false) +#define NS_BUILD_PROFILE_NOOP(code) \ + do if (false) \ + { \ + code; \ + } while (false) /** * \ingroup debugging @@ -49,9 +47,8 @@ #define NS_BUILD_PROFILE_OP(code) \ do \ { \ - code ; \ - } \ - while (false) + code; \ + } while (false) #ifdef NS3_BUILD_PROFILE_DEBUG diff --git a/src/core/model/cairo-wideint-private.h b/src/core/model/cairo-wideint-private.h index 37ccbbf1e..a984eab8e 100644 --- a/src/core/model/cairo-wideint-private.h +++ b/src/core/model/cairo-wideint-private.h @@ -42,12 +42,13 @@ // Adapt to ns-3 environment #include "ns3/core-config.h" -#define cairo_private +#define cairo_private #define HAVE_UINT64_T 1 // Implementation tags added below and in cairo-wideint.c: // extern const char * cairo_impl64; // extern const char * cairo_impl128; +// *NS_CHECK_STYLE_OFF* /*for compatibility with MacOS and Cygwin*/ #ifndef HAVE_STDINT_H @@ -355,5 +356,6 @@ _cairo_int_96by64_32x64_divrem (cairo_int128_t num, }; #endif +// *NS_CHECK_STYLE_ON* #endif /* CAIRO_WIDEINT_H */ diff --git a/src/core/model/cairo-wideint.c b/src/core/model/cairo-wideint.c index 094bc98a3..3d9fe065f 100644 --- a/src/core/model/cairo-wideint.c +++ b/src/core/model/cairo-wideint.c @@ -40,6 +40,8 @@ * Implementation of the cairo_x functions which implement high precision arithmetic. */ +// *NS_CHECK_STYLE_OFF* + #if HAVE_UINT64_T const char * cairo_impl64 = "uint64_t"; diff --git a/src/core/model/calendar-scheduler.cc b/src/core/model/calendar-scheduler.cc index 96c3fd7ca..7912a3c7e 100644 --- a/src/core/model/calendar-scheduler.cc +++ b/src/core/model/calendar-scheduler.cc @@ -175,8 +175,8 @@ CalendarScheduler::DoRemoveNext (void) uint64_t bucketTop = m_bucketTop; int32_t minBucket = -1; Scheduler::EventKey minKey; - NS_ASSERT(!IsEmpty()); - minKey.m_ts = uint64_t(-int64_t(1)); + NS_ASSERT (!IsEmpty ()); + minKey.m_ts = uint64_t (-int64_t (1)); minKey.m_uid = 0; minKey.m_context = 0xffffffff; do @@ -207,7 +207,7 @@ CalendarScheduler::DoRemoveNext (void) m_lastPrio = minKey.m_ts; m_lastBucket = Hash (minKey.m_ts); m_bucketTop = (minKey.m_ts / m_width + 1) * m_width; - Scheduler::Event next = m_buckets[minBucket].front(); + Scheduler::Event next = m_buckets[minBucket].front (); m_buckets[minBucket].pop_front (); return next; diff --git a/src/core/model/calendar-scheduler.h b/src/core/model/calendar-scheduler.h index 2d53db4d9..2f338d469 100644 --- a/src/core/model/calendar-scheduler.h +++ b/src/core/model/calendar-scheduler.h @@ -132,7 +132,7 @@ private: /** Calendar bucket type: a list of Events. */ typedef std::list Bucket; - + /** Array of buckets. */ Bucket *m_buckets; /** Number of buckets in the array. */ diff --git a/src/core/model/callback.cc b/src/core/model/callback.cc index a4876a3e7..352b68811 100644 --- a/src/core/model/callback.cc +++ b/src/core/model/callback.cc @@ -38,8 +38,7 @@ CallbackValue::CallbackValue () } CallbackValue::CallbackValue (const CallbackBase &base) : m_value (base) -{ -} +{} CallbackValue::~CallbackValue () { NS_LOG_FUNCTION (this); @@ -94,28 +93,34 @@ CallbackImplBase::Demangle (const std::string& mangled) NULL, NULL, &status); std::string ret; - if (status == 0) { + if (status == 0) + { NS_ASSERT (demangled); ret = demangled; } - else if (status == -1) { + else if (status == -1) + { NS_LOG_UNCOND ("Callback demangling failed: Memory allocation failure occurred."); ret = mangled; } - else if (status == -2) { + else if (status == -2) + { NS_LOG_UNCOND ("Callback demangling failed: Mangled name is not a valid under the C++ ABI mangling rules."); ret = mangled; } - else if (status == -3) { + else if (status == -3) + { NS_LOG_UNCOND ("Callback demangling failed: One of the arguments is invalid."); ret = mangled; } - else { + else + { NS_LOG_UNCOND ("Callback demangling failed: status " << status); ret = mangled; } - if (demangled) { + if (demangled) + { std::free (demangled); } return ret; diff --git a/src/core/model/callback.h b/src/core/model/callback.h index 11b9d462a..317d9a7a3 100644 --- a/src/core/model/callback.h +++ b/src/core/model/callback.h @@ -102,7 +102,7 @@ namespace ns3 { * or not we really want to use it. */ - + /** * \ingroup makecallbackmemptr * @@ -140,7 +140,8 @@ class CallbackImplBase : public SimpleRefCount { public: /** Virtual destructor */ - virtual ~CallbackImplBase () {} + virtual ~CallbackImplBase () + {} /** * Equality test * @@ -189,7 +190,7 @@ protected: */ template class CallbackImpl; - + /** * \ingroup callbackimpl * CallbackImpl classes with varying numbers of argument types @@ -198,9 +199,11 @@ class CallbackImpl; */ /** CallbackImpl class with no arguments. */ template -class CallbackImpl : public CallbackImplBase { +class CallbackImpl : public CallbackImplBase +{ public: - virtual ~CallbackImpl () {} + virtual ~CallbackImpl () + {} virtual R operator() (void) = 0; //!< Abstract operator virtual std::string GetTypeid (void) const { @@ -217,9 +220,11 @@ public: }; /** CallbackImpl class with one argument. */ template -class CallbackImpl : public CallbackImplBase { +class CallbackImpl : public CallbackImplBase +{ public: - virtual ~CallbackImpl () {} + virtual ~CallbackImpl () + {} virtual R operator() (T1) = 0; //!< Abstract operator virtual std::string GetTypeid (void) const { @@ -237,9 +242,11 @@ public: }; /** CallbackImpl class with two arguments. */ template -class CallbackImpl : public CallbackImplBase { +class CallbackImpl : public CallbackImplBase +{ public: - virtual ~CallbackImpl () {} + virtual ~CallbackImpl () + {} virtual R operator() (T1, T2) = 0; //!< Abstract operator virtual std::string GetTypeid (void) const { @@ -258,9 +265,11 @@ public: }; /** CallbackImpl class with three arguments. */ template -class CallbackImpl : public CallbackImplBase { +class CallbackImpl : public CallbackImplBase +{ public: - virtual ~CallbackImpl () {} + virtual ~CallbackImpl () + {} virtual R operator() (T1, T2, T3) = 0; //!< Abstract operator virtual std::string GetTypeid (void) const { @@ -280,9 +289,11 @@ public: }; /** CallbackImpl class with four arguments. */ template -class CallbackImpl : public CallbackImplBase { +class CallbackImpl : public CallbackImplBase +{ public: - virtual ~CallbackImpl () {} + virtual ~CallbackImpl () + {} virtual R operator() (T1, T2, T3, T4) = 0; //!< Abstract operator virtual std::string GetTypeid (void) const { @@ -303,9 +314,11 @@ public: }; /** CallbackImpl class with five arguments. */ template -class CallbackImpl : public CallbackImplBase { +class CallbackImpl : public CallbackImplBase +{ public: - virtual ~CallbackImpl () {} + virtual ~CallbackImpl () + {} virtual R operator() (T1, T2, T3, T4, T5) = 0; //!< Abstract operator virtual std::string GetTypeid (void) const { @@ -327,9 +340,11 @@ public: }; /** CallbackImpl class with six arguments. */ template -class CallbackImpl : public CallbackImplBase { +class CallbackImpl : public CallbackImplBase +{ public: - virtual ~CallbackImpl () {} + virtual ~CallbackImpl () + {} virtual R operator() (T1, T2, T3, T4, T5, T6) = 0; //!< Abstract operator virtual std::string GetTypeid (void) const { @@ -352,9 +367,11 @@ public: }; /** CallbackImpl class with seven arguments. */ template -class CallbackImpl : public CallbackImplBase { +class CallbackImpl : public CallbackImplBase +{ public: - virtual ~CallbackImpl () {} + virtual ~CallbackImpl () + {} virtual R operator() (T1, T2, T3, T4, T5, T6, T7) = 0; //!< Abstract operator virtual std::string GetTypeid (void) const { @@ -378,9 +395,11 @@ public: }; /** CallbackImpl class with eight arguments. */ template -class CallbackImpl : public CallbackImplBase { +class CallbackImpl : public CallbackImplBase +{ public: - virtual ~CallbackImpl () {} + virtual ~CallbackImpl () + {} virtual R operator() (T1, T2, T3, T4, T5, T6, T7, T8) = 0; //!< Abstract operator virtual std::string GetTypeid (void) const { @@ -405,9 +424,11 @@ public: }; /** CallbackImpl class with nine arguments. */ template -class CallbackImpl : public CallbackImplBase { +class CallbackImpl : public CallbackImplBase +{ public: - virtual ~CallbackImpl () {} + virtual ~CallbackImpl () + {} virtual R operator() (T1, T2, T3, T4, T5, T6, T7, T8, T9) = 0; //!< Abstract operator virtual std::string GetTypeid (void) const { @@ -439,29 +460,34 @@ public: * CallbackImpl with functors */ template -class FunctorCallbackImpl : public CallbackImpl { +class FunctorCallbackImpl : public CallbackImpl +{ public: /** * Construct from a functor * - * \param [in] functor The functor + * \param [in] functor The functor */ FunctorCallbackImpl (T const &functor) - : m_functor (functor) {} - virtual ~FunctorCallbackImpl () {} + : m_functor (functor) + {} + virtual ~FunctorCallbackImpl () + {} /** * Functor with varying numbers of arguments * @{ */ /** \return Callback value */ - R operator() (void) { + R operator() (void) + { return m_functor (); } /** * \param [in] a1 First argument * \return Callback value */ - R operator() (T1 a1) { + R operator() (T1 a1) + { return m_functor (a1); } /** @@ -469,7 +495,8 @@ public: * \param [in] a2 Second argument * \return Callback value */ - R operator() (T1 a1,T2 a2) { + R operator() (T1 a1,T2 a2) + { return m_functor (a1,a2); } /** @@ -478,7 +505,8 @@ public: * \param [in] a3 Third argument * \return Callback value */ - R operator() (T1 a1,T2 a2,T3 a3) { + R operator() (T1 a1,T2 a2,T3 a3) + { return m_functor (a1,a2,a3); } /** @@ -488,7 +516,8 @@ public: * \param [in] a4 Fourth argument * \return Callback value */ - R operator() (T1 a1,T2 a2,T3 a3,T4 a4) { + R operator() (T1 a1,T2 a2,T3 a3,T4 a4) + { return m_functor (a1,a2,a3,a4); } /** @@ -499,7 +528,8 @@ public: * \param [in] a5 Fifth argument * \return Callback value */ - R operator() (T1 a1,T2 a2,T3 a3,T4 a4,T5 a5) { + R operator() (T1 a1,T2 a2,T3 a3,T4 a4,T5 a5) + { return m_functor (a1,a2,a3,a4,a5); } /** @@ -511,7 +541,8 @@ public: * \param [in] a6 Sixth argument * \return Callback value */ - R operator() (T1 a1,T2 a2,T3 a3,T4 a4,T5 a5,T6 a6) { + R operator() (T1 a1,T2 a2,T3 a3,T4 a4,T5 a5,T6 a6) + { return m_functor (a1,a2,a3,a4,a5,a6); } /** @@ -524,7 +555,8 @@ public: * \param [in] a7 Seventh argument * \return Callback value */ - R operator() (T1 a1,T2 a2,T3 a3,T4 a4,T5 a5,T6 a6,T7 a7) { + R operator() (T1 a1,T2 a2,T3 a3,T4 a4,T5 a5,T6 a6,T7 a7) + { return m_functor (a1,a2,a3,a4,a5,a6,a7); } /** @@ -538,7 +570,8 @@ public: * \param [in] a8 eighth argument * \return Callback value */ - R operator() (T1 a1,T2 a2,T3 a3,T4 a4,T5 a5,T6 a6,T7 a7,T8 a8) { + R operator() (T1 a1,T2 a2,T3 a3,T4 a4,T5 a5,T6 a6,T7 a7,T8 a8) + { return m_functor (a1,a2,a3,a4,a5,a6,a7,a8); } /** @@ -553,7 +586,8 @@ public: * \param [in] a9 ninth argument * \return Callback value */ - R operator() (T1 a1,T2 a2,T3 a3,T4 a4,T5 a5,T6 a6,T7 a7,T8 a8,T9 a9) { + R operator() (T1 a1,T2 a2,T3 a3,T4 a4,T5 a5,T6 a6,T7 a7,T8 a8,T9 a9) + { return m_functor (a1,a2,a3,a4,a5,a6,a7,a8,a9); } /**@}*/ @@ -563,8 +597,9 @@ public: * \param [in] other CallbackImpl Ptr * \return \c true if this and other have the same functor */ - virtual bool IsEqual (Ptr other) const { - FunctorCallbackImpl const *otherDerived = + virtual bool IsEqual (Ptr other) const + { + FunctorCallbackImpl const *otherDerived = dynamic_cast const *> (PeekPointer (other)); if (otherDerived == 0) { @@ -576,6 +611,7 @@ public: } return true; } + private: T m_functor; //!< the functor }; @@ -585,7 +621,8 @@ private: * CallbackImpl for pointer to member functions */ template -class MemPtrCallbackImpl : public CallbackImpl { +class MemPtrCallbackImpl : public CallbackImpl +{ public: /** * Construct from an object pointer and member function pointer @@ -594,21 +631,25 @@ public: * \param [in] memPtr The object class member function */ MemPtrCallbackImpl (OBJ_PTR const&objPtr, MEM_PTR memPtr) - : m_objPtr (objPtr), m_memPtr (memPtr) {} - virtual ~MemPtrCallbackImpl () {} + : m_objPtr (objPtr), m_memPtr (memPtr) + {} + virtual ~MemPtrCallbackImpl () + {} /** * Functor with varying numbers of arguments * @{ */ /** \return Callback value */ - R operator() (void) { + R operator() (void) + { return ((CallbackTraits::GetReference (m_objPtr)).*m_memPtr)(); } /** * \param [in] a1 First argument * \return Callback value */ - R operator() (T1 a1) { + R operator() (T1 a1) + { return ((CallbackTraits::GetReference (m_objPtr)).*m_memPtr)(a1); } /** @@ -616,7 +657,8 @@ public: * \param [in] a2 Second argument * \return Callback value */ - R operator() (T1 a1,T2 a2) { + R operator() (T1 a1,T2 a2) + { return ((CallbackTraits::GetReference (m_objPtr)).*m_memPtr)(a1, a2); } /** @@ -625,7 +667,8 @@ public: * \param [in] a3 Third argument * \return Callback value */ - R operator() (T1 a1,T2 a2,T3 a3) { + R operator() (T1 a1,T2 a2,T3 a3) + { return ((CallbackTraits::GetReference (m_objPtr)).*m_memPtr)(a1, a2, a3); } /** @@ -635,7 +678,8 @@ public: * \param [in] a4 Fourth argument * \return Callback value */ - R operator() (T1 a1,T2 a2,T3 a3,T4 a4) { + R operator() (T1 a1,T2 a2,T3 a3,T4 a4) + { return ((CallbackTraits::GetReference (m_objPtr)).*m_memPtr)(a1, a2, a3, a4); } /** @@ -646,7 +690,8 @@ public: * \param [in] a5 Fifth argument * \return Callback value */ - R operator() (T1 a1,T2 a2,T3 a3,T4 a4,T5 a5) { + R operator() (T1 a1,T2 a2,T3 a3,T4 a4,T5 a5) + { return ((CallbackTraits::GetReference (m_objPtr)).*m_memPtr)(a1, a2, a3, a4, a5); } /** @@ -658,7 +703,8 @@ public: * \param [in] a6 Sixth argument * \return Callback value */ - R operator() (T1 a1,T2 a2,T3 a3,T4 a4,T5 a5,T6 a6) { + R operator() (T1 a1,T2 a2,T3 a3,T4 a4,T5 a5,T6 a6) + { return ((CallbackTraits::GetReference (m_objPtr)).*m_memPtr)(a1, a2, a3, a4, a5, a6); } /** @@ -671,7 +717,8 @@ public: * \param [in] a7 Seventh argument * \return Callback value */ - R operator() (T1 a1,T2 a2,T3 a3,T4 a4,T5 a5,T6 a6,T7 a7) { + R operator() (T1 a1,T2 a2,T3 a3,T4 a4,T5 a5,T6 a6,T7 a7) + { return ((CallbackTraits::GetReference (m_objPtr)).*m_memPtr)(a1, a2, a3, a4, a5, a6, a7); } /** @@ -685,7 +732,8 @@ public: * \param [in] a8 Eighth argument * \return Callback value */ - R operator() (T1 a1,T2 a2,T3 a3,T4 a4,T5 a5,T6 a6,T7 a7,T8 a8) { + R operator() (T1 a1,T2 a2,T3 a3,T4 a4,T5 a5,T6 a6,T7 a7,T8 a8) + { return ((CallbackTraits::GetReference (m_objPtr)).*m_memPtr)(a1, a2, a3, a4, a5, a6, a7, a8); } /** @@ -700,7 +748,8 @@ public: * \param [in] a9 Ninth argument * \return Callback value */ - R operator() (T1 a1,T2 a2,T3 a3,T4 a4,T5 a5,T6 a6,T7 a7,T8 a8, T9 a9) { + R operator() (T1 a1,T2 a2,T3 a3,T4 a4,T5 a5,T6 a6,T7 a7,T8 a8, T9 a9) + { return ((CallbackTraits::GetReference (m_objPtr)).*m_memPtr)(a1, a2, a3, a4, a5, a6, a7, a8, a9); } /**@}*/ @@ -710,20 +759,22 @@ public: * \param [in] other Callback Ptr * \return \c true if we have the same object and member function */ - virtual bool IsEqual (Ptr other) const { - MemPtrCallbackImpl const *otherDerived = + virtual bool IsEqual (Ptr other) const + { + MemPtrCallbackImpl const *otherDerived = dynamic_cast const *> (PeekPointer (other)); if (otherDerived == 0) { return false; } - else if (otherDerived->m_objPtr != m_objPtr || - otherDerived->m_memPtr != m_memPtr) + else if (otherDerived->m_objPtr != m_objPtr + || otherDerived->m_memPtr != m_memPtr) { return false; } return true; } + private: OBJ_PTR const m_objPtr; //!< the object pointer MEM_PTR m_memPtr; //!< the member function pointer @@ -734,30 +785,35 @@ private: * CallbackImpl for functors with first argument bound at construction */ template -class BoundFunctorCallbackImpl : public CallbackImpl { +class BoundFunctorCallbackImpl : public CallbackImpl +{ public: /** * Construct from functor and a bound argument - * \param [in] functor The functor + * \param [in] functor The functor * \param [in] a The argument to bind */ template BoundFunctorCallbackImpl (FUNCTOR functor, ARG a) - : m_functor (functor), m_a (a) {} - virtual ~BoundFunctorCallbackImpl () {} + : m_functor (functor), m_a (a) + {} + virtual ~BoundFunctorCallbackImpl () + {} /** * Functor with varying numbers of arguments * @{ */ /** \return Callback value */ - R operator() (void) { + R operator() (void) + { return m_functor (m_a); } /** * \param [in] a1 First argument * \return Callback value */ - R operator() (T1 a1) { + R operator() (T1 a1) + { return m_functor (m_a,a1); } /** @@ -765,7 +821,8 @@ public: * \param [in] a2 Second argument * \return Callback value */ - R operator() (T1 a1,T2 a2) { + R operator() (T1 a1,T2 a2) + { return m_functor (m_a,a1,a2); } /** @@ -774,7 +831,8 @@ public: * \param [in] a3 Third argument * \return Callback value */ - R operator() (T1 a1,T2 a2,T3 a3) { + R operator() (T1 a1,T2 a2,T3 a3) + { return m_functor (m_a,a1,a2,a3); } /** @@ -784,7 +842,8 @@ public: * \param [in] a4 Fourth argument * \return Callback value */ - R operator() (T1 a1,T2 a2,T3 a3,T4 a4) { + R operator() (T1 a1,T2 a2,T3 a3,T4 a4) + { return m_functor (m_a,a1,a2,a3,a4); } /** @@ -795,7 +854,8 @@ public: * \param [in] a5 Fifth argument * \return Callback value */ - R operator() (T1 a1,T2 a2,T3 a3,T4 a4,T5 a5) { + R operator() (T1 a1,T2 a2,T3 a3,T4 a4,T5 a5) + { return m_functor (m_a,a1,a2,a3,a4,a5); } /** @@ -807,7 +867,8 @@ public: * \param [in] a6 Sixth argument * \return Callback value */ - R operator() (T1 a1,T2 a2,T3 a3,T4 a4,T5 a5,T6 a6) { + R operator() (T1 a1,T2 a2,T3 a3,T4 a4,T5 a5,T6 a6) + { return m_functor (m_a,a1,a2,a3,a4,a5,a6); } /** @@ -820,7 +881,8 @@ public: * \param [in] a7 Seventh argument * \return Callback value */ - R operator() (T1 a1,T2 a2,T3 a3,T4 a4,T5 a5,T6 a6,T7 a7) { + R operator() (T1 a1,T2 a2,T3 a3,T4 a4,T5 a5,T6 a6,T7 a7) + { return m_functor (m_a,a1,a2,a3,a4,a5,a6,a7); } /** @@ -834,7 +896,8 @@ public: * \param [in] a8 Eighth argument * \return Callback value */ - R operator() (T1 a1,T2 a2,T3 a3,T4 a4,T5 a5,T6 a6,T7 a7,T8 a8) { + R operator() (T1 a1,T2 a2,T3 a3,T4 a4,T5 a5,T6 a6,T7 a7,T8 a8) + { return m_functor (m_a,a1,a2,a3,a4,a5,a6,a7,a8); } /**@}*/ @@ -844,20 +907,22 @@ public: * \param [in] other Callback Ptr * \return \c true if we have the same functor and bound arguments */ - virtual bool IsEqual (Ptr other) const { - BoundFunctorCallbackImpl const *otherDerived = + virtual bool IsEqual (Ptr other) const + { + BoundFunctorCallbackImpl const *otherDerived = dynamic_cast const *> (PeekPointer (other)); if (otherDerived == 0) { return false; } - else if (otherDerived->m_functor != m_functor || - otherDerived->m_a != m_a) + else if (otherDerived->m_functor != m_functor + || otherDerived->m_a != m_a) { return false; } return true; } + private: T m_functor; //!< The functor typename TypeTraits::ReferencedType m_a; //!< the bound argument @@ -868,7 +933,8 @@ private: * CallbackImpl for functors with first two arguments bound at construction */ template -class TwoBoundFunctorCallbackImpl : public CallbackImpl { +class TwoBoundFunctorCallbackImpl : public CallbackImpl +{ public: /** * Construct from functor and two arguments @@ -878,21 +944,25 @@ public: */ template TwoBoundFunctorCallbackImpl (FUNCTOR functor, ARG1 arg1, ARG2 arg2) - : m_functor (functor), m_a1 (arg1), m_a2 (arg2) {} - virtual ~TwoBoundFunctorCallbackImpl () {} + : m_functor (functor), m_a1 (arg1), m_a2 (arg2) + {} + virtual ~TwoBoundFunctorCallbackImpl () + {} /** * Functor with varying numbers of arguments * @{ */ /** \return Callback value */ - R operator() (void) { + R operator() (void) + { return m_functor (m_a1,m_a2); } /** * \param [in] a1 First argument * \return Callback value */ - R operator() (T1 a1) { + R operator() (T1 a1) + { return m_functor (m_a1,m_a2,a1); } /** @@ -900,7 +970,8 @@ public: * \param [in] a2 Second argument * \return Callback value */ - R operator() (T1 a1,T2 a2) { + R operator() (T1 a1,T2 a2) + { return m_functor (m_a1,m_a2,a1,a2); } /** @@ -909,7 +980,8 @@ public: * \param [in] a3 Third argument * \return Callback value */ - R operator() (T1 a1,T2 a2,T3 a3) { + R operator() (T1 a1,T2 a2,T3 a3) + { return m_functor (m_a1,m_a2,a1,a2,a3); } /** @@ -919,7 +991,8 @@ public: * \param [in] a4 Fourth argument * \return Callback value */ - R operator() (T1 a1,T2 a2,T3 a3,T4 a4) { + R operator() (T1 a1,T2 a2,T3 a3,T4 a4) + { return m_functor (m_a1,m_a2,a1,a2,a3,a4); } /** @@ -930,7 +1003,8 @@ public: * \param [in] a5 Fifth argument * \return Callback value */ - R operator() (T1 a1,T2 a2,T3 a3,T4 a4,T5 a5) { + R operator() (T1 a1,T2 a2,T3 a3,T4 a4,T5 a5) + { return m_functor (m_a1,m_a2,a1,a2,a3,a4,a5); } /** @@ -942,7 +1016,8 @@ public: * \param [in] a6 Sixth argument * \return Callback value */ - R operator() (T1 a1,T2 a2,T3 a3,T4 a4,T5 a5,T6 a6) { + R operator() (T1 a1,T2 a2,T3 a3,T4 a4,T5 a5,T6 a6) + { return m_functor (m_a1,m_a2,a1,a2,a3,a4,a5,a6); } /** @@ -955,7 +1030,8 @@ public: * \param [in] a7 Seventh argument * \return Callback value */ - R operator() (T1 a1,T2 a2,T3 a3,T4 a4,T5 a5,T6 a6,T7 a7) { + R operator() (T1 a1,T2 a2,T3 a3,T4 a4,T5 a5,T6 a6,T7 a7) + { return m_functor (m_a1,m_a2,a1,a2,a3,a4,a5,a6,a7); } /**@}*/ @@ -965,20 +1041,22 @@ public: * \param [in] other Callback Ptr * \return \c true if we have the same functor and bound arguments */ - virtual bool IsEqual (Ptr other) const { - TwoBoundFunctorCallbackImpl const *otherDerived = + virtual bool IsEqual (Ptr other) const + { + TwoBoundFunctorCallbackImpl const *otherDerived = dynamic_cast const *> (PeekPointer (other)); if (otherDerived == 0) { return false; } - else if (otherDerived->m_functor != m_functor || - otherDerived->m_a1 != m_a1 || otherDerived->m_a2 != m_a2) + else if (otherDerived->m_functor != m_functor + || otherDerived->m_a1 != m_a1 || otherDerived->m_a2 != m_a2) { return false; } return true; } + private: T m_functor; //!< The functor typename TypeTraits::ReferencedType m_a1; //!< first bound argument @@ -990,7 +1068,8 @@ private: * CallbackImpl for functors with first three arguments bound at construction */ template -class ThreeBoundFunctorCallbackImpl : public CallbackImpl { +class ThreeBoundFunctorCallbackImpl : public CallbackImpl +{ public: /** * Construct from functor and three arguments @@ -1001,21 +1080,25 @@ public: */ template ThreeBoundFunctorCallbackImpl (FUNCTOR functor, ARG1 arg1, ARG2 arg2, ARG3 arg3) - : m_functor (functor), m_a1 (arg1), m_a2 (arg2), m_a3 (arg3) {} - virtual ~ThreeBoundFunctorCallbackImpl () {} + : m_functor (functor), m_a1 (arg1), m_a2 (arg2), m_a3 (arg3) + {} + virtual ~ThreeBoundFunctorCallbackImpl () + {} /** * Functor with varying numbers of arguments * @{ */ /** \return Callback value */ - R operator() (void) { + R operator() (void) + { return m_functor (m_a1,m_a2,m_a3); } /** * \param [in] a1 First argument * \return Callback value */ - R operator() (T1 a1) { + R operator() (T1 a1) + { return m_functor (m_a1,m_a2,m_a3,a1); } /** @@ -1023,7 +1106,8 @@ public: * \param [in] a2 Second argument * \return Callback value */ - R operator() (T1 a1,T2 a2) { + R operator() (T1 a1,T2 a2) + { return m_functor (m_a1,m_a2,m_a3,a1,a2); } /** @@ -1032,7 +1116,8 @@ public: * \param [in] a3 Third argument * \return Callback value */ - R operator() (T1 a1,T2 a2,T3 a3) { + R operator() (T1 a1,T2 a2,T3 a3) + { return m_functor (m_a1,m_a2,m_a3,a1,a2,a3); } /** @@ -1042,7 +1127,8 @@ public: * \param [in] a4 Fourth argument * \return Callback value */ - R operator() (T1 a1,T2 a2,T3 a3,T4 a4) { + R operator() (T1 a1,T2 a2,T3 a3,T4 a4) + { return m_functor (m_a1,m_a2,m_a3,a1,a2,a3,a4); } /** @@ -1053,7 +1139,8 @@ public: * \param [in] a5 Fifth argument * \return Callback value */ - R operator() (T1 a1,T2 a2,T3 a3,T4 a4,T5 a5) { + R operator() (T1 a1,T2 a2,T3 a3,T4 a4,T5 a5) + { return m_functor (m_a1,m_a2,m_a3,a1,a2,a3,a4,a5); } /** @@ -1065,7 +1152,8 @@ public: * \param [in] a6 Sixth argument * \return Callback value */ - R operator() (T1 a1,T2 a2,T3 a3,T4 a4,T5 a5,T6 a6) { + R operator() (T1 a1,T2 a2,T3 a3,T4 a4,T5 a5,T6 a6) + { return m_functor (m_a1,m_a2,m_a3,a1,a2,a3,a4,a5,a6); } /**@}*/ @@ -1075,23 +1163,25 @@ public: * \param [in] other Callback Ptr * \return \c true if we have the same functor and bound arguments */ - virtual bool IsEqual (Ptr other) const { - ThreeBoundFunctorCallbackImpl const *otherDerived = + virtual bool IsEqual (Ptr other) const + { + ThreeBoundFunctorCallbackImpl const *otherDerived = dynamic_cast const *> (PeekPointer (other)); if (otherDerived == 0) { return false; } - else if (otherDerived->m_functor != m_functor || - otherDerived->m_a1 != m_a1 || otherDerived->m_a2 != m_a2 || otherDerived->m_a3 != m_a3) + else if (otherDerived->m_functor != m_functor + || otherDerived->m_a1 != m_a1 || otherDerived->m_a2 != m_a2 || otherDerived->m_a3 != m_a3) { return false; } return true; } + private: - T m_functor; //!< The functor - typename TypeTraits::ReferencedType m_a1; //!< first bound argument + T m_functor; //!< The functor + typename TypeTraits::ReferencedType m_a1; //!< first bound argument typename TypeTraits::ReferencedType m_a2; //!< second bound argument typename TypeTraits::ReferencedType m_a3; //!< third bound argument }; @@ -1101,17 +1191,24 @@ private: * Base class for Callback class. * Provides pimpl abstraction. */ -class CallbackBase { +class CallbackBase +{ public: - CallbackBase () : m_impl () {} + CallbackBase () : m_impl () + {} /** \return The impl pointer */ - Ptr GetImpl (void) const { return m_impl; } + Ptr GetImpl (void) const + { + return m_impl; + } + protected: /** * Construct from a pimpl * \param [in] impl The CallbackImplBase Ptr */ - CallbackBase (Ptr impl) : m_impl (impl) {} + CallbackBase (Ptr impl) : m_impl (impl) + {} Ptr m_impl; //!< the pimpl }; @@ -1133,22 +1230,22 @@ protected: * user intervention which allows you to pass around Callback * instances by value. * - * Sample code which shows how to use this class template + * Sample code which shows how to use this class template * as well as the function templates \ref MakeCallback : * \include src/core/examples/main-callback.cc * * \internal - * This code was originally written based on the techniques + * This code was originally written based on the techniques * described in http://www.codeproject.com/cpp/TTLFunction.asp * It was subsequently rewritten to follow the architecture - * outlined in "Modern C++ Design" by Andrei Alexandrescu in + * outlined in "Modern C++ Design" by Andrei Alexandrescu in * chapter 5, "Generalized Functors". * * This code uses: * - default template parameters to saves users from having to * specify empty parameters when the number of parameters * is smaller than the maximum supported number - * - the pimpl idiom: the Callback class is passed around by + * - the pimpl idiom: the Callback class is passed around by * value and delegates the crux of the work to its pimpl * pointer. * - two pimpl implementations which derive from CallbackImpl @@ -1158,7 +1255,7 @@ protected: * - a reference list implementation to implement the Callback's * value semantics. * - * This code most notably departs from the alexandrescu + * This code most notably departs from the alexandrescu * implementation in that it does not use type lists to specify * and pass around the types of the callback arguments. * Of course, it also does not use copy-destruction semantics @@ -1167,15 +1264,17 @@ protected: * * \see attribute_Callback */ -template -class Callback : public CallbackBase { +class Callback : public CallbackBase +{ public: - Callback () {} + Callback () + {} /** * Construct a functor call back, supporting operator() calls @@ -1187,7 +1286,7 @@ public: * always properly disambiguated by the c++ compiler. */ template - Callback (FUNCTOR const &functor, bool, bool) + Callback (FUNCTOR const &functor, bool, bool) : CallbackBase (Create > (functor)) {} @@ -1218,7 +1317,8 @@ public: * \return The bound callback */ template - Callback Bind (T a) { + Callback Bind (T a) + { Ptr > impl = Ptr > ( new BoundFunctorCallbackImpl< @@ -1235,7 +1335,8 @@ public: * \return The bound callback */ template - Callback TwoBind (TX1 a1, TX2 a2) { + Callback TwoBind (TX1 a1, TX2 a2) + { Ptr > impl = Ptr > ( new TwoBoundFunctorCallbackImpl< @@ -1253,7 +1354,8 @@ public: * \return The bound callback */ template - Callback ThreeBind (TX1 a1, TX2 a2, TX3 a3) { + Callback ThreeBind (TX1 a1, TX2 a2, TX3 a3) + { Ptr > impl = Ptr > ( new ThreeBoundFunctorCallbackImpl< @@ -1267,11 +1369,13 @@ public: * * \return \c true if I don't have an implementation */ - bool IsNull (void) const { + bool IsNull (void) const + { return (DoPeekImpl () == 0) ? true : false; } /** Discard the implementation, set it to null */ - void Nullify (void) { + void Nullify (void) + { m_impl = 0; } @@ -1280,14 +1384,16 @@ public: * @{ */ /** \return Callback value */ - R operator() (void) const { + R operator() (void) const + { return (*(DoPeekImpl ()))(); } /** * \param [in] a1 First argument * \return Callback value */ - R operator() (T1 a1) const { + R operator() (T1 a1) const + { return (*(DoPeekImpl ()))(a1); } /** @@ -1295,7 +1401,8 @@ public: * \param [in] a2 Second argument * \return Callback value */ - R operator() (T1 a1, T2 a2) const { + R operator() (T1 a1, T2 a2) const + { return (*(DoPeekImpl ()))(a1,a2); } /** @@ -1304,7 +1411,8 @@ public: * \param [in] a3 Third argument * \return Callback value */ - R operator() (T1 a1, T2 a2, T3 a3) const { + R operator() (T1 a1, T2 a2, T3 a3) const + { return (*(DoPeekImpl ()))(a1,a2,a3); } /** @@ -1314,7 +1422,8 @@ public: * \param [in] a4 Fourth argument * \return Callback value */ - R operator() (T1 a1, T2 a2, T3 a3, T4 a4) const { + R operator() (T1 a1, T2 a2, T3 a3, T4 a4) const + { return (*(DoPeekImpl ()))(a1,a2,a3,a4); } /** @@ -1325,7 +1434,8 @@ public: * \param [in] a5 Fifth argument * \return Callback value */ - R operator() (T1 a1, T2 a2, T3 a3, T4 a4,T5 a5) const { + R operator() (T1 a1, T2 a2, T3 a3, T4 a4,T5 a5) const + { return (*(DoPeekImpl ()))(a1,a2,a3,a4,a5); } /** @@ -1337,7 +1447,8 @@ public: * \param [in] a6 Sixth argument * \return Callback value */ - R operator() (T1 a1, T2 a2, T3 a3, T4 a4,T5 a5,T6 a6) const { + R operator() (T1 a1, T2 a2, T3 a3, T4 a4,T5 a5,T6 a6) const + { return (*(DoPeekImpl ()))(a1,a2,a3,a4,a5,a6); } /** @@ -1350,7 +1461,8 @@ public: * \param [in] a7 Seventh argument * \return Callback value */ - R operator() (T1 a1, T2 a2, T3 a3, T4 a4,T5 a5,T6 a6,T7 a7) const { + R operator() (T1 a1, T2 a2, T3 a3, T4 a4,T5 a5,T6 a6,T7 a7) const + { return (*(DoPeekImpl ()))(a1,a2,a3,a4,a5,a6,a7); } /** @@ -1364,7 +1476,8 @@ public: * \param [in] a8 Eighth argument * \return Callback value */ - R operator() (T1 a1, T2 a2, T3 a3, T4 a4,T5 a5,T6 a6,T7 a7,T8 a8) const { + R operator() (T1 a1, T2 a2, T3 a3, T4 a4,T5 a5,T6 a6,T7 a7,T8 a8) const + { return (*(DoPeekImpl ()))(a1,a2,a3,a4,a5,a6,a7,a8); } /** @@ -1379,7 +1492,8 @@ public: * \param [in] a9 Ninth argument * \return Callback value */ - R operator() (T1 a1, T2 a2, T3 a3, T4 a4,T5 a5,T6 a6,T7 a7,T8 a8, T9 a9) const { + R operator() (T1 a1, T2 a2, T3 a3, T4 a4,T5 a5,T6 a6,T7 a7,T8 a8, T9 a9) const + { return (*(DoPeekImpl ()))(a1,a2,a3,a4,a5,a6,a7,a8,a9); } /**@}*/ @@ -1390,7 +1504,8 @@ public: * \param [in] other Callback * \return \c true if we are equal */ - bool IsEqual (const CallbackBase &other) const { + bool IsEqual (const CallbackBase &other) const + { return m_impl->IsEqual (other.GetImpl ()); } @@ -1400,7 +1515,8 @@ public: * \param [in] other Callback Ptr * \return \c true if other can be dynamic_cast to my type */ - bool CheckType (const CallbackBase & other) const { + bool CheckType (const CallbackBase & other) const + { return DoCheckType (other.GetImpl ()); } /** @@ -1409,12 +1525,15 @@ public: * \param [in] other Callback * \returns \c true if \p other was type-compatible and could be adopted. */ - bool Assign (const CallbackBase &other) { + bool Assign (const CallbackBase &other) + { return DoAssign (other.GetImpl ()); } + private: /** \return The pimpl pointer */ - CallbackImpl *DoPeekImpl (void) const { + CallbackImpl * DoPeekImpl (void) const + { return static_cast *> (PeekPointer (m_impl)); } /** @@ -1423,9 +1542,10 @@ private: * \param [in] other Callback Ptr * \return \c true if other can be dynamic_cast to my type */ - bool DoCheckType (Ptr other) const { - if (other != 0 && - dynamic_cast *> (PeekPointer (other)) != 0) + bool DoCheckType (Ptr other) const + { + if (other != 0 + && dynamic_cast *> (PeekPointer (other)) != 0) { return true; } @@ -1439,14 +1559,15 @@ private: } } /** \copydoc Assign */ - bool DoAssign (Ptr other) { + bool DoAssign (Ptr other) + { if (!DoCheckType (other)) { std::string othTid = other->GetTypeid (); std::string myTid = CallbackImpl::DoGetTypeid (); NS_FATAL_ERROR_CONT ("Incompatible types. (feed to \"c++filt -t\" if needed)" << std::endl << - "got=" << othTid << std::endl << - "expected=" << myTid); + "got=" << othTid << std::endl << + "expected=" << myTid); return false; } m_impl = const_cast (PeekPointer (other)); @@ -1481,88 +1602,108 @@ bool operator != (Callback a, Callback -Callback MakeCallback (R (T::*memPtr)(void), OBJ objPtr) { +Callback MakeCallback (R (T::*memPtr)(void), OBJ objPtr) +{ return Callback (objPtr, memPtr); } template -Callback MakeCallback (R (T::*memPtr)() const, OBJ objPtr) { +Callback MakeCallback (R (T::*memPtr)() const, OBJ objPtr) +{ return Callback (objPtr, memPtr); } template -Callback MakeCallback (R (T::*memPtr)(T1), OBJ objPtr) { +Callback MakeCallback (R (T::*memPtr)(T1), OBJ objPtr) +{ return Callback (objPtr, memPtr); } template -Callback MakeCallback (R (T::*memPtr)(T1) const, OBJ objPtr) { +Callback MakeCallback (R (T::*memPtr)(T1) const, OBJ objPtr) +{ return Callback (objPtr, memPtr); } template -Callback MakeCallback (R (T::*memPtr)(T1,T2), OBJ objPtr) { +Callback MakeCallback (R (T::*memPtr)(T1,T2), OBJ objPtr) +{ return Callback (objPtr, memPtr); } template -Callback MakeCallback (R (T::*memPtr)(T1,T2) const, OBJ objPtr) { +Callback MakeCallback (R (T::*memPtr)(T1,T2) const, OBJ objPtr) +{ return Callback (objPtr, memPtr); } template -Callback MakeCallback (R (T::*memPtr)(T1,T2,T3), OBJ objPtr) { +Callback MakeCallback (R (T::*memPtr)(T1,T2,T3), OBJ objPtr) +{ return Callback (objPtr, memPtr); } template -Callback MakeCallback (R (T::*memPtr)(T1,T2,T3) const, OBJ objPtr) { +Callback MakeCallback (R (T::*memPtr)(T1,T2,T3) const, OBJ objPtr) +{ return Callback (objPtr, memPtr); } template -Callback MakeCallback (R (T::*memPtr)(T1,T2,T3,T4), OBJ objPtr) { +Callback MakeCallback (R (T::*memPtr)(T1,T2,T3,T4), OBJ objPtr) +{ return Callback (objPtr, memPtr); } template -Callback MakeCallback (R (T::*memPtr)(T1,T2,T3,T4) const, OBJ objPtr) { +Callback MakeCallback (R (T::*memPtr)(T1,T2,T3,T4) const, OBJ objPtr) +{ return Callback (objPtr, memPtr); } template -Callback MakeCallback (R (T::*memPtr)(T1,T2,T3,T4,T5), OBJ objPtr) { +Callback MakeCallback (R (T::*memPtr)(T1,T2,T3,T4,T5), OBJ objPtr) +{ return Callback (objPtr, memPtr); } template -Callback MakeCallback (R (T::*memPtr)(T1,T2,T3,T4,T5) const, OBJ objPtr) { +Callback MakeCallback (R (T::*memPtr)(T1,T2,T3,T4,T5) const, OBJ objPtr) +{ return Callback (objPtr, memPtr); } template -Callback MakeCallback (R (T::*memPtr)(T1,T2,T3,T4,T5,T6), OBJ objPtr) { +Callback MakeCallback (R (T::*memPtr)(T1,T2,T3,T4,T5,T6), OBJ objPtr) +{ return Callback (objPtr, memPtr); } template -Callback MakeCallback (R (T::*memPtr)(T1,T2,T3,T4,T5,T6) const, OBJ objPtr) { +Callback MakeCallback (R (T::*memPtr)(T1,T2,T3,T4,T5,T6) const, OBJ objPtr) +{ return Callback (objPtr, memPtr); } template -Callback MakeCallback (R (T::*memPtr)(T1,T2,T3,T4,T5,T6,T7), OBJ objPtr) { +Callback MakeCallback (R (T::*memPtr)(T1,T2,T3,T4,T5,T6,T7), OBJ objPtr) +{ return Callback (objPtr, memPtr); } template -Callback MakeCallback (R (T::*memPtr)(T1,T2,T3,T4,T5,T6,T7) const, OBJ objPtr) { +Callback MakeCallback (R (T::*memPtr)(T1,T2,T3,T4,T5,T6,T7) const, OBJ objPtr) +{ return Callback (objPtr, memPtr); } template -Callback MakeCallback (R (T::*memPtr)(T1,T2,T3,T4,T5,T6,T7,T8), OBJ objPtr) { +Callback MakeCallback (R (T::*memPtr)(T1,T2,T3,T4,T5,T6,T7,T8), OBJ objPtr) +{ return Callback (objPtr, memPtr); } template -Callback MakeCallback (R (T::*memPtr)(T1,T2,T3,T4,T5,T6,T7,T8) const, OBJ objPtr) { +Callback MakeCallback (R (T::*memPtr)(T1,T2,T3,T4,T5,T6,T7,T8) const, OBJ objPtr) +{ return Callback (objPtr, memPtr); } template -Callback MakeCallback (R (T::*memPtr)(T1,T2,T3,T4,T5,T6,T7,T8,T9), OBJ objPtr) { +Callback MakeCallback (R (T::*memPtr)(T1,T2,T3,T4,T5,T6,T7,T8,T9), OBJ objPtr) +{ return Callback (objPtr, memPtr); } template -Callback MakeCallback (R (T::*memPtr)(T1,T2,T3,T4,T5,T6,T7,T8,T9) const, OBJ objPtr) { +Callback MakeCallback (R (T::*memPtr)(T1,T2,T3,T4,T5,T6,T7,T8,T9) const, OBJ objPtr) +{ return Callback (objPtr, memPtr); } /**@}*/ @@ -1574,48 +1715,58 @@ Callback MakeCallback (R (T::*memPtr)(T1,T2,T3,T4, /** * \param [in] fnPtr Function pointer * \return A wrapper Callback - * + * * Build Callbacks for functions which take varying numbers of arguments * and potentially returning a value. */ template -Callback MakeCallback (R (*fnPtr)()) { +Callback MakeCallback (R (*fnPtr)()) +{ return Callback (fnPtr, true, true); } template -Callback MakeCallback (R (*fnPtr)(T1)) { +Callback MakeCallback (R (*fnPtr)(T1)) +{ return Callback (fnPtr, true, true); } template -Callback MakeCallback (R (*fnPtr)(T1,T2)) { +Callback MakeCallback (R (*fnPtr)(T1,T2)) +{ return Callback (fnPtr, true, true); } template -Callback MakeCallback (R (*fnPtr)(T1,T2,T3)) { +Callback MakeCallback (R (*fnPtr)(T1,T2,T3)) +{ return Callback (fnPtr, true, true); } template -Callback MakeCallback (R (*fnPtr)(T1,T2,T3,T4)) { +Callback MakeCallback (R (*fnPtr)(T1,T2,T3,T4)) +{ return Callback (fnPtr, true, true); } template -Callback MakeCallback (R (*fnPtr)(T1,T2,T3,T4,T5)) { +Callback MakeCallback (R (*fnPtr)(T1,T2,T3,T4,T5)) +{ return Callback (fnPtr, true, true); } template -Callback MakeCallback (R (*fnPtr)(T1,T2,T3,T4,T5,T6)) { +Callback MakeCallback (R (*fnPtr)(T1,T2,T3,T4,T5,T6)) +{ return Callback (fnPtr, true, true); } template -Callback MakeCallback (R (*fnPtr)(T1,T2,T3,T4,T5,T6,T7)) { +Callback MakeCallback (R (*fnPtr)(T1,T2,T3,T4,T5,T6,T7)) +{ return Callback (fnPtr, true, true); } template -Callback MakeCallback (R (*fnPtr)(T1,T2,T3,T4,T5,T6,T7,T8)) { +Callback MakeCallback (R (*fnPtr)(T1,T2,T3,T4,T5,T6,T7,T8)) +{ return Callback (fnPtr, true, true); } template -Callback MakeCallback (R (*fnPtr)(T1,T2,T3,T4,T5,T6,T7,T8,T9)) { +Callback MakeCallback (R (*fnPtr)(T1,T2,T3,T4,T5,T6,T7,T8,T9)) +{ return Callback (fnPtr, true, true); } /**@}*/ @@ -1630,45 +1781,55 @@ Callback MakeCallback (R (*fnPtr)(T1,T2,T3,T4,T5,T * Build null Callbacks which take no arguments, * for varying number of template arguments, * and potentially returning a value. - */ + */ template -Callback MakeNullCallback (void) { +Callback MakeNullCallback (void) +{ return Callback (); } template -Callback MakeNullCallback (void) { +Callback MakeNullCallback (void) +{ return Callback (); } template -Callback MakeNullCallback (void) { +Callback MakeNullCallback (void) +{ return Callback (); } template -Callback MakeNullCallback (void) { +Callback MakeNullCallback (void) +{ return Callback (); } template -Callback MakeNullCallback (void) { +Callback MakeNullCallback (void) +{ return Callback (); } template -Callback MakeNullCallback (void) { +Callback MakeNullCallback (void) +{ return Callback (); } template -Callback MakeNullCallback (void) { +Callback MakeNullCallback (void) +{ return Callback (); } template -Callback MakeNullCallback (void) { +Callback MakeNullCallback (void) +{ return Callback (); } template -Callback MakeNullCallback (void) { +Callback MakeNullCallback (void) +{ return Callback (); } template -Callback MakeNullCallback (void) { +Callback MakeNullCallback (void) +{ return Callback (); } /**@}*/ @@ -1681,65 +1842,74 @@ Callback MakeNullCallback (void) { * \param [in] fnPtr Function pointer * \param [in] a1 First bound argument * \return A bound Callback - */ + */ template -Callback MakeBoundCallback (R (*fnPtr)(TX), ARG a1) { +Callback MakeBoundCallback (R (*fnPtr)(TX), ARG a1) +{ Ptr > impl = - Create >(fnPtr, a1); + Create > (fnPtr, a1); return Callback (impl); } -template -Callback MakeBoundCallback (R (*fnPtr)(TX,T1), ARG a1) { +Callback MakeBoundCallback (R (*fnPtr)(TX,T1), ARG a1) +{ Ptr > impl = Create > (fnPtr, a1); return Callback (impl); } -template -Callback MakeBoundCallback (R (*fnPtr)(TX,T1,T2), ARG a1) { +Callback MakeBoundCallback (R (*fnPtr)(TX,T1,T2), ARG a1) +{ Ptr > impl = Create > (fnPtr, a1); return Callback (impl); } template -Callback MakeBoundCallback (R (*fnPtr)(TX,T1,T2,T3), ARG a1) { +Callback MakeBoundCallback (R (*fnPtr)(TX,T1,T2,T3), ARG a1) +{ Ptr > impl = Create > (fnPtr, a1); return Callback (impl); } template -Callback MakeBoundCallback (R (*fnPtr)(TX,T1,T2,T3,T4), ARG a1) { +Callback MakeBoundCallback (R (*fnPtr)(TX,T1,T2,T3,T4), ARG a1) +{ Ptr > impl = Create > (fnPtr, a1); return Callback (impl); } template -Callback MakeBoundCallback (R (*fnPtr)(TX,T1,T2,T3,T4,T5), ARG a1) { +Callback MakeBoundCallback (R (*fnPtr)(TX,T1,T2,T3,T4,T5), ARG a1) +{ Ptr > impl = Create > (fnPtr, a1); return Callback (impl); } template -Callback MakeBoundCallback (R (*fnPtr)(TX,T1,T2,T3,T4,T5,T6), ARG a1) { +Callback MakeBoundCallback (R (*fnPtr)(TX,T1,T2,T3,T4,T5,T6), ARG a1) +{ Ptr > impl = Create > (fnPtr, a1); return Callback (impl); } template -Callback MakeBoundCallback (R (*fnPtr)(TX,T1,T2,T3,T4,T5,T6,T7), ARG a1) { +Callback MakeBoundCallback (R (*fnPtr)(TX,T1,T2,T3,T4,T5,T6,T7), ARG a1) +{ Ptr > impl = Create > (fnPtr, a1); return Callback (impl); } template -Callback MakeBoundCallback (R (*fnPtr)(TX,T1,T2,T3,T4,T5,T6,T7,T8), ARG a1) { +Callback MakeBoundCallback (R (*fnPtr)(TX,T1,T2,T3,T4,T5,T6,T7,T8), ARG a1) +{ Ptr > impl = Create > (fnPtr, a1); return Callback (impl); @@ -1752,60 +1922,68 @@ Callback MakeBoundCallback (R (*fnPtr)(TX,T1,T2,T3,T4 * Make Callbacks with two bound arguments. * \param [in] fnPtr Function pointer * \param [in] a1 First bound argument - * \param [in] a2 Second bound argument + * \param [in] a2 Second bound argument * \return A bound Callback */ template -Callback MakeBoundCallback (R (*fnPtr)(TX1,TX2), ARG1 a1, ARG2 a2) { +Callback MakeBoundCallback (R (*fnPtr)(TX1,TX2), ARG1 a1, ARG2 a2) +{ Ptr > impl = - Create >(fnPtr, a1, a2); + Create > (fnPtr, a1, a2); return Callback (impl); } template -Callback MakeBoundCallback (R (*fnPtr)(TX1,TX2,T1), ARG1 a1, ARG2 a2) { +Callback MakeBoundCallback (R (*fnPtr)(TX1,TX2,T1), ARG1 a1, ARG2 a2) +{ Ptr > impl = Create > (fnPtr, a1, a2); return Callback (impl); } template -Callback MakeBoundCallback (R (*fnPtr)(TX1,TX2,T1,T2), ARG1 a1, ARG2 a2) { +Callback MakeBoundCallback (R (*fnPtr)(TX1,TX2,T1,T2), ARG1 a1, ARG2 a2) +{ Ptr > impl = Create > (fnPtr, a1, a2); return Callback (impl); } template -Callback MakeBoundCallback (R (*fnPtr)(TX1,TX2,T1,T2,T3), ARG1 a1, ARG2 a2) { +Callback MakeBoundCallback (R (*fnPtr)(TX1,TX2,T1,T2,T3), ARG1 a1, ARG2 a2) +{ Ptr > impl = Create > (fnPtr, a1, a2); return Callback (impl); } template -Callback MakeBoundCallback (R (*fnPtr)(TX1,TX2,T1,T2,T3,T4), ARG1 a1, ARG2 a2) { +Callback MakeBoundCallback (R (*fnPtr)(TX1,TX2,T1,T2,T3,T4), ARG1 a1, ARG2 a2) +{ Ptr > impl = Create > (fnPtr, a1, a2); return Callback (impl); } template -Callback MakeBoundCallback (R (*fnPtr)(TX1,TX2,T1,T2,T3,T4,T5), ARG1 a1, ARG2 a2) { +Callback MakeBoundCallback (R (*fnPtr)(TX1,TX2,T1,T2,T3,T4,T5), ARG1 a1, ARG2 a2) +{ Ptr > impl = Create > (fnPtr, a1, a2); return Callback (impl); } template -Callback MakeBoundCallback (R (*fnPtr)(TX1,TX2,T1,T2,T3,T4,T5,T6), ARG1 a1, ARG2 a2) { +Callback MakeBoundCallback (R (*fnPtr)(TX1,TX2,T1,T2,T3,T4,T5,T6), ARG1 a1, ARG2 a2) +{ Ptr > impl = Create > (fnPtr, a1, a2); return Callback (impl); } template -Callback MakeBoundCallback (R (*fnPtr)(TX1,TX2,T1,T2,T3,T4,T5,T6,T7), ARG1 a1, ARG2 a2) { +Callback MakeBoundCallback (R (*fnPtr)(TX1,TX2,T1,T2,T3,T4,T5,T6,T7), ARG1 a1, ARG2 a2) +{ Ptr > impl = Create > (fnPtr, a1, a2); return Callback (impl); @@ -1817,55 +1995,62 @@ Callback MakeBoundCallback (R (*fnPtr)(TX1,TX2,T1,T2,T3, * @{ * Make Callbacks with three bound arguments. * \param [in] a1 First bound argument - * \param [in] a2 Second bound argument - * \param [in] a3 Third bound argument + * \param [in] a2 Second bound argument + * \param [in] a3 Third bound argument * \param [in] fnPtr Function pointer * \return A bound Callback */ template -Callback MakeBoundCallback (R (*fnPtr)(TX1,TX2,TX3), ARG1 a1, ARG2 a2, ARG3 a3) { +Callback MakeBoundCallback (R (*fnPtr)(TX1,TX2,TX3), ARG1 a1, ARG2 a2, ARG3 a3) +{ Ptr > impl = - Create >(fnPtr, a1, a2, a3); + Create > (fnPtr, a1, a2, a3); return Callback (impl); } template -Callback MakeBoundCallback (R (*fnPtr)(TX1,TX2,TX3,T1), ARG1 a1, ARG2 a2, ARG3 a3) { +Callback MakeBoundCallback (R (*fnPtr)(TX1,TX2,TX3,T1), ARG1 a1, ARG2 a2, ARG3 a3) +{ Ptr > impl = Create > (fnPtr, a1, a2, a3); return Callback (impl); } template -Callback MakeBoundCallback (R (*fnPtr)(TX1,TX2,TX3,T1,T2), ARG1 a1, ARG2 a2, ARG3 a3) { +Callback MakeBoundCallback (R (*fnPtr)(TX1,TX2,TX3,T1,T2), ARG1 a1, ARG2 a2, ARG3 a3) +{ Ptr > impl = Create > (fnPtr, a1, a2, a3); return Callback (impl); } template -Callback MakeBoundCallback (R (*fnPtr)(TX1,TX2,TX3,T1,T2,T3), ARG1 a1, ARG2 a2, ARG3 a3) { +Callback MakeBoundCallback (R (*fnPtr)(TX1,TX2,TX3,T1,T2,T3), ARG1 a1, ARG2 a2, ARG3 a3) +{ Ptr > impl = Create > (fnPtr, a1, a2, a3); return Callback (impl); } template -Callback MakeBoundCallback (R (*fnPtr)(TX1,TX2,TX3,T1,T2,T3,T4), ARG1 a1, ARG2 a2, ARG3 a3) { +Callback MakeBoundCallback (R (*fnPtr)(TX1,TX2,TX3,T1,T2,T3,T4), ARG1 a1, ARG2 a2, ARG3 a3) +{ Ptr > impl = Create > (fnPtr, a1, a2, a3); return Callback (impl); } template -Callback MakeBoundCallback (R (*fnPtr)(TX1,TX2,TX3,T1,T2,T3,T4,T5), ARG1 a1, ARG2 a2, ARG3 a3) { +Callback MakeBoundCallback (R (*fnPtr)(TX1,TX2,TX3,T1,T2,T3,T4,T5), ARG1 a1, ARG2 a2, ARG3 a3) +{ Ptr > impl = Create > (fnPtr, a1, a2, a3); return Callback (impl); } template -Callback MakeBoundCallback (R (*fnPtr)(TX1,TX2,TX3,T1,T2,T3,T4,T5,T6), ARG1 a1, ARG2 a2, ARG3 a3) { +Callback MakeBoundCallback (R (*fnPtr)(TX1,TX2,TX3,T1,T2,T3,T4,T5,T6), ARG1 a1, ARG2 a2, ARG3 a3) +{ Ptr > impl = Create > (fnPtr, a1, a2, a3); return Callback (impl); @@ -1915,6 +2100,7 @@ public: * \return \c true if successful */ virtual bool DeserializeFromString (std::string value, Ptr checker); + private: CallbackBase m_value; //!< the CallbackBase }; @@ -1932,7 +2118,9 @@ bool CallbackValue::GetAccessor (T &value) const if (value.CheckType (m_value)) { if (!value.Assign (m_value)) - NS_FATAL_ERROR_NO_MSG (); + { + NS_FATAL_ERROR_NO_MSG (); + } return true; } return false; diff --git a/src/core/model/command-line.cc b/src/core/model/command-line.cc index 7e37ddc1e..c8fd5c52b 100644 --- a/src/core/model/command-line.cc +++ b/src/core/model/command-line.cc @@ -128,12 +128,18 @@ CommandLine::Parse (std::vector args) { m_name = SystemPath::Split (args[0]).back (); args.erase (args.begin ()); // discard the program name - + for (auto param : args) { - if (HandleOption (param)) continue; - if (HandleNonOption (param)) continue; - + if (HandleOption (param)) + { + continue; + } + if (HandleNonOption (param)) + { + continue; + } + // is this possible? NS_ASSERT_MSG (false, "unexpected error parsing command line parameter: '" @@ -145,7 +151,7 @@ CommandLine::Parse (std::vector args) #ifdef ENABLE_DES_METRICS DesMetrics::Get ()->Initialize (args); #endif - + } bool @@ -182,7 +188,7 @@ CommandLine::HandleOption (const std::string & param) const else { name = arg.substr (0, cur); - value = arg.substr (cur + 1, arg.size () - (cur+1)); + value = arg.substr (cur + 1, arg.size () - (cur + 1)); } HandleArgument (name, value); @@ -194,11 +200,11 @@ CommandLine::HandleNonOption (const std::string &value) { NS_LOG_FUNCTION (this << value); - if (m_nonOptionCount == m_nonOptions.size()) + if (m_nonOptionCount == m_nonOptions.size ()) { // Add an unspecified non-option as a string NS_LOG_LOGIC ("adding StringItem, NOCount:" << m_nonOptionCount - << ", NOSize:" << m_nonOptions.size ()); + << ", NOSize:" << m_nonOptions.size ()); StringItem * item = new StringItem; item->m_name = "extra-non-option-argument"; item->m_help = "Extra non-option argument encountered."; @@ -241,13 +247,13 @@ CommandLine::PrintHelp (std::ostream &os) const << (nonOptions.size () ? " [Program Arguments]" : "") << " [General Arguments]" << std::endl; - + if (m_usage.length ()) { os << std::endl; os << m_usage << std::endl; } - + std::size_t width = 0; for (auto it : m_options) { @@ -319,7 +325,7 @@ CommandLine::PrintGlobals (std::ostream &os) const // Sort output std::vector globals; - + for (GlobalValue::Iterator i = GlobalValue::Begin (); i != GlobalValue::End (); ++i) @@ -354,17 +360,17 @@ CommandLine::PrintAttributes (std::ostream &os, const std::string &type) const } os << "Attributes for TypeId " << tid.GetName () << std::endl; - + // Sort output std::vector attributes; - + for (uint32_t i = 0; i < tid.GetAttributeN (); ++i) { std::stringstream ss; ss << " --" << tid.GetAttributeFullName (i) << "=["; struct TypeId::AttributeInformation info = tid.GetAttribute (i); ss << info.initialValue->SerializeToString (info.checker) << "]" - << std::endl; + << std::endl; ss << " " << info.help << std::endl; attributes.push_back (ss.str ()); } @@ -384,17 +390,17 @@ CommandLine::PrintGroup (std::ostream &os, const std::string &group) const NS_LOG_FUNCTION (this); os << "TypeIds in group " << group << ":" << std::endl; - + // Sort output std::vector groupTypes; - + for (uint16_t i = 0; i < TypeId::GetRegisteredN (); ++i) { std::stringstream ss; TypeId tid = TypeId::GetRegistered (i); if (tid.GetGroupName () == group) { - ss << " " < types; - + for (uint16_t i = 0; i < TypeId::GetRegisteredN (); ++i) { std::stringstream ss; @@ -443,7 +449,7 @@ CommandLine::PrintGroups (std::ostream &os) const TypeId tid = TypeId::GetRegistered (i); groups.insert (tid.GetGroupName ()); } - + os << "Registered TypeId groups:" << std::endl; // Sets are already sorted for (std::set::const_iterator k = groups.begin (); @@ -467,7 +473,7 @@ CommandLine::HandleArgument (const std::string &name, const std::string &value) // method below never returns. PrintHelp (std::cout); std::exit (0); - } + } else if (name == "PrintGroups") { // method below never returns. @@ -504,7 +510,7 @@ CommandLine::HandleArgument (const std::string &name, const std::string &value) { if (i->m_name == name) { - if (! i->Parse (value)) + if (!i->Parse (value)) { std::cerr << "Invalid argument value: " << name << "=" << value << std::endl; @@ -558,7 +564,7 @@ CommandLine::AddValue (const std::string &name, std::size_t colon = attributePath.rfind ("::"); const std::string typeName = attributePath.substr (0, colon); NS_LOG_DEBUG ("typeName: '" << typeName << "', colon: " << colon); - + TypeId tid; if (!TypeId::LookupByNameFailSafe (typeName, &tid)) { @@ -566,26 +572,26 @@ CommandLine::AddValue (const std::string &name, } const std::string attrName = attributePath.substr (colon + 2); - struct TypeId::AttributeInformation info; + struct TypeId::AttributeInformation info; if (!tid.LookupAttributeByName (attrName, &info)) { NS_FATAL_ERROR ("Attribute not found: " << attributePath); } - + std::stringstream ss; ss << info.help << " (" << attributePath << ") [" << info.initialValue->SerializeToString (info.checker) << "]"; - + AddValue (name, ss.str (), - MakeBoundCallback (CommandLine::HandleAttribute, attributePath)) ; + MakeBoundCallback (CommandLine::HandleAttribute, attributePath)); } std::string CommandLine::GetExtraNonOption (std::size_t i) const { std::string value; - + if (m_nonOptions.size () >= i + m_NNonOptions) { auto ip = dynamic_cast (m_nonOptions[i + m_NNonOptions]); @@ -624,7 +630,7 @@ CommandLine::HandleAttribute (const std::string name, } return success; } - + bool CommandLine::Item::HasDefault () const @@ -650,7 +656,7 @@ CommandLine::StringItem::HasDefault (void) const { return false; } - + std::string CommandLine::StringItem::GetDefault (void) const { @@ -671,11 +677,11 @@ bool CommandLineHelper::UserItemParse (const std::string value, bool & val) { std::string src = value; - std::transform(src.begin(), src.end(), src.begin(), - [](char c) {return static_cast(std::tolower(c)); }); + std::transform (src.begin (), src.end (), src.begin (), + [](char c) {return static_cast (std::tolower (c)); }); if (src.length () == 0) { - val = ! val; + val = !val; return true; } else if ( (src == "true") || (src == "t") ) diff --git a/src/core/model/command-line.h b/src/core/model/command-line.h index f7a8c9674..830e47bf6 100644 --- a/src/core/model/command-line.h +++ b/src/core/model/command-line.h @@ -49,11 +49,11 @@ namespace ns3 { * \ingroup commandline * \brief Parse command-line arguments * - * Instances of this class can be used to parse command-line + * Instances of this class can be used to parse command-line * arguments. Programs can register a general usage message with * CommandLine::Usage, and arguments with CommandLine::AddValue. * Argument variable types with input streamers (`operator>>`) - * can be set directly; more complex argument parsing + * can be set directly; more complex argument parsing * can be accomplished by providing a Callback. * * CommandLine also provides handlers for these standard arguments: @@ -64,7 +64,7 @@ namespace ns3 { --PrintTypeIds: Print all TypeIds. --PrintAttributes=[typeid]: Print all attributes of typeid. --PrintHelp: Print this help message. \endverbatim - * + * * The more common \c --help is a synonym for \c --PrintHelp; an example * is given below. * @@ -86,7 +86,7 @@ namespace ns3 { * the forms * \verbatim --toggle1 --toggle2=1 --toggle3=t --toggle4=true \endverbatim - * The first form changes the state of toggle1 from its default; + * The first form changes the state of toggle1 from its default; * all the rest set the corresponding boolean variable to true. * \c 0, \c f and \c false are accepted to set the variable to false. * Option arguments can appear in any order on the command line, @@ -104,11 +104,10 @@ namespace ns3 { * value each variable ended up with, especially when using boolean toggles. * Suggested best practice is for scripts to report the values of all items * settable through CommandLine, as done by the example below. - * + * * * CommandLine can set the initial value of every attribute in the system - * with the - * \c --TypeIdName::AttributeName=value syntax, for example + * with the \c --TypeIdName::AttributeName=value syntax, for example * \verbatim --Application::StartTime=3s \endverbatim * In some cases you may want to highlight the use of a particular @@ -133,7 +132,7 @@ namespace ns3 { * int intArg = 1; * bool boolArg = false; * std::string strArg = "strArg default"; - * + * * CommandLine cmd; * cmd.Usage ("CommandLine example program.\n" * "\n" @@ -162,21 +161,21 @@ namespace ns3 { boolArg: true strArg: "Hello" cbArg: "World" - + $ ./waf --run="command-line-example --help" ns3-dev-command-line-example-debug [Program Arguments] [General Arguments] - + CommandLine example program. - + This little program demonstrates how to use CommandLine. - + Program Arguments: --intArg: an int argument [1] --boolArg: a bool argument [false] --strArg: a string argument [strArg default] --anti: Set this RNG stream to generate antithetic values (ns3::RandomVariableStream::Antithetic) [false] --cbArg: a string via callback - + General Arguments: --PrintGlobals: Print the list of globals. --PrintGroups: Print the list of groups. @@ -194,7 +193,7 @@ namespace ns3 { * \code * int value1; * int value2; - * + * * CommandLine cmd; * cmd.Usage ("..."); * cmd.AddValue ("value1", "first value", value1); @@ -237,7 +236,7 @@ public: * \param [in] usage Program usage message to write with \c --help. */ void Usage (const std::string usage); - + /** * Add a program argument, assigning to POD * @@ -253,13 +252,13 @@ public: T &value); /** - * Callback function signature for + * Callback function signature for * AddValue(const std::string&,const std::string&,Callback). * * \param [in] value The argument value. */ typedef bool (* Callback) (const std::string value); - + /** * Add a program argument, using a Callback to parse the value * @@ -283,7 +282,7 @@ public: */ void AddValue (const std::string &name, const std::string &attributePath); - + /** * Add a non-option argument, assigning to POD * @@ -307,7 +306,7 @@ public: * \return The i'th non-option argument, as a string. */ std::string GetExtraNonOption (std::size_t i) const; - + /** * Get the total number of non-option arguments found, * including those configured with AddNonOption() and extra non-option @@ -326,7 +325,7 @@ public: * main program name as first element). * \param [in] argv The 'argv' variable: a null-terminated array of strings, * each of which identifies a command-line argument. - * + * * Obviously, this method will parse the input command-line arguments and * will attempt to handle them all. * @@ -377,7 +376,7 @@ private: * \ingroup commandline * \brief The argument abstract base class */ - class Item + class Item { public: std::string m_name; /**< Argument label: \c \-\--m_name=... */ @@ -412,7 +411,7 @@ private: virtual bool Parse (const std::string value); bool HasDefault () const; std::string GetDefault () const; - + T *m_valuePtr; /**< Pointer to the POD location */ std::string m_default; /**< String representation of default value */ }; // class UserItem @@ -424,7 +423,7 @@ private: bool Parse (const std::string value); bool HasDefault (void) const; std::string GetDefault (void) const; - + std::string m_value; /**< The argument value. */ }; // class StringItem @@ -449,11 +448,11 @@ private: /** * Handle an option in the form \c param=value. * - * \param [in] param The option string. + * \param [in] param The option string. * \returns \c true if this was really an option. */ bool HandleOption (const std::string & param) const; - + /** * Handle a non-option * @@ -461,7 +460,7 @@ private: * \return \c true if \c value could be parsed correctly. */ bool HandleNonOption (const std::string &value); - + /** * Match name against the program or general arguments, * and dispatch to the appropriate handler. @@ -476,7 +475,7 @@ private: * \param [in] name The full name of the Attribute. * \param [in] value The value to assign to \p name. * \return \c true if the value was set successfully, false otherwise. - */ + */ static bool HandleAttribute (const std::string name, const std::string value); /** @@ -539,39 +538,39 @@ private: */ namespace CommandLineHelper { - /** - * \ingroup commandlinehelper - * \brief Helpers to specialize CommandLine::UserItem::Parse() on bool - * - * \param [in] value The argument name - * \param [out] val The argument location - * \return \c true if parsing was successful - * @{ - */ - template - bool UserItemParse (const std::string value, T & val); - template <> - bool UserItemParse (const std::string value, bool & val); - /**@}*/ +/** + * \ingroup commandlinehelper + * \brief Helpers to specialize CommandLine::UserItem::Parse() on bool + * + * \param [in] value The argument name + * \param [out] val The argument location + * \return \c true if parsing was successful + * @{ + */ +template +bool UserItemParse (const std::string value, T & val); +template <> +bool UserItemParse (const std::string value, bool & val); +/**@}*/ - /** - * \ingroup commandlinehelper - * \brief Helper to specialize CommandLine::UserItem::GetDefault() on bool - * - * \param [in] val The argument value - * \return The string representation of value - * @{ - */ - template - std::string GetDefault (const T & val); - template <> - std::string GetDefault (const bool & val); - /**@}*/ +/** + * \ingroup commandlinehelper + * \brief Helper to specialize CommandLine::UserItem::GetDefault() on bool + * + * \param [in] val The argument value + * \return The string representation of value + * @{ + */ +template +std::string GetDefault (const T & val); +template <> +std::string GetDefault (const bool & val); +/**@}*/ } // namespace CommandLineHelper - - - + + + } // namespace ns3 @@ -582,7 +581,7 @@ namespace CommandLineHelper { namespace ns3 { template -void +void CommandLine::AddValue (const std::string &name, const std::string &help, T &value) @@ -591,11 +590,11 @@ CommandLine::AddValue (const std::string &name, item->m_name = name; item->m_help = help; item->m_valuePtr = &value; - + std::stringstream ss; ss << value; ss >> item->m_default; - + m_options.push_back (item); } @@ -609,13 +608,13 @@ CommandLine::AddNonOption (const std::string name, item->m_name = name; item->m_help = help; item->m_valuePtr = &value; - + std::stringstream ss; ss << value; ss >> item->m_default; m_nonOptions.push_back (item); ++m_NNonOptions; - + } template @@ -670,7 +669,7 @@ CommandLineHelper::UserItemParse (const std::string value, T & val) * CommandLine cmd; * cmd.Parse (argc, argv); * ... - * + * * std::cerr << cmd; * \endcode * diff --git a/src/core/model/config.cc b/src/core/model/config.cc index 7efbdf584..dc6981853 100644 --- a/src/core/model/config.cc +++ b/src/core/model/config.cc @@ -100,7 +100,7 @@ MatchContainer::Set (std::string name, const AttributeValue &value) object->SetAttribute (name, value); } } -void +void MatchContainer::Connect (std::string name, const CallbackBase &cb) { NS_LOG_FUNCTION (this << name << &cb); @@ -112,7 +112,7 @@ MatchContainer::Connect (std::string name, const CallbackBase &cb) object->TraceConnect (name, ctx, cb); } } -void +void MatchContainer::ConnectWithoutContext (std::string name, const CallbackBase &cb) { NS_LOG_FUNCTION (this << name << &cb); @@ -123,7 +123,7 @@ MatchContainer::ConnectWithoutContext (std::string name, const CallbackBase &cb) object->TraceConnectWithoutContext (name, cb); } } -void +void MatchContainer::Disconnect (std::string name, const CallbackBase &cb) { NS_LOG_FUNCTION (this << name << &cb); @@ -135,7 +135,7 @@ MatchContainer::Disconnect (std::string name, const CallbackBase &cb) object->TraceDisconnect (name, ctx, cb); } } -void +void MatchContainer::DisconnectWithoutContext (std::string name, const CallbackBase &cb) { NS_LOG_FUNCTION (this << name << &cb); @@ -167,6 +167,7 @@ public: * \returns \c true if the index matches the Config Path. */ bool Matches (std::size_t i) const; + private: /** * Convert a string to an \c uint32_t. @@ -193,61 +194,61 @@ ArrayMatcher::Matches (std::size_t i) const NS_LOG_FUNCTION (this << i); if (m_element == "*") { - NS_LOG_DEBUG ("Array "< leftBracket && dash < rightBracket) + if (leftBracket == 0 && rightBracket == m_element.size () - 1 + && dash > leftBracket && dash < rightBracket) { std::string lowerBound = m_element.substr (leftBracket + 1, dash - (leftBracket + 1)); std::string upperBound = m_element.substr (dash + 1, rightBracket - (dash + 1)); uint32_t min; uint32_t max; - if (StringToUint32 (lowerBound, &min) && - StringToUint32 (upperBound, &max) && - i >= min && i <= max) + if (StringToUint32 (lowerBound, &min) + && StringToUint32 (upperBound, &max) + && i >= min && i <= max) { - NS_LOG_DEBUG ("Array "< root); - + private: /** Ensure the Config path starts and ends with a '/'. */ void Canonicalize (void); @@ -361,7 +362,7 @@ Resolver::Canonicalize (void) } } -void +void Resolver::Resolve (Ptr root) { NS_LOG_FUNCTION (this << root); @@ -382,12 +383,12 @@ Resolver::GetResolvedPath (void) const return fullPath; } -void +void Resolver::DoResolveOne (Ptr object) { NS_LOG_FUNCTION (this << object); - NS_LOG_DEBUG ("resolved="< root) { // This is a call to GetObject std::string tidString = item.substr (1, item.size () - 1); - NS_LOG_DEBUG ("GetObject="< (PeekPointer(info.checker)); + const PointerChecker *pChecker = dynamic_cast (PeekPointer (info.checker)); if (pChecker != 0) { - NS_LOG_DEBUG ("GetAttribute(ptr)="< root) m_workStack.pop_back (); } // attempt to cast to an object vector. - const ObjectPtrContainerChecker *vectorChecker = + const ObjectPtrContainerChecker *vectorChecker = dynamic_cast (PeekPointer (info.checker)); if (vectorChecker != 0) { - NS_LOG_DEBUG ("GetAttribute(vector)="< obj) { NS_LOG_FUNCTION (this << obj); m_roots.push_back (obj); } -void +void ConfigImpl::UnregisterRootNamespaceObject (Ptr obj) { NS_LOG_FUNCTION (this << obj); @@ -774,7 +776,7 @@ ConfigImpl::GetRootNamespaceObjectN (void) const NS_LOG_FUNCTION (this); return m_roots.size (); } -Ptr +Ptr ConfigImpl::GetRootNamespaceObject (std::size_t i) const { NS_LOG_FUNCTION (this << i); @@ -810,7 +812,7 @@ void Set (std::string path, const AttributeValue &value) void SetDefault (std::string name, const AttributeValue &value) { NS_LOG_FUNCTION (name << &value); - if (!SetDefaultFailSafe(name, value)) + if (!SetDefaultFailSafe (name, value)) { NS_FATAL_ERROR ("Could not set default value for " << name); } @@ -824,7 +826,7 @@ bool SetDefaultFailSafe (std::string fullName, const AttributeValue &value) return false; } std::string tidName = fullName.substr (0, pos); - std::string paramName = fullName.substr (pos+2, fullName.size () - (pos+2)); + std::string paramName = fullName.substr (pos + 2, fullName.size () - (pos + 2)); TypeId tid; bool ok = TypeId::LookupByNameFailSafe (tidName, &tid); if (!ok) @@ -833,7 +835,7 @@ bool SetDefaultFailSafe (std::string fullName, const AttributeValue &value) } for (uint32_t j = 0; j < tid.GetAttributeN (); j++) { - struct TypeId::AttributeInformation tmp = tid.GetAttribute(j); + struct TypeId::AttributeInformation tmp = tid.GetAttribute (j); if (tmp.name == paramName) { Ptr v = tmp.checker->CreateValidValue (value); @@ -867,13 +869,13 @@ void DisconnectWithoutContext (std::string path, const CallbackBase &cb) NS_LOG_FUNCTION (path << &cb); ConfigImpl::Get ()->DisconnectWithoutContext (path, cb); } -void +void Connect (std::string path, const CallbackBase &cb) { NS_LOG_FUNCTION (path << &cb); ConfigImpl::Get ()->Connect (path, cb); } -void +void Disconnect (std::string path, const CallbackBase &cb) { NS_LOG_FUNCTION (path << &cb); diff --git a/src/core/model/config.h b/src/core/model/config.h index 2b7aa4adc..096ed45d2 100644 --- a/src/core/model/config.h +++ b/src/core/model/config.h @@ -70,7 +70,7 @@ void Set (std::string path, const AttributeValue &value); * \param [in] name The full name of the attribute * \param [in] value The value to set. * - * This method overrides the initial value of the + * This method overrides the initial value of the * matching attribute. This method cannot fail: it will * crash if the input attribute name or value is invalid. */ @@ -81,8 +81,8 @@ void SetDefault (std::string name, const AttributeValue &value); * \param [in] value The value to set. * \returns \c true if the value was set successfully, false otherwise. * - * This method overrides the initial value of the - * matching attribute. + * This method overrides the initial value of the + * matching attribute. */ bool SetDefaultFailSafe (std::string name, const AttributeValue &value); /** @@ -161,8 +161,8 @@ public: * \param [in] contexts The corresponding contexts. * \param [in] path The path used for object matching. */ - MatchContainer (const std::vector > &objects, - const std::vector &contexts, + MatchContainer (const std::vector > &objects, + const std::vector &contexts, std::string path); /** @@ -240,7 +240,7 @@ public: * \sa ns3::Config::DisconnectWithoutContext */ void DisconnectWithoutContext (std::string name, const CallbackBase &cb); - + private: /** The list of objects in this container. */ std::vector > m_objects; diff --git a/src/core/model/default-deleter.h b/src/core/model/default-deleter.h index 41e537db2..0fdc04ee6 100644 --- a/src/core/model/default-deleter.h +++ b/src/core/model/default-deleter.h @@ -50,7 +50,8 @@ struct DefaultDeleter * \tparam T \deduced The object type being deleted. * \param [in] object The object to delete. */ - inline static void Delete (T *object) { + inline static void Delete (T *object) + { delete object; } }; diff --git a/src/core/model/default-simulator-impl.cc b/src/core/model/default-simulator-impl.cc index 7c606ee3a..8b182b951 100644 --- a/src/core/model/default-simulator-impl.cc +++ b/src/core/model/default-simulator-impl.cc @@ -73,7 +73,7 @@ DefaultSimulatorImpl::DefaultSimulatorImpl () m_unscheduledEvents = 0; m_eventCount = 0; m_eventsWithContextEmpty = true; - m_main = SystemThread::Self(); + m_main = SystemThread::Self (); } DefaultSimulatorImpl::~DefaultSimulatorImpl () @@ -99,7 +99,7 @@ void DefaultSimulatorImpl::Destroy () { NS_LOG_FUNCTION (this); - while (!m_destroyEvents.empty ()) + while (!m_destroyEvents.empty ()) { Ptr ev = m_destroyEvents.front ().PeekEventImpl (); m_destroyEvents.pop_front (); @@ -129,7 +129,7 @@ DefaultSimulatorImpl::SetScheduler (ObjectFactory schedulerFactory) } // System ID for non-distributed simulation is always zero -uint32_t +uint32_t DefaultSimulatorImpl::GetSystemId (void) const { return 0; @@ -154,7 +154,7 @@ DefaultSimulatorImpl::ProcessOneEvent (void) ProcessEventsWithContext (); } -bool +bool DefaultSimulatorImpl::IsFinished (void) const { return m_events->IsEmpty () || m_stop; @@ -172,21 +172,21 @@ DefaultSimulatorImpl::ProcessEventsWithContext (void) EventsWithContext eventsWithContext; { CriticalSection cs (m_eventsWithContextMutex); - m_eventsWithContext.swap(eventsWithContext); + m_eventsWithContext.swap (eventsWithContext); m_eventsWithContextEmpty = true; } while (!eventsWithContext.empty ()) { - EventWithContext event = eventsWithContext.front (); - eventsWithContext.pop_front (); - Scheduler::Event ev; - ev.impl = event.event; - ev.key.m_ts = m_currentTs + event.timestamp; - ev.key.m_context = event.context; - ev.key.m_uid = m_uid; - m_uid++; - m_unscheduledEvents++; - m_events->Insert (ev); + EventWithContext event = eventsWithContext.front (); + eventsWithContext.pop_front (); + Scheduler::Event ev; + ev.impl = event.event; + ev.key.m_ts = m_currentTs + event.timestamp; + ev.key.m_context = event.context; + ev.key.m_uid = m_uid; + m_uid++; + m_unscheduledEvents++; + m_events->Insert (ev); } } @@ -195,11 +195,11 @@ DefaultSimulatorImpl::Run (void) { NS_LOG_FUNCTION (this); // Set the current threadId as the main threadId - m_main = SystemThread::Self(); + m_main = SystemThread::Self (); ProcessEventsWithContext (); m_stop = false; - while (!m_events->IsEmpty () && !m_stop) + while (!m_events->IsEmpty () && !m_stop) { ProcessOneEvent (); } @@ -209,14 +209,14 @@ DefaultSimulatorImpl::Run (void) NS_ASSERT (!m_events->IsEmpty () || m_unscheduledEvents == 0); } -void +void DefaultSimulatorImpl::Stop (void) { NS_LOG_FUNCTION (this); m_stop = true; } -void +void DefaultSimulatorImpl::Stop (Time const &delay) { NS_LOG_FUNCTION (this << delay.GetTimeStep ()); @@ -272,7 +272,7 @@ DefaultSimulatorImpl::ScheduleWithContext (uint32_t context, Time const &delay, ev.event = event; { CriticalSection cs (m_eventsWithContextMutex); - m_eventsWithContext.push_back(ev); + m_eventsWithContext.push_back (ev); m_eventsWithContextEmpty = false; } } @@ -312,7 +312,7 @@ DefaultSimulatorImpl::Now (void) const return TimeStep (m_currentTs); } -Time +Time DefaultSimulatorImpl::GetDelayLeft (const EventId &id) const { if (IsExpired (id)) @@ -372,8 +372,8 @@ DefaultSimulatorImpl::IsExpired (const EventId &id) const { if (id.GetUid () == 2) { - if (id.PeekEventImpl () == 0 || - id.PeekEventImpl ()->IsCancelled ()) + if (id.PeekEventImpl () == 0 + || id.PeekEventImpl ()->IsCancelled ()) { return true; } @@ -387,11 +387,10 @@ DefaultSimulatorImpl::IsExpired (const EventId &id) const } return true; } - if (id.PeekEventImpl () == 0 || - id.GetTs () < m_currentTs || - (id.GetTs () == m_currentTs && - id.GetUid () <= m_currentUid) || - id.PeekEventImpl ()->IsCancelled ()) + if (id.PeekEventImpl () == 0 + || id.GetTs () < m_currentTs + || (id.GetTs () == m_currentTs && id.GetUid () <= m_currentUid) + || id.PeekEventImpl ()->IsCancelled ()) { return true; } @@ -401,7 +400,7 @@ DefaultSimulatorImpl::IsExpired (const EventId &id) const } } -Time +Time DefaultSimulatorImpl::GetMaximumSimulationTime (void) const { return TimeStep (0x7fffffffffffffffLL); diff --git a/src/core/model/default-simulator-impl.h b/src/core/model/default-simulator-impl.h index 918b7e1af..d05284e69 100644 --- a/src/core/model/default-simulator-impl.h +++ b/src/core/model/default-simulator-impl.h @@ -86,9 +86,10 @@ private: void ProcessOneEvent (void); /** Move events from a different context into the main event queue. */ void ProcessEventsWithContext (void); - + /** Wrap an event with its execution context. */ - struct EventWithContext { + struct EventWithContext + { /** The event context. */ uint32_t context; /** Event timestamp. */ diff --git a/src/core/model/des-metrics.cc b/src/core/model/des-metrics.cc index ac9fde759..2e2701c95 100644 --- a/src/core/model/des-metrics.cc +++ b/src/core/model/des-metrics.cc @@ -38,7 +38,7 @@ namespace ns3 { /* static */ std::string DesMetrics::m_outputDir; // = ""; -void +void DesMetrics::Initialize (std::vector args, std::string outDir /* = "" */ ) { if (m_initialized) @@ -78,9 +78,12 @@ DesMetrics::Initialize (std::vector args, std::string outDir /* = " m_os << " \"command_line_arguments\" : \""; if (args.size () == 0) { - for (std::size_t i = 0; i < args.size (); ++i) + for (std::size_t i = 0; i < args.size (); ++i) { - if (i > 0) m_os << " "; + if (i > 0) + { + m_os << " "; + } m_os << args[i]; } } @@ -92,7 +95,7 @@ DesMetrics::Initialize (std::vector args, std::string outDir /* = " m_os << " \"events\" : [" << std::endl; m_separator = ' '; - + } void @@ -100,7 +103,7 @@ DesMetrics::Trace (const Time & now, const Time & delay) { TraceWithContext (Simulator::GetContext (), now, delay); } - + void DesMetrics::TraceWithContext (uint32_t context, const Time & now, const Time & delay) { @@ -120,7 +123,7 @@ DesMetrics::TraceWithContext (uint32_t context, const Time & now, const Time & d // Force to signed so we can show NoContext as '-1' int32_t send = (sendCtx != Simulator::NO_CONTEXT) ? (int32_t)sendCtx : -1; int32_t recv = (context != Simulator::NO_CONTEXT) ? (int32_t)context : -1; - + ss << " [\"" << send << "\",\"" << now.GetTimeStep () << "\",\"" @@ -144,7 +147,7 @@ void DesMetrics::Close (void) { m_os << std::endl; // Finish the last event line - + m_os << " ]" << std::endl; m_os << "}" << std::endl; m_os.close (); diff --git a/src/core/model/des-metrics.h b/src/core/model/des-metrics.h index a517c5534..dfbf37f25 100644 --- a/src/core/model/des-metrics.h +++ b/src/core/model/des-metrics.h @@ -97,7 +97,7 @@ namespace ns3 { * \li Run everything, retaining the results directory:
* \code ./test.py --nowaf --retain \endcode * \li Example traces end up in \c testpy-output/, so move there:
- * \code cd testpy-output/$(date +"%F")*_/ \endcode + * \code cd testpy-output/$(date +"%F")*_/ \endcode * (Remove the `_', which is to work around a Doxygen limitation.) * \li Remove the traces with less than 10 events:
* \code wc -l *.json | sort -nr | grep "^ *[789] " | cut -d ' ' -f 9 | xargs rm -f \endcode @@ -105,28 +105,28 @@ namespace ns3 { * \code wc -l *.json | sort -n | tail -2 \endcode * */ -class DesMetrics : public Singleton +class DesMetrics : public Singleton { public: /** * Open the DesMetrics trace file and print the header. * - * The trace file will have the same base name as the main program, - * '.json' as the extension. + * The trace file will have the same base name as the main program, + * '.json' as the extension. * * \param args [in] Command line arguments. * \param outDir [in] Directory where the trace file should be written. */ - void Initialize (std::vector args, std::string outDir = ""); + void Initialize (std::vector args, std::string outDir = ""); /** * Trace an event to self at the time it is scheduled. * - * \param now [in] The local simulation time. - * \param delay [in] The delay to the event. + * \param now [in] The local simulation time. + * \param delay [in] The delay to the event. */ - void Trace (const Time & now, const Time & delay); + void Trace (const Time & now, const Time & delay); /** * Trace an event (with context) at the time it is scheduled. @@ -154,14 +154,14 @@ private: * in \c command-line-test-suite.cc */ static std::string m_outputDir; - + bool m_initialized; //!< Have we been initialized. std::ofstream m_os; //!< The output JSON trace file stream. char m_separator; //!< The separator between event records. /** Mutex to control access to the output file. */ SystemMutex m_mutex; - + }; // class DesMetrics diff --git a/src/core/model/double.cc b/src/core/model/double.cc index c300ece60..e89d5e7d5 100644 --- a/src/core/model/double.cc +++ b/src/core/model/double.cc @@ -55,8 +55,10 @@ Ptr MakeDoubleChecker (double min, double max, std::stri Checker (double minValue, double maxValue, std::string name) : m_minValue (minValue), m_maxValue (maxValue), - m_name (name) {} - virtual bool Check (const AttributeValue &value) const { + m_name (name) + {} + virtual bool Check (const AttributeValue &value) const + { NS_LOG_FUNCTION (&value); const DoubleValue *v = dynamic_cast (&value); if (v == 0) @@ -65,25 +67,30 @@ Ptr MakeDoubleChecker (double min, double max, std::stri } return v->Get () >= m_minValue && v->Get () <= m_maxValue; } - virtual std::string GetValueTypeName (void) const { + virtual std::string GetValueTypeName (void) const + { NS_LOG_FUNCTION_NOARGS (); return "ns3::DoubleValue"; } - virtual bool HasUnderlyingTypeInformation (void) const { + virtual bool HasUnderlyingTypeInformation (void) const + { NS_LOG_FUNCTION_NOARGS (); return true; } - virtual std::string GetUnderlyingTypeInformation (void) const { + virtual std::string GetUnderlyingTypeInformation (void) const + { NS_LOG_FUNCTION_NOARGS (); std::ostringstream oss; oss << m_name << " " << m_minValue << ":" << m_maxValue; return oss.str (); } - virtual Ptr Create (void) const { + virtual Ptr Create (void) const + { NS_LOG_FUNCTION_NOARGS (); return ns3::Create (); } - virtual bool Copy (const AttributeValue &source, AttributeValue &destination) const { + virtual bool Copy (const AttributeValue &source, AttributeValue &destination) const + { NS_LOG_FUNCTION (&source << &destination); const DoubleValue *src = dynamic_cast (&source); DoubleValue *dst = dynamic_cast (&destination); diff --git a/src/core/model/empty.h b/src/core/model/empty.h index 6631e6992..561fa6f2f 100644 --- a/src/core/model/empty.h +++ b/src/core/model/empty.h @@ -30,7 +30,8 @@ namespace ns3 { /** * \brief make Callback use a separate empty type */ -class empty {}; +class empty +{}; } #endif /* EMPTY_H */ diff --git a/src/core/model/enum.cc b/src/core/model/enum.cc index 4ba11d5bb..956c1795b 100644 --- a/src/core/model/enum.cc +++ b/src/core/model/enum.cc @@ -60,7 +60,7 @@ EnumValue::Copy (void) const NS_LOG_FUNCTION (this); return ns3::Create (*this); } -std::string +std::string EnumValue::SerializeToString (Ptr checker) const { NS_LOG_FUNCTION (this << checker); @@ -78,7 +78,7 @@ EnumValue::SerializeToString (Ptr checker) const // quiet compiler. return ""; } -bool +bool EnumValue::DeserializeFromString (std::string value, Ptr checker) { NS_LOG_FUNCTION (this << value << checker); @@ -130,19 +130,19 @@ EnumChecker::Check (const AttributeValue &value) const } return false; } -std::string +std::string EnumChecker::GetValueTypeName (void) const { NS_LOG_FUNCTION (this); return "ns3::EnumValue"; } -bool +bool EnumChecker::HasUnderlyingTypeInformation (void) const { NS_LOG_FUNCTION (this); return true; } -std::string +std::string EnumChecker::GetUnderlyingTypeInformation (void) const { NS_LOG_FUNCTION (this); @@ -165,7 +165,7 @@ EnumChecker::Create (void) const return ns3::Create (); } -bool +bool EnumChecker::Copy (const AttributeValue &source, AttributeValue &destination) const { NS_LOG_FUNCTION (this << &source << &destination); @@ -180,7 +180,7 @@ EnumChecker::Copy (const AttributeValue &source, AttributeValue &destination) co } -Ptr +Ptr MakeEnumChecker (int v1, std::string n1, int v2, std::string n2, int v3, std::string n3, diff --git a/src/core/model/enum.h b/src/core/model/enum.h index 20798c0eb..e24b3ae94 100644 --- a/src/core/model/enum.h +++ b/src/core/model/enum.h @@ -176,7 +176,7 @@ Ptr MakeEnumAccessor (T1 a1, T2 a2); * \param [in] n21 The corresponding name. * \param [in] v22 A enum value * \param [in] n22 The corresponding name. - */ + */ Ptr MakeEnumChecker (int v1, std::string n1, int v2 = 0, std::string n2 = "", int v3 = 0, std::string n3 = "", diff --git a/src/core/model/event-id.cc b/src/core/model/event-id.cc index a90ceef22..b7dc272aa 100644 --- a/src/core/model/event-id.cc +++ b/src/core/model/event-id.cc @@ -73,19 +73,19 @@ EventId::PeekEventImpl (void) const NS_LOG_FUNCTION (this); return PeekPointer (m_eventImpl); } -uint64_t +uint64_t EventId::GetTs (void) const { NS_LOG_FUNCTION (this); return m_ts; } -uint32_t +uint32_t EventId::GetContext (void) const { NS_LOG_FUNCTION (this); return m_context; } -uint32_t +uint32_t EventId::GetUid (void) const { NS_LOG_FUNCTION (this); diff --git a/src/core/model/event-id.h b/src/core/model/event-id.h index 61185bdb7..f683bd136 100644 --- a/src/core/model/event-id.h +++ b/src/core/model/event-id.h @@ -44,13 +44,14 @@ class EventImpl; * with Simulator::Cancel() or Simulator::Remove(). * * The important thing to remember about this class is that - * every variable of this type is _always_ in a valid state, + * every variable of this type is _always_ in a valid state, * even when it has not been assigned an EventId coming from a * Simulator::Schedule() method: calling Simulator::Cancel(), IsRunning(), * IsExpired() or passing around instances of this object * will not result in crashes or memory leaks. */ -class EventId { +class EventId +{ public: /** Default constructor. This EventId does nothing. */ EventId (); @@ -76,10 +77,11 @@ public: bool IsExpired (void) const; /** * This method is syntactic sugar for !IsExpired(). - * + * * \returns \c true if the event has not expired, \c false otherwise. */ bool IsRunning (void) const; + public: /** * \name Scheduler Helpers. @@ -88,7 +90,7 @@ public: */ /**@{*/ /** \return The underlying EventImpl pointer. */ - EventImpl *PeekEventImpl (void) const; + EventImpl * PeekEventImpl (void) const; /** \return The virtual time stamp. */ uint64_t GetTs (void) const; /** \return The event context. */ @@ -96,7 +98,7 @@ public: /** \return The unique id. */ uint32_t GetUid (void) const; /**@}*/ - + /** * Test if two EventId's are equal. * \param [in] a The first EventId. @@ -130,25 +132,25 @@ private: ** Inline implementations ************************************************/ -inline +inline bool operator == (const EventId &a, const EventId &b) { - return - a.m_uid == b.m_uid && - a.m_context == b.m_context && - a.m_ts == b.m_ts && - a.m_eventImpl == b.m_eventImpl; + return + a.m_uid == b.m_uid + && a.m_context == b.m_context + && a.m_ts == b.m_ts + && a.m_eventImpl == b.m_eventImpl; } - -inline + +inline bool operator != (const EventId &a, const EventId &b) { return !(a == b); } - -inline + +inline bool operator < (const EventId &a, const EventId &b) { diff --git a/src/core/model/fatal-impl.cc b/src/core/model/fatal-impl.cc index cb95ccd21..299fc6ee2 100644 --- a/src/core/model/fatal-impl.cc +++ b/src/core/model/fatal-impl.cc @@ -39,7 +39,7 @@ * * The singleton pattern we use here is tricky because we have to ensure: * - * - RegisterStream() succeeds, even if called before \c main() enters and + * - RegisterStream() succeeds, even if called before \c main() enters and * before any constructor run in this file. * * - UnregisterStream() succeeds, whether or not FlushStreams() has @@ -53,7 +53,7 @@ namespace ns3 { NS_LOG_COMPONENT_DEFINE ("FatalImpl"); - + namespace FatalImpl { /** @@ -70,7 +70,7 @@ namespace { * * \returns The address of the static pointer. */ -std::list **PeekStreamList (void) +std::list ** PeekStreamList (void) { NS_LOG_FUNCTION_NOARGS (); static std::list *streams = 0; @@ -83,7 +83,7 @@ std::list **PeekStreamList (void) * * \returns The stream list. */ -std::list *GetStreamList (void) +std::list * GetStreamList (void) { NS_LOG_FUNCTION_NOARGS (); std::list **pstreams = PeekStreamList (); @@ -145,7 +145,7 @@ void sigHandler (int sig) } } // unnamed namespace -void +void FlushStreams (void) { NS_LOG_FUNCTION_NOARGS (); @@ -161,7 +161,7 @@ FlushStreams (void) * The SIGSEGV override should only be active for the * duration of this function. */ struct sigaction hdl; - hdl.sa_handler=sigHandler; + hdl.sa_handler = sigHandler; sigaction (SIGSEGV, &hdl, 0); std::list *l = *pl; @@ -175,7 +175,7 @@ FlushStreams (void) } /* Restore default SIGSEGV handler (Not that it matters anyway) */ - hdl.sa_handler=SIG_DFL; + hdl.sa_handler = SIG_DFL; sigaction (SIGSEGV, &hdl, 0); /* Flush all opened FILE* */ @@ -191,5 +191,5 @@ FlushStreams (void) } } // namespace FatalImpl - + } // namespace ns3 diff --git a/src/core/model/global-value.cc b/src/core/model/global-value.cc index 7142a858b..5509c2ef5 100644 --- a/src/core/model/global-value.cc +++ b/src/core/model/global-value.cc @@ -79,12 +79,12 @@ GlobalValue::InitializeFromEnv (void) while (next != std::string::npos) { next = env.find (";", cur); - std::string tmp = std::string (env, cur, next-cur); + std::string tmp = std::string (env, cur, next - cur); std::string::size_type equal = tmp.find ("="); if (equal != std::string::npos) { std::string name = tmp.substr (0, equal); - std::string value = tmp.substr (equal+1, tmp.size () - equal - 1); + std::string value = tmp.substr (equal + 1, tmp.size () - equal - 1); if (name == m_name) { Ptr v = m_checker->CreateValidValue (StringValue (value)); @@ -101,13 +101,13 @@ GlobalValue::InitializeFromEnv (void) #endif /* HAVE_GETENV */ } -std::string +std::string GlobalValue::GetName (void) const { NS_LOG_FUNCTION_NOARGS (); return m_name; } -std::string +std::string GlobalValue::GetHelp (void) const { NS_LOG_FUNCTION_NOARGS (); @@ -125,11 +125,11 @@ GlobalValue::GetValue (AttributeValue &value) const StringValue *str = dynamic_cast (&value); if (str == 0) { - NS_FATAL_ERROR ("GlobalValue name="<Set (m_currentValue->SerializeToString (m_checker)); } -Ptr +Ptr GlobalValue::GetChecker (void) const { NS_LOG_FUNCTION (this); @@ -151,7 +151,7 @@ GlobalValue::SetValue (const AttributeValue &value) return true; } -void +void GlobalValue::Bind (std::string name, const AttributeValue &value) { NS_LOG_FUNCTION (name << &value); @@ -162,14 +162,14 @@ GlobalValue::Bind (std::string name, const AttributeValue &value) { if (!(*i)->SetValue (value)) { - NS_FATAL_ERROR ("Invalid new value for global value: "<begin (); } -GlobalValue::Iterator +GlobalValue::Iterator GlobalValue::End (void) { NS_LOG_FUNCTION_NOARGS (); return GetVector ()->end (); } -void +void GlobalValue::ResetInitialValue (void) { NS_LOG_FUNCTION (this); @@ -215,7 +215,7 @@ GlobalValue::GetValueByNameFailSafe (std::string name, AttributeValue &value) (*gvit)->GetValue (value); return true; } - } + } return false; // not found } diff --git a/src/core/model/global-value.h b/src/core/model/global-value.h index 5651e9255..3a6c1b2f7 100644 --- a/src/core/model/global-value.h +++ b/src/core/model/global-value.h @@ -33,11 +33,11 @@ namespace ns3 { - /* Forward declaration */ - namespace tests { - class GlobalValueTestCase; - } - +/* Forward declaration */ +namespace tests { +class GlobalValueTestCase; +} + /** * \ingroup Core * @@ -49,7 +49,7 @@ namespace ns3 { * - From the command line, * - By explicit call to SetValue() or Bind(). * - * Instances of this class are expected to be allocated as static + * Instances of this class are expected to be allocated as static * global variables and should be used to store configurable global state. * For example: * \code @@ -64,9 +64,9 @@ namespace ns3 { * but they can also be set through the \c NS_GLOBAL_VALUE environment variable. * For example, \c NS_GLOBAL_VALUE='Name=Value;OtherName=OtherValue;' would set * global values \c Name and \c OtherName to \c Value and \c OtherValue, - * respectively. + * respectively. * - * Users of the CommandLine class also get the ability to set global + * Users of the CommandLine class also get the ability to set global * values through command line arguments to their program: * \c --Name=Value will set global value \c Name to \c Value. */ @@ -74,7 +74,7 @@ class GlobalValue { /** Container type for holding all the GlobalValues. */ typedef std::vector Vector; - + public: /** Iterator type for the list of all global values. */ typedef Vector::const_iterator Iterator; @@ -160,29 +160,28 @@ public: static Iterator End (void); - /** + /** * Finds the GlobalValue with the given name and returns its value - * + * * \param [in] name the name of the GlobalValue to be found * \param [out] value where to store the value of the found GlobalValue - * + * * \return \c true if the GlobalValue was found, \c false otherwise */ static bool GetValueByNameFailSafe (std::string name, AttributeValue &value); - /** + /** * Finds the GlobalValue with the given name and returns its * value. * * This method cannot fail, i.e., it will trigger a * NS_FATAL_ERROR if the requested GlobalValue is not found. - * + * * \param [in] name the name of the GlobalValue to be found * \param [out] value where to store the value of the found GlobalValue */ static void GetValueByName (std::string name, AttributeValue &value); - private: // Test case needs direct access to GetVector() friend class tests::GlobalValueTestCase; @@ -192,7 +191,7 @@ private: * * \returns The vector. */ - static Vector *GetVector (void); + static Vector * GetVector (void); /** Initialize from the \c NS_GLOBAL_VALUE environment variable. */ void InitializeFromEnv (void); diff --git a/src/core/model/hash-fnv.cc b/src/core/model/hash-fnv.cc index 77d15e64e..14dece6db 100644 --- a/src/core/model/hash-fnv.cc +++ b/src/core/model/hash-fnv.cc @@ -51,7 +51,7 @@ namespace Hash { namespace Function { -/** FNV hash implementation details. */ +/** FNV hash implementation details. */ namespace Fnv1aImplementation { /************************************************* @@ -63,13 +63,13 @@ namespace Fnv1aImplementation { * \defgroup hash_fnv FNV Hash Implementation */ /**@{*/ - + extern "C" { // Changes from FNV distribution are marked with `//PDB' // -// Begin fnv.h -----------------------------------> +/* Begin fnv.h -------------- *NS_CHECK_STYLE_OFF* ----> */ /* * fnv - Fowler/Noll/Vo- hash code @@ -195,7 +195,7 @@ typedef uint32_t Fnv32_t; //PDB */ //#include "longlong.h" //PDB - assume `unsigned long long' is 64 bit #define HAVE_64BIT_LONG_LONG - + /** @@ -292,9 +292,9 @@ enum fnv_type { #endif /* __FNV_H__ */ -// End fnv.h -------------------------------> +/* End fnv.h ---------------- *NS_CHECK_STYLE_ON* -----> */ -// Begin hash_32a.c ------------------------------> +/* Begin hash_32a.c --------- *NS_CHECK_STYLE_OFF* ----> */ /* * hash_32 - 32 bit Fowler/Noll/Vo FNV-1a hash code @@ -438,10 +438,10 @@ fnv_32a_str(char *str, Fnv32_t hval) /* return our new hash value */ return hval; } - -// End hash_32a.c --------------------------> -// Begin hash_64a.c-------------------------------> +/* End hash_32a.c ----------- *NS_CHECK_STYLE_ON* -----> */ + +/* Begin hash_64a.c --------- *NS_CHECK_STYLE_OFF* ----> */ /* * hash_64 - 64 bit Fowler/Noll/Vo-0 FNV-1a hash code @@ -734,8 +734,8 @@ fnv_64a_str(char *str, Fnv64_t hval) /* return our new hash value */ return hval; } - -// End hash_64a.c---------------------------> + +/* End hash_64a.c ----------- *NS_CHECK_STYLE_ON* -----> */ } /* extern "C" */ diff --git a/src/core/model/hash-fnv.h b/src/core/model/hash-fnv.h index 40fd81652..f98eaa712 100644 --- a/src/core/model/hash-fnv.h +++ b/src/core/model/hash-fnv.h @@ -43,7 +43,7 @@ namespace Function { * This is the venerable Fowler-Noll-Vo hash, version 1A. (See the * FNV page.) * - * The implementation here is taken directly from the published FNV + * The implementation here is taken directly from the published FNV * * reference code, * with minor modifications to wrap into this class. See the diff --git a/src/core/model/hash-function.h b/src/core/model/hash-function.h index 4970e887e..989a06868 100644 --- a/src/core/model/hash-function.h +++ b/src/core/model/hash-function.h @@ -86,14 +86,16 @@ public: /** * Constructor. */ - Implementation () { }; + Implementation () + { } /** * Destructor. */ - virtual ~Implementation () { }; + virtual ~Implementation () + { } }; // Hashfunction - + /*-------------------------------------- * Hash function implementation * by function pointers and templates @@ -132,12 +134,15 @@ public: * * \param [in] hp Function pointer to a 32-bit hash function. */ - Hash32 (Hash32Function_ptr hp) : m_fp (hp) { }; + Hash32 (Hash32Function_ptr hp) : m_fp (hp) + { } uint32_t GetHash32 (const char * buffer, const std::size_t size) { - return (*m_fp) (buffer, size); + return (*m_fp)(buffer, size); } - void clear () { }; + void clear () + { } + private: Hash32Function_ptr m_fp; /**< The hash function. */ }; // Hash32 @@ -156,10 +161,11 @@ public: * * \param [in] hp Function pointer to a 64-bit hash function. */ - Hash64 (Hash64Function_ptr hp) : m_fp (hp) { }; + Hash64 (Hash64Function_ptr hp) : m_fp (hp) + { } uint64_t GetHash64 (const char * buffer, const std::size_t size) { - return (*m_fp) (buffer, size); + return (*m_fp)(buffer, size); } uint32_t GetHash32 (const char * buffer, const std::size_t size) { @@ -169,7 +175,9 @@ public: memcpy (&hash32, &hash64, sizeof (hash32)); return hash32; } - void clear () { }; + void clear () + { } + private: Hash64Function_ptr m_fp; /**< The hash function. */ }; // Hash64 diff --git a/src/core/model/hash-murmur3.cc b/src/core/model/hash-murmur3.cc index 74a677044..b8e26277f 100644 --- a/src/core/model/hash-murmur3.cc +++ b/src/core/model/hash-murmur3.cc @@ -60,8 +60,8 @@ namespace Murmur3Implementation { * \defgroup hash_murmur3 Murmur3 Hash Implementation */ /**@{*/ - - + + // Changes from Murmur3 distribution are marked with `//PDB' // @@ -71,7 +71,7 @@ namespace Murmur3Implementation { // Adapted from http://code.google.com/p/smhasher/ -// Begin Murmur3.cpp -----------------------------> +// Begin Murmur3.cpp -------- *NS_CHECK_STYLE_OFF* ----> // //----------------------------------------------------------------------------- @@ -219,7 +219,7 @@ void MurmurHash3_x86_32_incr ( const void * key, std::size_t len, k1 *= c1; k1 = rotl32(k1,15); k1 *= c2; - + h1 ^= k1; h1 = rotl32(h1,13); h1 = h1*5+0xe6546b64; @@ -399,7 +399,7 @@ void MurmurHash3_x86_128_fin ( const std::size_t len, uint32_t h2 = seeds[1]; uint32_t h3 = seeds[2]; uint32_t h4 = seeds[3]; - + h1 ^= len; h2 ^= len; h3 ^= len; h4 ^= len; h1 += h2; h1 += h3; h1 += h4; @@ -501,11 +501,11 @@ void MurmurHash3_x64_128 ( const void * key, const std::size_t len, } -// End Murmur3.cpp -----------------------------> +// End Murmur3.cpp ---------- *NS_CHECK_STYLE_ON* -----> #undef BIG_CONSTANT - + //----------------------------------------------------------------------------- @@ -525,10 +525,10 @@ Murmur3::GetHash32 (const char * buffer, const std::size_t size) using namespace Murmur3Implementation; MurmurHash3_x86_32_incr (buffer, size, - m_hash32, (void *)& m_hash32); + m_hash32, (void *) &m_hash32); m_size32 += static_cast (size); uint32_t hash; - MurmurHash3_x86_32_fin (m_size32, m_hash32, (void *) & hash); + MurmurHash3_x86_32_fin (m_size32, m_hash32, (void *) &hash); return hash; } @@ -555,7 +555,7 @@ Murmur3::GetHash64 (const char * buffer, const std::size_t size) // // Using uint32_t here avoids the bug, and continues to works with newer gcc. uint32_t hash[4]; - + MurmurHash3_x86_128_fin (static_cast (m_size64), (uint32_t *)(void *)m_hash64, hash); uint64_t result = hash[1]; diff --git a/src/core/model/hash-murmur3.h b/src/core/model/hash-murmur3.h index 67aaf28c5..9c34248ed 100644 --- a/src/core/model/hash-murmur3.h +++ b/src/core/model/hash-murmur3.h @@ -103,7 +103,7 @@ private: { SEED = 0x8BADF00D // Ate bad food }; - /** + /** * Cache last hash value, and total bytes hashed (needed to finalize), * for incremental hashing */ @@ -111,13 +111,13 @@ private: uint32_t m_hash32; std::size_t m_size32; /**@}*/ - + /** murmur3 produces 128-bit hash and state; we use just the first 64-bits. */ /**@{*/ - uint64_t m_hash64[2]; + uint64_t m_hash64[2]; std::size_t m_size64; /**@}*/ - + }; // class Murmur3 } // namespace Function diff --git a/src/core/model/heap-scheduler.h b/src/core/model/heap-scheduler.h index c78a01365..29ad40b3a 100644 --- a/src/core/model/heap-scheduler.h +++ b/src/core/model/heap-scheduler.h @@ -151,7 +151,7 @@ private: * \param [in] b The second item. */ inline void Exch (std::size_t a, std::size_t b); - /** Percolate a newly inserted Last item to its proper position. */ + /** Percolate a newly inserted Last item to its proper position. */ void BottomUp (void); /** * Percolate a deletion bubble down the heap. diff --git a/src/core/model/int-to-type.h b/src/core/model/int-to-type.h index e7edb7559..b67392529 100644 --- a/src/core/model/int-to-type.h +++ b/src/core/model/int-to-type.h @@ -31,7 +31,7 @@ namespace ns3 { * Convert an integer into a type. * * This trivial template is extremely useful, as explained in - * "Modern C++ Design", p 29, section 2.4, + * "Modern C++ Design", p 29, section 2.4, * "Mapping Integral Constants to Types". * * For an example, see timer-impl.h @@ -43,7 +43,8 @@ template struct IntToType { /** Enumeration holding the type-specific value. */ - enum v_e { + enum v_e + { value = v /**< The integer value distinguishing this type. */ }; }; diff --git a/src/core/model/int64x64-128.cc b/src/core/model/int64x64-128.cc index c3b625da0..1d70ef261 100644 --- a/src/core/model/int64x64-128.cc +++ b/src/core/model/int64x64-128.cc @@ -46,7 +46,7 @@ NS_LOG_COMPONENT_DEFINE ("int64x64-128"); * \param [out] ub The unsigned magnitude of the second operand. * \returns \c true if the result will be negative. */ -static inline +static inline bool output_sign (const int128_t sa, const int128_t sb, @@ -93,7 +93,7 @@ int64x64_t::Umul (const uint128_t a, const uint128_t b) // if the high part is not zero, put a warning NS_ABORT_MSG_IF ((hiPart & HP_MASK_HI) != 0, "High precision 128 bits multiplication error: multiplication overflow."); - + // Adding 64-bit terms to get 128-bit results, with carries res1 = loPart >> 64; res2 = midPart & HP_MASK_LO; @@ -121,7 +121,7 @@ int64x64_t::Div (const int64x64_t & o) uint128_t int64x64_t::Udiv (const uint128_t a, const uint128_t b) { - + uint128_t rem = a; uint128_t den = b; uint128_t quo = rem / den; @@ -131,36 +131,36 @@ int64x64_t::Udiv (const uint128_t a, const uint128_t b) // Now, manage the remainder const uint64_t DIGITS = 64; // Number of fraction digits (bits) we need const uint128_t ZERO = 0; - + NS_ASSERT_MSG (rem < den, "Remainder not less than divisor"); - + uint64_t digis = 0; // Number of digits we have already uint64_t shift = 0; // Number we are going to get this round - - // Skip trailing zeros in divisor + + // Skip trailing zeros in divisor while ( (shift < DIGITS) && !(den & 0x1)) { ++shift; den >>= 1; } - + while ( (digis < DIGITS) && (rem != ZERO) ) { // Skip leading zeros in remainder - while ( (digis + shift < DIGITS) && - !(rem & HP128_MASK_HI_BIT)) - { + while ( (digis + shift < DIGITS) + && !(rem & HP128_MASK_HI_BIT)) + { ++shift; rem <<= 1; } // Cast off denominator bits if: // Need more digits and - // LSB is zero or + // LSB is zero or // rem < den - while ( (digis + shift < DIGITS) && - ( !(den & 0x1) || (rem < den) ) ) + while ( (digis + shift < DIGITS) + && ( !(den & 0x1) || (rem < den) ) ) { ++shift; den >>= 1; @@ -183,11 +183,11 @@ int64x64_t::Udiv (const uint128_t a, const uint128_t b) shift = DIGITS - digis; result <<= shift; } - + return result; } -void +void int64x64_t::MulByInvert (const int64x64_t & o) { bool negResult = _v < 0; @@ -213,7 +213,7 @@ int64x64_t::UmulByInvert (const uint128_t a, const uint128_t b) return result; } -int64x64_t +int64x64_t int64x64_t::Invert (const uint64_t v) { NS_ASSERT (v > 1); diff --git a/src/core/model/int64x64-128.h b/src/core/model/int64x64-128.h index 676ec6cde..a830bcb3a 100644 --- a/src/core/model/int64x64-128.h +++ b/src/core/model/int64x64-128.h @@ -45,7 +45,7 @@ namespace ns3 { class int64x64_t { /// uint128_t high bit (sign bit). - static const uint128_t HP128_MASK_HI_BIT = (((int128_t)1)<<127); + static const uint128_t HP128_MASK_HI_BIT = (((int128_t)1) << 127); /// Mask for fraction part. static const uint64_t HP_MASK_LO = 0xffffffffffffffffULL; /// Mask for sign + integer part. @@ -73,7 +73,8 @@ public: * specifically the double implementation. To handle this, * we expose the underlying implementation type here. */ - enum impl_type { + enum impl_type + { int128_impl, //!< Native \c int128_t implementation. cairo_impl, //!< Cairo wideint implementation. ld_impl, //!< `long double` implementation. @@ -84,7 +85,8 @@ public: /// Default constructor. inline int64x64_t () - : _v (0) {} + : _v (0) + {} /** * \name Construct from a floating point value. * @@ -117,8 +119,8 @@ public: const uint64_t lo = flo; if (flo >= HP_MAX_64) { - // conversion to uint64 rolled over - ++hi; + // conversion to uint64 rolled over + ++hi; } _v = hi << 64; _v |= lo; @@ -138,12 +140,12 @@ public: _v <<= 64; } inline int64x64_t (const long int v) - : _v (v) + : _v (v) { _v <<= 64; } inline int64x64_t (const long long int v) - : _v (v) + : _v (v) { _v <<= 64; } @@ -153,17 +155,17 @@ public: _v <<= 64; } inline int64x64_t (const unsigned long int v) - : _v (v) + : _v (v) { _v <<= 64; } inline int64x64_t (const unsigned long long int v) - : _v (v) + : _v (v) { _v <<= 64; } /**@}*/ - + /** * Construct from explicit high and low values. * @@ -182,7 +184,8 @@ public: * \param [in] o Value to copy. */ inline int64x64_t (const int64x64_t & o) - : _v (o._v) {} + : _v (o._v) + {} /** * Assignment. * @@ -263,7 +266,7 @@ private: friend bool operator < (const int64x64_t & lhs, const int64x64_t & rhs); friend bool operator > (const int64x64_t & lhs, const int64x64_t & rhs); - + friend int64x64_t & operator += ( int64x64_t & lhs, const int64x64_t & rhs); friend int64x64_t & operator -= ( int64x64_t & lhs, const int64x64_t & rhs); friend int64x64_t & operator *= ( int64x64_t & lhs, const int64x64_t & rhs); @@ -276,7 +279,7 @@ private: * Implement `*=`. * * \param [in] o The other factor. - */ + */ void Mul (const int64x64_t & o); /** * Implement `/=`. @@ -334,7 +337,8 @@ private: * \param [in] v Integer value to represent. */ inline int64x64_t (const int128_t v) - : _v (v) {} + : _v (v) + {} int128_t _v; //!< The Q64.64 value. diff --git a/src/core/model/int64x64-cairo.cc b/src/core/model/int64x64-cairo.cc index 713db018c..dbc823d6d 100644 --- a/src/core/model/int64x64-cairo.cc +++ b/src/core/model/int64x64-cairo.cc @@ -54,7 +54,7 @@ NS_LOG_COMPONENT_DEFINE ("int64x64-cairo"); * \param [out] ub The unsigned magnitude of the second operand. * \returns True if the result will be negative. */ -static inline +static inline bool output_sign (const cairo_int128_t sa, const cairo_int128_t sb, @@ -109,9 +109,9 @@ int64x64_t::Umul (const cairo_uint128_t a, const cairo_uint128_t b) res2 = _cairo_uint64_to_uint128 (hiPart.lo); res1 = _cairo_uint128_add (res1, res2); res1 = _cairo_uint128_lsl (res1, 64); - + result = _cairo_uint128_add (result, res1); - + return result; } @@ -135,36 +135,36 @@ int64x64_t::Udiv (const cairo_uint128_t a, const cairo_uint128_t b) // Now, manage the remainder const uint64_t DIGITS = 64; // Number of fraction digits (bits) we need const cairo_uint128_t ZERO = _cairo_uint32_to_uint128 ((uint32_t)0); - + NS_ASSERT_MSG (_cairo_uint128_lt (rem, den), "Remainder not less than divisor"); - + uint64_t digis = 0; // Number of digits we have already uint64_t shift = 0; // Number we are going to get this round - - // Skip trailing zeros in divisor + + // Skip trailing zeros in divisor while ( (shift < DIGITS) && !(den.lo & 0x1)) { ++shift; den = _cairo_uint128_rsl (den, 1); } - - while ( (digis < DIGITS) && !(_cairo_uint128_eq(rem, ZERO)) ) + + while ( (digis < DIGITS) && !(_cairo_uint128_eq (rem, ZERO)) ) { // Skip leading zeros in remainder - while ( (digis + shift < DIGITS) && - !(rem.hi & HPCAIRO_MASK_HI_BIT) ) - { + while ( (digis + shift < DIGITS) + && !(rem.hi & HPCAIRO_MASK_HI_BIT) ) + { ++shift; rem = _cairo_int128_lsl (rem, 1); } // Cast off denominator bits if: // Need more digits and - // LSB is zero or + // LSB is zero or // rem < den - while ( (digis + shift < DIGITS) && - ( !(den.lo & 0x1) || _cairo_uint128_lt (rem, den) ) ) + while ( (digis + shift < DIGITS) + && ( !(den.lo & 0x1) || _cairo_uint128_lt (rem, den) ) ) { ++shift; den = _cairo_uint128_rsl (den, 1); @@ -186,11 +186,11 @@ int64x64_t::Udiv (const cairo_uint128_t a, const cairo_uint128_t b) shift = DIGITS - digis; result = _cairo_uint128_lsl (result, static_cast (shift)); } - + return result; } -void +void int64x64_t::MulByInvert (const int64x64_t & o) { bool sign = _cairo_int128_negative (_v); @@ -199,7 +199,7 @@ int64x64_t::MulByInvert (const int64x64_t & o) _v = sign ? _cairo_int128_negate (result) : result; } - + cairo_uint128_t int64x64_t::UmulByInvert (const cairo_uint128_t a, const cairo_uint128_t b) { @@ -214,7 +214,7 @@ int64x64_t::UmulByInvert (const cairo_uint128_t a, const cairo_uint128_t b) return result; } -int64x64_t +int64x64_t int64x64_t::Invert (const uint64_t v) { NS_ASSERT (v > 1); diff --git a/src/core/model/int64x64-cairo.h b/src/core/model/int64x64-cairo.h index d52cbe1dd..5dd514e2f 100644 --- a/src/core/model/int64x64-cairo.h +++ b/src/core/model/int64x64-cairo.h @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* - * Copyright (c) 2010 INRIA + * Copyright (c) 2010 INRIA * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as @@ -40,7 +40,7 @@ namespace ns3 { class int64x64_t { /// High bit of fractional part - static const uint64_t HPCAIRO_MASK_HI_BIT = (((uint64_t)1)<<63); + static const uint64_t HPCAIRO_MASK_HI_BIT = (((uint64_t)1) << 63); /// Mask for fraction part static const uint64_t HP_MASK_LO = 0xffffffffffffffffULL; /** @@ -65,7 +65,8 @@ public: * specifically the double implementation. To handle this, * we expose the underlying implementation type here. */ - enum impl_type { + enum impl_type + { int128_impl, //!< Native int128_t implementation. cairo_impl, //!< cairo wideint implementation ld_impl, //!< long double implementation @@ -112,8 +113,8 @@ public: const cairo_uint64_t lo = (cairo_uint64_t)flo; if (flo >= HP_MAX_64) { - // conversion to uint64 rolled over - ++hi; + // conversion to uint64 rolled over + ++hi; } _v.hi = hi; _v.lo = lo; @@ -176,7 +177,8 @@ public: * \param [in] o Value to copy. */ inline int64x64_t (const int64x64_t & o) - : _v (o._v) {} + : _v (o._v) + {} /** * Assignment. * @@ -253,7 +255,7 @@ private: friend bool operator < (const int64x64_t & lhs, const int64x64_t & rhs); friend bool operator > (const int64x64_t & lhs, const int64x64_t & rhs); - + friend int64x64_t & operator += ( int64x64_t & lhs, const int64x64_t & rhs); friend int64x64_t & operator -= ( int64x64_t & lhs, const int64x64_t & rhs); friend int64x64_t & operator *= ( int64x64_t & lhs, const int64x64_t & rhs); @@ -266,7 +268,7 @@ private: * Implement `*=`. * * \param [in] o The other factor. - */ + */ void Mul (const int64x64_t & o); /** * Implement `/=`. @@ -354,7 +356,7 @@ inline bool operator > (const int64x64_t & lhs, const int64x64_t & rhs) */ inline int64x64_t & operator += (int64x64_t & lhs, const int64x64_t & rhs) { - lhs._v = _cairo_int128_add( lhs._v, rhs._v ); + lhs._v = _cairo_int128_add ( lhs._v, rhs._v ); return lhs; } /** @@ -363,7 +365,7 @@ inline int64x64_t & operator += (int64x64_t & lhs, const int64x64_t & rhs) */ inline int64x64_t & operator -= (int64x64_t & lhs, const int64x64_t & rhs) { - lhs._v = _cairo_int128_sub( lhs._v, rhs._v ); + lhs._v = _cairo_int128_sub ( lhs._v, rhs._v ); return lhs; } /** diff --git a/src/core/model/int64x64-double.h b/src/core/model/int64x64-double.h index 47950fde5..51f7080ea 100644 --- a/src/core/model/int64x64-double.h +++ b/src/core/model/int64x64-double.h @@ -64,7 +64,8 @@ public: * specifically the double implementation. To handle this, * we expose the underlying implementation type here. */ - enum impl_type { + enum impl_type + { int128_impl, //!< Native int128_t implementation. cairo_impl, //!< cairo wideint implementation ld_impl, //!< long double implementation @@ -75,7 +76,8 @@ public: /// Default constructor inline int64x64_t () - : _v (0) {} + : _v (0) + {} /**@{*/ /** * Construct from a floating point value. @@ -83,9 +85,11 @@ public: * \param [in] v Floating value to represent */ inline int64x64_t (double v) - : _v (v) {} + : _v (v) + {} inline int64x64_t (long double v) - : _v (v) {} + : _v (v) + {} /**@}*/ /**@{*/ @@ -95,17 +99,23 @@ public: * \param [in] v Integer value to represent */ inline int64x64_t (int v) - : _v (v) {} + : _v (v) + {} inline int64x64_t (long int v) - : _v (v) {} + : _v (v) + {} inline int64x64_t (long long int v) - : _v (static_cast (v)) {} + : _v (static_cast (v)) + {} inline int64x64_t (unsigned int v) - : _v (v) {} + : _v (v) + {} inline int64x64_t (unsigned long int v) - : _v (v) {} + : _v (v) + {} inline int64x64_t (unsigned long long int v) - : _v (static_cast (v)) {} + : _v (static_cast (v)) + {} /**@}*/ /** * Construct from explicit high and low values. @@ -116,10 +126,10 @@ public: explicit inline int64x64_t (int64_t hi, uint64_t lo) { const bool negative = hi < 0; - const long double hild = static_cast (hi); + const long double hild = static_cast (hi); const long double fhi = negative ? -hild : hild; const long double flo = lo / HP_MAX_64; - _v = negative ? - fhi : fhi; + _v = negative ? -fhi : fhi; _v += flo; // _v = negative ? -_v : _v; } @@ -130,7 +140,8 @@ public: * \param [in] o Value to copy. */ inline int64x64_t (const int64x64_t & o) - : _v (o._v) {} + : _v (o._v) + {} /** * Assignment. * @@ -151,6 +162,7 @@ public: { return (double)_v; } + private: /** * Get the high and low portions of this value. @@ -158,7 +170,7 @@ private: * \return A pair of the high and low words */ std::pair GetHighLow (void) const - { + { const bool negative = _v < 0; const long double v = negative ? -_v : _v; @@ -178,20 +190,21 @@ private: uint64_t lo = static_cast (flo); if (flo >= HP_MAX_64) { - // conversion to uint64 rolled over - ++hi; + // conversion to uint64 rolled over + ++hi; } if (negative) { - lo = ~lo; - hi = ~hi; - if (++lo == 0) - { - ++hi; - } + lo = ~lo; + hi = ~hi; + if (++lo == 0) + { + ++hi; + } } return std::make_pair (hi, lo); - } + } + public: /** * Get the integer portion. @@ -243,7 +256,7 @@ private: friend bool operator < (const int64x64_t & lhs, const int64x64_t & rhs); friend bool operator > (const int64x64_t & lhs, const int64x64_t & rhs); - + friend int64x64_t & operator += ( int64x64_t & lhs, const int64x64_t & rhs); friend int64x64_t & operator -= ( int64x64_t & lhs, const int64x64_t & rhs); friend int64x64_t & operator *= ( int64x64_t & lhs, const int64x64_t & rhs); diff --git a/src/core/model/int64x64.cc b/src/core/model/int64x64.cc index 9d596ce65..94a711267 100644 --- a/src/core/model/int64x64.cc +++ b/src/core/model/int64x64.cc @@ -85,7 +85,7 @@ std::ostream &operator << (std::ostream &os, const int64x64_t &value) oss << hi << "."; // collect the digits here so we can round properly - int64x64_t low(0, absVal.GetLow ()); + int64x64_t low (0, absVal.GetLow ()); std::size_t places = 0; // Number of decimal places printed so far bool more = true; // Should we print more digits? @@ -101,9 +101,9 @@ std::ostream &operator << (std::ostream &os, const int64x64_t &value) low *= 10; digit = low.GetHigh (); NS_ASSERT_MSG ( (0 <= digit) && (digit <= 9), - "digit " << digit << " out of range [0,9] " - << " streaming out " - << HEXHILOW (value.GetHigh (), value.GetLow ()) ); + "digit " << digit << " out of range [0,9] " << + " streaming out " << + HEXHILOW (value.GetHigh (), value.GetLow ()) ); low -= digit; oss << std::setw (1) << digit; @@ -125,7 +125,8 @@ std::ostream &operator << (std::ostream &os, const int64x64_t &value) << HEXHILOW (low.GetHigh (), low.GetLow ()) << std::dec << std::setfill (' ' ) << std::left); - } while (more); + } + while (more); // Check if we need to round the last printed digit, // based on the first unprinted digit @@ -142,14 +143,14 @@ std::ostream &operator << (std::ostream &os, const int64x64_t &value) { if (*rit == '.') // Skip over the decimal point { - continue ; + continue; } ++(*rit); // Add the carry if (*rit <= '9') // Relies on character order... { carry = false; - break ; // Carry complete + break; // Carry complete } else { @@ -210,8 +211,8 @@ static uint64_t ReadLoDigits (std::string str) { int digit = *rit - '0'; NS_ASSERT_MSG ( (0 <= digit) && (digit <= 9), - "digit " << digit << " out of range [0,9]" - << " streaming in low digits \"" << str << "\""); + "digit " << digit << " out of range [0,9]" << + " streaming in low digits \"" << str << "\""); low = (low + digit + round) / 10; } @@ -254,12 +255,12 @@ std::istream &operator >> (std::istream &is, int64x64_t &value) next = str.find (".", cur); if (next != std::string::npos) { - hi = ReadHiDigits (str.substr (cur, next-cur)); - lo = ReadLoDigits (str.substr (next+1, str.size ()-(next+1))); + hi = ReadHiDigits (str.substr (cur, next - cur)); + lo = ReadLoDigits (str.substr (next + 1, str.size () - (next + 1))); } else if (cur != std::string::npos) { - hi = ReadHiDigits (str.substr (cur, str.size ()-cur)); + hi = ReadHiDigits (str.substr (cur, str.size () - cur)); lo = 0; } else diff --git a/src/core/model/int64x64.h b/src/core/model/int64x64.h index b50bbac4d..a72814875 100644 --- a/src/core/model/int64x64.h +++ b/src/core/model/int64x64.h @@ -69,11 +69,11 @@ namespace ns3 { * Comparison | `==`, `!=`, `<`, `<=`, `>`, `>=` * Unary | `+`, `-`, `!` */ - + /** * \ingroup highprec * \class int64x64_t - * + * * High precision numerical type, implementing Q64.64 fixed precision. */ diff --git a/src/core/model/integer.cc b/src/core/model/integer.cc index 680d9b483..7d890734d 100644 --- a/src/core/model/integer.cc +++ b/src/core/model/integer.cc @@ -54,8 +54,10 @@ MakeIntegerChecker (int64_t min, int64_t max, std::string name) IntegerChecker (int64_t minValue, int64_t maxValue, std::string name) : m_minValue (minValue), m_maxValue (maxValue), - m_name (name) {} - virtual bool Check (const AttributeValue &value) const { + m_name (name) + {} + virtual bool Check (const AttributeValue &value) const + { NS_LOG_FUNCTION (&value); const IntegerValue *v = dynamic_cast (&value); if (v == 0) @@ -64,25 +66,30 @@ MakeIntegerChecker (int64_t min, int64_t max, std::string name) } return v->Get () >= m_minValue && v->Get () <= m_maxValue; } - virtual std::string GetValueTypeName (void) const { + virtual std::string GetValueTypeName (void) const + { NS_LOG_FUNCTION_NOARGS (); return "ns3::IntegerValue"; } - virtual bool HasUnderlyingTypeInformation (void) const { + virtual bool HasUnderlyingTypeInformation (void) const + { NS_LOG_FUNCTION_NOARGS (); return true; } - virtual std::string GetUnderlyingTypeInformation (void) const { + virtual std::string GetUnderlyingTypeInformation (void) const + { NS_LOG_FUNCTION_NOARGS (); std::ostringstream oss; oss << m_name << " " << m_minValue << ":" << m_maxValue; return oss.str (); } - virtual Ptr Create (void) const { + virtual Ptr Create (void) const + { NS_LOG_FUNCTION_NOARGS (); return ns3::Create (); } - virtual bool Copy (const AttributeValue &src, AttributeValue &dst) const { + virtual bool Copy (const AttributeValue &src, AttributeValue &dst) const + { NS_LOG_FUNCTION (&src << &dst); const IntegerValue *source = dynamic_cast (&src); IntegerValue *destination = dynamic_cast (&dst); diff --git a/src/core/model/list-scheduler.cc b/src/core/model/list-scheduler.cc index b7b6fe6ba..1929b634a 100644 --- a/src/core/model/list-scheduler.cc +++ b/src/core/model/list-scheduler.cc @@ -53,8 +53,7 @@ ListScheduler::ListScheduler () NS_LOG_FUNCTION (this); } ListScheduler::~ListScheduler () -{ -} +{} void ListScheduler::Insert (const Event &ev) diff --git a/src/core/model/log-macros-disabled.h b/src/core/model/log-macros-disabled.h index 4b4d51541..2a889ae0b 100644 --- a/src/core/model/log-macros-disabled.h +++ b/src/core/model/log-macros-disabled.h @@ -35,7 +35,7 @@ std::clog << msg This expression is required for forms like NS_LOG_LOGIC (... << std::endl ...) - + ns3::ParameterLogger (std::clog) << msg This expression is required for NS_LOG_FUNCTION (... << vector ...) @@ -45,7 +45,7 @@ note: in expansion of macro NS_LOG_LOGIC (std::endl... error: no match for operator<< (operand types are ns3::ParameterLogger and ) - + note: candidate: template ns3::ParameterLogger& ns3::ParameterLogger::operator<<(T) note: template argument deduction/substitution failed @@ -63,16 +63,14 @@ * \ingroup logging * Empty logging macro implementation, used when logging is disabled. */ -#define NS_LOG_NOOP_INTERNAL(msg) \ - do \ - if (false) \ - { \ - std::clog << msg; \ - } \ - while (false) +#define NS_LOG_NOOP_INTERNAL(msg) \ + do if (false) \ + { \ + std::clog << msg; \ + } while (false) #define NS_LOG(level, msg) \ - NS_LOG_NOOP_INTERNAL (msg) + NS_LOG_NOOP_INTERNAL (msg) #define NS_LOG_FUNCTION_NOARGS() @@ -80,19 +78,17 @@ * \ingroup logging * Empty logging macro implementation, used when logging is disabled. */ -#define NS_LOG_NOOP_FUNC_INTERNAL(msg) \ - do \ - if (false) \ - { \ - ns3::ParameterLogger (std::clog) << msg; \ - } \ - while (false) +#define NS_LOG_NOOP_FUNC_INTERNAL(msg) \ + do if (false) \ + { \ + ns3::ParameterLogger (std::clog) << msg; \ + } while (false) #define NS_LOG_FUNCTION(parameters) \ - NS_LOG_NOOP_FUNC_INTERNAL (parameters) + NS_LOG_NOOP_FUNC_INTERNAL (parameters) #define NS_LOG_UNCOND(msg) \ - NS_LOG_NOOP_INTERNAL (msg) + NS_LOG_NOOP_INTERNAL (msg) #endif /* !NS3_LOG_ENABLE */ diff --git a/src/core/model/log-macros-enabled.h b/src/core/model/log-macros-enabled.h index 52f01a3c5..f9abb2967 100644 --- a/src/core/model/log-macros-enabled.h +++ b/src/core/model/log-macros-enabled.h @@ -73,8 +73,8 @@ #define NS_LOG_APPEND_FUNC_PREFIX \ if (g_log.IsEnabled (ns3::LOG_PREFIX_FUNC)) \ { \ - std::clog << g_log.Name () << ":" << \ - __FUNCTION__ << "(): "; \ + std::clog << g_log.Name () << ":" \ + << __FUNCTION__ << "(): "; \ } \ /** @@ -151,8 +151,7 @@ */ #define NS_LOG(level, msg) \ NS_LOG_CONDITION \ - do \ - { \ + do { \ if (g_log.IsEnabled (level)) \ { \ NS_LOG_APPEND_TIME_PREFIX; \ @@ -162,8 +161,7 @@ NS_LOG_APPEND_LEVEL_PREFIX (level); \ std::clog << msg << std::endl; \ } \ - } \ - while (false) + } while (false) /** * \ingroup logging @@ -175,8 +173,7 @@ */ #define NS_LOG_FUNCTION_NOARGS() \ NS_LOG_CONDITION \ - do \ - { \ + do { \ if (g_log.IsEnabled (ns3::LOG_FUNCTION)) \ { \ NS_LOG_APPEND_TIME_PREFIX; \ @@ -185,8 +182,7 @@ std::clog << g_log.Name () << ":" \ << __FUNCTION__ << "()" << std::endl; \ } \ - } \ - while (false) + } while (false) /** @@ -236,12 +232,10 @@ * \param [in] msg The message to log */ #define NS_LOG_UNCOND(msg) \ - NS_LOG_CONDITION \ - do \ - { \ + NS_LOG_CONDITION \ + do { \ std::clog << msg << std::endl; \ - } \ - while (false) + } while (false) #endif /* NS3_LOG_ENABLE */ diff --git a/src/core/model/log.cc b/src/core/model/log.cc index 2df564fef..538024765 100644 --- a/src/core/model/log.cc +++ b/src/core/model/log.cc @@ -74,7 +74,7 @@ public: */ static PrintList g_printList; - + /* static */ LogComponent::ComponentList * LogComponent::GetComponentList (void) @@ -98,7 +98,7 @@ PrintList::PrintList () while (next != std::string::npos) { next = env.find_first_of (":", cur); - std::string tmp = std::string (env, cur, next-cur); + std::string tmp = std::string (env, cur, next - cur); if (tmp == "print-list") { LogComponentPrintList (); @@ -125,7 +125,7 @@ LogComponent::LogComponent (const std::string & name, { if (i->first == name) { - NS_FATAL_ERROR ("Log component \""<insert (std::make_pair (name, this)); @@ -164,7 +164,7 @@ LogComponent::EnvVarCheck (void) while (next != std::string::npos) { next = env.find_first_of (":", cur); - std::string tmp = std::string (env, cur, next-cur); + std::string tmp = std::string (env, cur, next - cur); std::string::size_type equal = tmp.find ("="); std::string component; if (equal == std::string::npos) @@ -235,8 +235,8 @@ LogComponent::EnvVarCheck (void) { level |= LOG_PREFIX_LEVEL; } - else if ( (lev == "prefix_all") || - (!pre_pipe && ( (lev == "all") || (lev == "*") ) ) + else if ( (lev == "prefix_all") + || (!pre_pipe && ( (lev == "all") || (lev == "*") ) ) ) { level |= LOG_PREFIX_ALL; @@ -275,7 +275,8 @@ LogComponent::EnvVarCheck (void) } pre_pipe = false; - } while (next_lev != std::string::npos); + } + while (next_lev != std::string::npos); Enable ((enum LogLevel)level); } @@ -286,7 +287,7 @@ LogComponent::EnvVarCheck (void) } -bool +bool LogComponent::IsEnabled (const enum LogLevel level) const { // LogComponentEnableEnvVar (); @@ -305,13 +306,13 @@ LogComponent::SetMask (const enum LogLevel level) m_mask |= level; } -void +void LogComponent::Enable (const enum LogLevel level) { m_levels |= (level & ~m_mask); } -void +void LogComponent::Disable (const enum LogLevel level) { m_levels &= ~level; @@ -331,7 +332,7 @@ LogComponent::File (void) const /* static */ std::string -LogComponent::GetLevelLabel(const enum LogLevel level) +LogComponent::GetLevelLabel (const enum LogLevel level) { if (level == LOG_ERROR) { @@ -365,31 +366,31 @@ LogComponent::GetLevelLabel(const enum LogLevel level) } } -void +void LogComponentEnable (char const *name, enum LogLevel level) { LogComponent::ComponentList *components = LogComponent::GetComponentList (); LogComponent::ComponentList::const_iterator i; - for (i = components->begin (); - i != components->end (); + for (i = components->begin (); + i != components->end (); i++) { - if (i->first.compare (name) == 0) + if (i->first.compare (name) == 0) { i->second->Enable (level); return; } } - if (i == components->end()) - { - // nothing matched - LogComponentPrintList(); - NS_FATAL_ERROR ("Logging component \"" << name << - "\" not found. See above for a list of available log components"); + if (i == components->end ()) + { + // nothing matched + LogComponentPrintList (); + NS_FATAL_ERROR ("Logging component \"" << name << + "\" not found. See above for a list of available log components"); } } -void +void LogComponentEnableAll (enum LogLevel level) { LogComponent::ComponentList *components = LogComponent::GetComponentList (); @@ -401,7 +402,7 @@ LogComponentEnableAll (enum LogLevel level) } } -void +void LogComponentDisable (char const *name, enum LogLevel level) { LogComponent::ComponentList *components = LogComponent::GetComponentList (); @@ -409,7 +410,7 @@ LogComponentDisable (char const *name, enum LogLevel level) i != components->end (); i++) { - if (i->first.compare (name) == 0) + if (i->first.compare (name) == 0) { i->second->Disable (level); break; @@ -417,7 +418,7 @@ LogComponentDisable (char const *name, enum LogLevel level) } } -void +void LogComponentDisableAll (enum LogLevel level) { LogComponent::ComponentList *components = LogComponent::GetComponentList (); @@ -429,7 +430,7 @@ LogComponentDisableAll (enum LogLevel level) } } -void +void LogComponentPrintList (void) { LogComponent::ComponentList *components = LogComponent::GetComponentList (); @@ -509,23 +510,23 @@ LogComponentPrintList (void) * \param [in] componentName The putative log component name. * \returns \c true if \c componentName exists. */ -static bool ComponentExists(std::string componentName) +static bool ComponentExists (std::string componentName) { - char const*name=componentName.c_str(); + char const*name = componentName.c_str (); LogComponent::ComponentList *components = LogComponent::GetComponentList (); LogComponent::ComponentList::const_iterator i; for (i = components->begin (); i != components->end (); i++) - { - if (i->first.compare (name) == 0) - { - return true; - } + { + if (i->first.compare (name) == 0) + { + return true; + } } - NS_ASSERT (i == components->end()); - // nothing matched - return false; + NS_ASSERT (i == components->end ()); + // nothing matched + return false; } /** @@ -537,7 +538,7 @@ static void CheckEnvironmentVariables (void) { #ifdef HAVE_GETENV char *envVar = getenv ("NS_LOG"); - if (envVar == 0 || std::strlen(envVar) == 0) + if (envVar == 0 || std::strlen (envVar) == 0) { return; } @@ -545,32 +546,32 @@ static void CheckEnvironmentVariables (void) std::string::size_type cur = 0; std::string::size_type next = 0; - + while (next != std::string::npos) { next = env.find_first_of (":", cur); - std::string tmp = std::string (env, cur, next-cur); + std::string tmp = std::string (env, cur, next - cur); std::string::size_type equal = tmp.find ("="); std::string component; if (equal == std::string::npos) { - // ie no '=' characters found + // ie no '=' characters found component = tmp; - if (ComponentExists(component) || component == "*" || component == "***") + if (ComponentExists (component) || component == "*" || component == "***") { return; } - else + else { - LogComponentPrintList(); - NS_FATAL_ERROR("Invalid or unregistered component name \"" << component << - "\" in env variable NS_LOG, see above for a list of valid components"); + LogComponentPrintList (); + NS_FATAL_ERROR ("Invalid or unregistered component name \"" << component << + "\" in env variable NS_LOG, see above for a list of valid components"); } } else { component = tmp.substr (0, equal); - if (ComponentExists(component) || component == "*") + if (ComponentExists (component) || component == "*") { std::string::size_type cur_lev; std::string::size_type next_lev = equal; @@ -604,25 +605,26 @@ static void CheckEnvironmentVariables (void) || lev == "level_all" || lev == "*" || lev == "**" - ) + ) { continue; } - else + else { - NS_FATAL_ERROR("Invalid log level \"" << lev << - "\" in env variable NS_LOG for component name " << component); + NS_FATAL_ERROR ("Invalid log level \"" << lev << + "\" in env variable NS_LOG for component name " << component); } - } while (next_lev != std::string::npos); + } + while (next_lev != std::string::npos); } - else + else { - LogComponentPrintList(); - NS_FATAL_ERROR("Invalid or unregistered component name \"" << component << - "\" in env variable NS_LOG, see above for a list of valid components"); + LogComponentPrintList (); + NS_FATAL_ERROR ("Invalid or unregistered component name \"" << component << + "\" in env variable NS_LOG, see above for a list of valid components"); } } - cur = next + 1; // parse next component + cur = next + 1; // parse next component } #endif } @@ -633,7 +635,7 @@ void LogSetTimePrinter (TimePrinter printer) * This is the only place where we are more or less sure that all log variables * are registered. See \bugid{1082} for details. */ - CheckEnvironmentVariables(); + CheckEnvironmentVariables (); } TimePrinter LogGetTimePrinter (void) { @@ -653,12 +655,11 @@ NodePrinter LogGetNodePrinter (void) ParameterLogger::ParameterLogger (std::ostream &os) : m_first (true), m_os (os) -{ -} +{} template<> -ParameterLogger& -ParameterLogger::operator<< (const std::string param) +ParameterLogger & +ParameterLogger::operator<< (const std::string param) { if (m_first) { @@ -673,42 +674,42 @@ ParameterLogger::operator<< (const std::string param) } template<> -ParameterLogger& -ParameterLogger::operator<< (const char * param) +ParameterLogger & +ParameterLogger::operator<< (const char * param) { (*this) << std::string (param); return *this; } template<> -ParameterLogger& -ParameterLogger::operator<< (const int8_t param) +ParameterLogger & +ParameterLogger::operator<< (const int8_t param) { if (m_first) - { - m_os << static_cast (param); - m_first = false; - } + { + m_os << static_cast (param); + m_first = false; + } else - { - m_os << ", " << static_cast (param); - } + { + m_os << ", " << static_cast (param); + } return *this; } template<> -ParameterLogger& -ParameterLogger::operator<< (const uint8_t param) +ParameterLogger & +ParameterLogger::operator<< (const uint8_t param) { if (m_first) - { - m_os << static_cast (param); - m_first = false; - } + { + m_os << static_cast (param); + m_first = false; + } else - { - m_os << ", " << static_cast (param); - } + { + m_os << ", " << static_cast (param); + } return *this; } diff --git a/src/core/model/log.h b/src/core/model/log.h index ea34f9604..3bb57bc10 100644 --- a/src/core/model/log.h +++ b/src/core/model/log.h @@ -47,9 +47,9 @@ * LOG functionality: macros which allow developers to * send information to the \c std::clog output stream. * - * All logging messages are disabled by default. To enable selected logging + * All logging messages are disabled by default. To enable selected logging * messages, use the ns3::LogComponentEnable - * function or use the NS_LOG environment variable + * function or use the NS_LOG environment variable * * Use the environment variable NS_LOG to define a ':'-separated list of * logging components to enable. For example (using bash syntax), @@ -90,7 +90,8 @@ namespace ns3 { /** * Logging severity classes and levels. */ -enum LogLevel { +enum LogLevel +{ LOG_NONE = 0x00000000, //!< No logging. LOG_ERROR = 0x00000001, //!< Serious error messages only. @@ -171,10 +172,10 @@ void LogComponentDisableAll (enum LogLevel level); /** * Define a Log component with a specific name. * - * This macro should be used at the top of every file in which you want + * This macro should be used at the top of every file in which you want * to use the NS_LOG macro. This macro defines a new * "log component" which can be later selectively enabled - * or disabled with the ns3::LogComponentEnable and + * or disabled with the ns3::LogComponentEnable and * ns3::LogComponentDisable functions or with the NS_LOG * environment variable. * @@ -246,7 +247,7 @@ void LogComponentDisableAll (enum LogLevel level); * \param [in] name The log component name. */ #define NS_LOG_STATIC_TEMPLATE_DEFINE(name) \ - static LogComponent & NS_UNUSED_GLOBAL (g_log) = GetLogComponent (name) + static LogComponent & NS_UNUSED_GLOBAL (g_log) = GetLogComponent (name) /** * Use \ref NS_LOG to output a message of level LOG_ERROR. @@ -377,7 +378,7 @@ public: * * \return The name of this LogComponent. */ - char const *Name (void) const; + char const * Name (void) const; /** * Get the compilation unit defining this LogComponent. * \returns The file name. @@ -389,7 +390,7 @@ public: * \param [in] level The LogLevel to get the label for. * \return The string label for \c level. */ - static std::string GetLevelLabel(const enum LogLevel level); + static std::string GetLevelLabel (const enum LogLevel level); /** * Prevent the enabling of a specific LogLevel. * @@ -417,16 +418,15 @@ public: * * \returns The list of LogComponents. */ - static ComponentList *GetComponentList (void); + static ComponentList * GetComponentList (void); - private: /** * Parse the `NS_LOG` environment variable for options relating to this * LogComponent. */ void EnvVarCheck (void); - + int32_t m_levels; //!< Enabled LogLevels. int32_t m_mask; //!< Blocked LogLevels. std::string m_name; //!< LogComponent name. @@ -449,6 +449,7 @@ class ParameterLogger { bool m_first; //!< First argument flag, doesn't get `, `. std::ostream &m_os; //!< Underlying output stream. + public: /** * Constructor. @@ -511,26 +512,26 @@ ParameterLogger::operator<< (std::vector vector) * \return This ParameterLogger, so it's chainable. */ template<> -ParameterLogger& -ParameterLogger::operator<< (const std::string param); - +ParameterLogger & +ParameterLogger::operator<< (const std::string param); + /** * Specialization for C-strings. * \param [in] param The function parameter. * \return This ParameterLogger, so it's chainable. */ template<> -ParameterLogger& -ParameterLogger::operator<< (const char * param); - +ParameterLogger & +ParameterLogger::operator<< (const char * param); + /** * Specialization for int8_t. * \param [in] param The function parameter. * \return This ParameterLogger, so it's chainable. */ template<> -ParameterLogger& - ParameterLogger::operator<< (int8_t param); +ParameterLogger & +ParameterLogger::operator<< (int8_t param); /** * Specialization for uint8_t. @@ -538,8 +539,8 @@ ParameterLogger& * \return This ParameterLogger, so it's chainable. */ template<> -ParameterLogger& - ParameterLogger::operator<< (uint8_t param); +ParameterLogger & +ParameterLogger::operator<< (uint8_t param); } // namespace ns3 diff --git a/src/core/model/make-event.cc b/src/core/model/make-event.cc index 1e829a9a3..c82bd4e8b 100644 --- a/src/core/model/make-event.cc +++ b/src/core/model/make-event.cc @@ -37,22 +37,22 @@ EventImpl * MakeEvent (void (*f)(void)) // zero arg version class EventFunctionImpl0 : public EventImpl { -public: + public: typedef void (*F)(void); EventFunctionImpl0 (F function) : m_function (function) - { - } + {} virtual ~EventFunctionImpl0 () - { - } -protected: + {} + + protected: virtual void Notify (void) { (*m_function)(); } -private: + + private: F m_function; } *ev = new EventFunctionImpl0 (f); return ev; diff --git a/src/core/model/make-event.h b/src/core/model/make-event.h index 766f7d7c8..060473977 100644 --- a/src/core/model/make-event.h +++ b/src/core/model/make-event.h @@ -171,7 +171,7 @@ EventImpl * MakeEvent (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6); /**@}*/ - + /** * \ingroup events * \defgroup makeeventfnptr MakeEvent from Function Pointers. @@ -349,7 +349,7 @@ struct EventMemberImplObjTraits * \param [in] p Object pointer. * \return A reference to the object pointed to by p. */ - static T &GetReference (T *p) + static T & GetReference (T *p) { return *p; } @@ -361,16 +361,15 @@ EventImpl * MakeEvent (MEM mem_ptr, OBJ obj) // zero argument version class EventMemberImpl0 : public EventImpl { -public: + public: EventMemberImpl0 (OBJ obj, MEM function) : m_obj (obj), m_function (function) - { - } + {} virtual ~EventMemberImpl0 () - { - } -private: + {} + + private: virtual void Notify (void) { (EventMemberImplObjTraits::GetReference (m_obj).*m_function)(); @@ -389,18 +388,18 @@ EventImpl * MakeEvent (MEM mem_ptr, OBJ obj, T1 a1) // one argument version class EventMemberImpl1 : public EventImpl { -public: + public: EventMemberImpl1 (OBJ obj, MEM function, T1 a1) : m_obj (obj), m_function (function), m_a1 (a1) - { - } -protected: + {} + + protected: virtual ~EventMemberImpl1 () - { - } -private: + {} + + private: virtual void Notify (void) { (EventMemberImplObjTraits::GetReference (m_obj).*m_function)(m_a1); @@ -419,19 +418,19 @@ EventImpl * MakeEvent (MEM mem_ptr, OBJ obj, T1 a1, T2 a2) // two argument version class EventMemberImpl2 : public EventImpl { -public: + public: EventMemberImpl2 (OBJ obj, MEM function, T1 a1, T2 a2) : m_obj (obj), m_function (function), m_a1 (a1), m_a2 (a2) - { - } -protected: + {} + + protected: virtual ~EventMemberImpl2 () - { - } -private: + {} + + private: virtual void Notify (void) { (EventMemberImplObjTraits::GetReference (m_obj).*m_function)(m_a1, m_a2); @@ -451,20 +450,20 @@ EventImpl * MakeEvent (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3) // three argument version class EventMemberImpl3 : public EventImpl { -public: + public: EventMemberImpl3 (OBJ obj, MEM function, T1 a1, T2 a2, T3 a3) : m_obj (obj), m_function (function), m_a1 (a1), m_a2 (a2), m_a3 (a3) - { - } -protected: + {} + + protected: virtual ~EventMemberImpl3 () - { - } -private: + {} + + private: virtual void Notify (void) { (EventMemberImplObjTraits::GetReference (m_obj).*m_function)(m_a1, m_a2, m_a3); @@ -485,7 +484,7 @@ EventImpl * MakeEvent (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4) // four argument version class EventMemberImpl4 : public EventImpl { -public: + public: EventMemberImpl4 (OBJ obj, MEM function, T1 a1, T2 a2, T3 a3, T4 a4) : m_obj (obj), m_function (function), @@ -493,13 +492,13 @@ public: m_a2 (a2), m_a3 (a3), m_a4 (a4) - { - } -protected: + {} + + protected: virtual ~EventMemberImpl4 () - { - } -private: + {} + + private: virtual void Notify (void) { (EventMemberImplObjTraits::GetReference (m_obj).*m_function)(m_a1, m_a2, m_a3, m_a4); @@ -522,7 +521,7 @@ EventImpl * MakeEvent (MEM mem_ptr, OBJ obj, // five argument version class EventMemberImpl5 : public EventImpl { -public: + public: EventMemberImpl5 (OBJ obj, MEM function, T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) : m_obj (obj), m_function (function), @@ -531,13 +530,13 @@ public: m_a3 (a3), m_a4 (a4), m_a5 (a5) - { - } -protected: + {} + + protected: virtual ~EventMemberImpl5 () - { - } -private: + {} + + private: virtual void Notify (void) { (EventMemberImplObjTraits::GetReference (m_obj).*m_function)(m_a1, m_a2, m_a3, m_a4, m_a5); @@ -561,7 +560,7 @@ EventImpl * MakeEvent (MEM mem_ptr, OBJ obj, // six argument version class EventMemberImpl6 : public EventImpl { -public: + public: EventMemberImpl6 (OBJ obj, MEM function, T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6) : m_obj (obj), m_function (function), @@ -571,13 +570,13 @@ public: m_a4 (a4), m_a5 (a5), m_a6 (a6) - { - } -protected: + {} + + protected: virtual ~EventMemberImpl6 () - { - } -private: + {} + + private: virtual void Notify (void) { (EventMemberImplObjTraits::GetReference (m_obj).*m_function)(m_a1, m_a2, m_a3, m_a4, m_a5, m_a6); @@ -600,19 +599,19 @@ EventImpl * MakeEvent (void (*f)(U1), T1 a1) // one arg version class EventFunctionImpl1 : public EventImpl { -public: + public: typedef void (*F)(U1); EventFunctionImpl1 (F function, T1 a1) : m_function (function), m_a1 (a1) - { - } -protected: + {} + + protected: virtual ~EventFunctionImpl1 () - { - } -private: + {} + + private: virtual void Notify (void) { (*m_function)(m_a1); @@ -629,20 +628,20 @@ EventImpl * MakeEvent (void (*f)(U1,U2), T1 a1, T2 a2) // two arg version class EventFunctionImpl2 : public EventImpl { -public: + public: typedef void (*F)(U1, U2); EventFunctionImpl2 (F function, T1 a1, T2 a2) : m_function (function), m_a1 (a1), m_a2 (a2) - { - } -protected: + {} + + protected: virtual ~EventFunctionImpl2 () - { - } -private: + {} + + private: virtual void Notify (void) { (*m_function)(m_a1, m_a2); @@ -661,7 +660,7 @@ EventImpl * MakeEvent (void (*f)(U1,U2,U3), T1 a1, T2 a2, T3 a3) // three arg version class EventFunctionImpl3 : public EventImpl { -public: + public: typedef void (*F)(U1, U2, U3); EventFunctionImpl3 (F function, T1 a1, T2 a2, T3 a3) @@ -669,13 +668,13 @@ public: m_a1 (a1), m_a2 (a2), m_a3 (a3) - { - } -protected: + {} + + protected: virtual ~EventFunctionImpl3 () - { - } -private: + {} + + private: virtual void Notify (void) { (*m_function)(m_a1, m_a2, m_a3); @@ -695,7 +694,7 @@ EventImpl * MakeEvent (void (*f)(U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4) // four arg version class EventFunctionImpl4 : public EventImpl { -public: + public: typedef void (*F)(U1, U2, U3, U4); EventFunctionImpl4 (F function, T1 a1, T2 a2, T3 a3, T4 a4) @@ -704,13 +703,13 @@ public: m_a2 (a2), m_a3 (a3), m_a4 (a4) - { - } -protected: + {} + + protected: virtual ~EventFunctionImpl4 () - { - } -private: + {} + + private: virtual void Notify (void) { (*m_function)(m_a1, m_a2, m_a3, m_a4); @@ -731,7 +730,7 @@ EventImpl * MakeEvent (void (*f)(U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 // five arg version class EventFunctionImpl5 : public EventImpl { -public: + public: typedef void (*F)(U1,U2,U3,U4,U5); EventFunctionImpl5 (F function, T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) @@ -741,13 +740,13 @@ public: m_a3 (a3), m_a4 (a4), m_a5 (a5) - { - } -protected: + {} + + protected: virtual ~EventFunctionImpl5 () - { - } -private: + {} + + private: virtual void Notify (void) { (*m_function)(m_a1, m_a2, m_a3, m_a4, m_a5); @@ -769,7 +768,7 @@ EventImpl * MakeEvent (void (*f)(U1,U2,U3,U4,U5,U6), T1 a1, T2 a2, T3 a3, T4 a4, // six arg version class EventFunctionImpl6 : public EventImpl { -public: + public: typedef void (*F)(U1,U2,U3,U4,U5,U6); EventFunctionImpl6 (F function, T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6) @@ -780,13 +779,13 @@ public: m_a4 (a4), m_a5 (a5), m_a6 (a6) - { - } -protected: + {} + + protected: virtual ~EventFunctionImpl6 () - { - } -private: + {} + + private: virtual void Notify (void) { (*m_function)(m_a1, m_a2, m_a3, m_a4, m_a5, m_a6); diff --git a/src/core/model/math.h b/src/core/model/math.h index 40f67fc72..8d42fde9a 100644 --- a/src/core/model/math.h +++ b/src/core/model/math.h @@ -18,7 +18,7 @@ * Christoph Moench-Tegeder */ -// It is recommended to include this header instead of or +// It is recommended to include this header instead of or // whenever the log2(x) function is needed. See bug 1467. #ifndef MATH_H @@ -34,10 +34,10 @@ #ifdef __FreeBSD__ -#if __FreeBSD_version <= 704101 || \ - (__FreeBSD_version >= 800000 && __FreeBSD_version < 802502) || \ - (__FreeBSD_version >= 900000 && __FreeBSD_version < 900027) -#define log2(x) (std::log(x) / M_LN2) +#if __FreeBSD_version <= 704101 \ + || (__FreeBSD_version >= 800000 && __FreeBSD_version < 802502) \ + || (__FreeBSD_version >= 900000 && __FreeBSD_version < 900027) +#define log2(x) (std::log (x) / M_LN2) #endif /* __FreeBSD_version */ #endif /* __FreeBSD__ */ diff --git a/src/core/model/names.cc b/src/core/model/names.cc index 78eae267d..22ab4997c 100644 --- a/src/core/model/names.cc +++ b/src/core/model/names.cc @@ -81,8 +81,7 @@ public: NameNode::NameNode () : m_parent (0), m_name (""), m_object (0) -{ -} +{} NameNode::NameNode (const NameNode &nameNode) { @@ -124,9 +123,9 @@ public: NamesPriv (); /** Destructor. */ ~NamesPriv (); - + // Doxygen \copydoc bug: won't copy these docs, so we repeat them. - + /** * Internal implementation for Names::Add(std::string,Ptr) * @@ -258,7 +257,7 @@ private: * \param [in] object The object to check. * \returns The corresponding NameNode, if it exists. */ - NameNode *IsNamed (Ptr object); + NameNode * IsNamed (Ptr object); /** * Check if a name already exists as a child of a NameNode. * @@ -319,7 +318,7 @@ NamesPriv::Add (std::string name, Ptr object) NS_LOG_FUNCTION (this << name << object); // // This is the simple, easy to use version of Add, so we want it to be flexible. - // We don't want to force a user to always type the fully qualified namespace + // We don't want to force a user to always type the fully qualified namespace // name, so we allow the namespace name to be omitted. For example, calling // Add ("Client/ath0", obj) should result in exactly the same behavior as // Add ("/Names/Client/ath0", obj). Calling Add ("Client", obj) should have @@ -351,8 +350,8 @@ NamesPriv::Add (std::string name, Ptr object) } // - // There must now be a fully qualified path in the string. All fully - // qualified names begin with "/Names". We have to split off the final + // There must now be a fully qualified path in the string. All fully + // qualified names begin with "/Names". We have to split off the final // segment which will become the name of the object. A '/' that // separates the path from the final segment had better be there since // we just made sure that at least the namespace name was there. @@ -426,19 +425,19 @@ NamesPriv::Rename (std::string oldpath, std::string newname) { NS_LOG_FUNCTION (this << oldpath << newname); // - // This is the simple, easy to use version of Rename, so we want it to be - // flexible. We don't want to force a user to always type the fully + // This is the simple, easy to use version of Rename, so we want it to be + // flexible. We don't want to force a user to always type the fully // qualified namespace name, so we allow the namespace name to be omitted. - // For example, calling Rename ("Client/ath0", "eth0") should result in + // For example, calling Rename ("Client/ath0", "eth0") should result in // exactly the same behavior as Rename ("/Names/Client/ath0", "eth0"). - // Calling Rename ("Client", "Router") should have the same effect as + // Calling Rename ("Client", "Router") should have the same effect as // Rename ("Names/Client", "Router") // // The first thing to do, then, is to "canonicalize" the input string to always // be a fully qualified path. // // If we are given a name that begins with "/Names/" we assume that this is a - // fully qualified path to the object we want to change. We split the path into + // fully qualified path to the object we want to change. We split the path into // path string (cf directory) and a final segment (cf filename) and then call // the "Real" Rename. // @@ -461,8 +460,8 @@ NamesPriv::Rename (std::string oldpath, std::string newname) } // - // There must now be a fully qualified path in the oldpath string. All - // fully qualified names begin with "/Names". We have to split off the final + // There must now be a fully qualified path in the oldpath string. All + // fully qualified names begin with "/Names". We have to split off the final // segment which will become the name we want to rename. A '/' that // separates the path from the final segment (name) had better be there since // we just made sure that at least the namespace name was there. @@ -596,14 +595,14 @@ NamesPriv::Find (std::string path) // This is hooked in from simple, easy to use version of Find, so we want it // to be flexible. // - // If we are provided a path that doesn't begin with "/Names", we assume + // If we are provided a path that doesn't begin with "/Names", we assume // that the caller has simply given us a path starting with a name that // is in the root namespace. This allows people to omit the "/Names" prefix. // and simply do a Find ("Client/eth0") instead of having to always do a // Find ("/Names/Client/eth0"); // // So, if we are given a name that begins with "/Names/" the upshot is that we - // just remove that prefix and treat the rest of the string as starting with a + // just remove that prefix and treat the rest of the string as starting with a // name in the root namespace. // @@ -627,7 +626,7 @@ NamesPriv::Find (std::string path) // // The string is now composed entirely of path segments in - // the /Names name space and we have eaten the leading slash. e.g., + // the /Names name space and we have eaten the leading slash. e.g., // remaining = "ClientNode/eth0" // // The start of the search is always at the root of the name space. @@ -639,7 +638,7 @@ NamesPriv::Find (std::string path) if (offset == std::string::npos) { // - // There are no remaining slashes so this is the last segment of the + // There are no remaining slashes so this is the last segment of the // specified name. We're done when we find it // std::map::iterator i = node->m_nameMap.find (remaining); @@ -657,7 +656,7 @@ NamesPriv::Find (std::string path) else { // - // There are more slashes so this is an intermediate segment of the + // There are more slashes so this is an intermediate segment of the // specified name. We need to "recurse" when we find this segment. // offset = remaining.find ("/"); diff --git a/src/core/model/names.h b/src/core/model/names.h index bfaba11aa..b1fe13cba 100644 --- a/src/core/model/names.h +++ b/src/core/model/names.h @@ -72,7 +72,7 @@ public: * time just as you might have different files of the same name * under different directories. * - * \param [in] name The name of the object you want to associate; which may be + * \param [in] name The name of the object you want to associate; which may be * prepended with a path to that object. * \param [in] object A smart pointer to the object itself. */ @@ -126,7 +126,7 @@ public: * file name. Recall that the path string actually refers to a * previously named object, "under" which you want to accomplish * some naming action. - * + * * However, the path is sometimes not available, and you only have * the object that is represented by the path in the names name * space. To support this use-case in a reasonably high-performance @@ -239,7 +239,7 @@ public: * file name. Recall that the path string actually refers to a * previously named object, "under" which you want to accomplish * some naming action. - * + * * However, the path is sometimes not available, and you only have * the object that is represented by the path in the names name * space. To support this use-case in a reasonably high-performance @@ -326,7 +326,7 @@ public: * in the system with that associated to it. If there is, do a * GetObject on the resulting object to convert it to the requested * typename and return it. - * + * * An object can be referred to in two ways. Either you can talk * about it using its fully qualified path name, for example, * "/Names/client/eth0" or you can refer to it by its name, in this @@ -449,10 +449,10 @@ private: static Ptr FindInternal (Ptr context, std::string name); }; - + template /* static */ -Ptr +Ptr Names::Find (std::string path) { Ptr obj = FindInternal (path); @@ -468,7 +468,7 @@ Names::Find (std::string path) template /* static */ -Ptr +Ptr Names::Find (std::string path, std::string name) { Ptr obj = FindInternal (path, name); @@ -484,7 +484,7 @@ Names::Find (std::string path, std::string name) template /* static */ -Ptr +Ptr Names::Find (Ptr context, std::string name) { Ptr obj = FindInternal (context, name); diff --git a/src/core/model/node-printer.cc b/src/core/model/node-printer.cc index da754a044..c824b25eb 100644 --- a/src/core/model/node-printer.cc +++ b/src/core/model/node-printer.cc @@ -32,12 +32,12 @@ namespace ns3 { - NS_LOG_COMPONENT_DEFINE ("NodePrinter"); +NS_LOG_COMPONENT_DEFINE ("NodePrinter"); /** * \ingroup logging * Default node id printer implementation. - * + * * \param [in,out] os The output stream to print the node id on. */ void @@ -54,6 +54,5 @@ DefaultNodePrinter (std::ostream &os) } - } // namespace ns3 diff --git a/src/core/model/non-copyable.h b/src/core/model/non-copyable.h index 12fe143cc..ec9b28e4b 100644 --- a/src/core/model/non-copyable.h +++ b/src/core/model/non-copyable.h @@ -55,9 +55,11 @@ class NonCopyable { protected: /** Constructor. */ - NonCopyable () {} + NonCopyable () + {} /** Destructor. */ - ~NonCopyable () {} + ~NonCopyable () + {} private: /** Copy constructor. Private, so not copyable. */ @@ -68,8 +70,8 @@ private: * \return The unmodified copy. */ NonCopyable & operator = (const NonCopyable &other); -}; +}; -} // namespace ns3 +} // namespace ns3 #endif /* NS3_NON_COPYABLE_H */ diff --git a/src/core/model/nstime.h b/src/core/model/nstime.h index 109d899a5..b88f57a25 100644 --- a/src/core/model/nstime.h +++ b/src/core/model/nstime.h @@ -41,7 +41,7 @@ namespace ns3 { class TimeWithUnit; - + /** * \ingroup core * \defgroup time Virtual Time @@ -144,7 +144,7 @@ public: * * \param [in] o Time to copy */ - inline Time(const Time & o) + inline Time (const Time & o) : m_data (o.m_data) { if (g_markingTimes) @@ -181,7 +181,7 @@ public: { if (g_markingTimes) { - Mark (this); + Mark (this); } } explicit inline Time (int v) @@ -189,7 +189,7 @@ public: { if (g_markingTimes) { - Mark (this); + Mark (this); } } explicit inline Time (long int v) @@ -197,7 +197,7 @@ public: { if (g_markingTimes) { - Mark (this); + Mark (this); } } explicit inline Time (long long int v) @@ -205,7 +205,7 @@ public: { if (g_markingTimes) { - Mark (this); + Mark (this); } } explicit inline Time (unsigned int v) @@ -213,7 +213,7 @@ public: { if (g_markingTimes) { - Mark (this); + Mark (this); } } explicit inline Time (unsigned long int v) @@ -221,7 +221,7 @@ public: { if (g_markingTimes) { - Mark (this); + Mark (this); } } explicit inline Time (unsigned long long int v) @@ -229,7 +229,7 @@ public: { if (g_markingTimes) { - Mark (this); + Mark (this); } } explicit inline Time (const int64x64_t & v) @@ -237,11 +237,11 @@ public: { if (g_markingTimes) { - Mark (this); + Mark (this); } } /**@}*/ - + /** * \brief Construct Time object from common time expressions like "1ms" * @@ -416,7 +416,7 @@ public: */ static enum Unit GetResolution (void); - + /** * Create a Time in the current unit. * @@ -522,14 +522,14 @@ public: } /**@}*/ - + /** Cast to int64x64_t */ inline operator int64x64_t () const { return int64x64_t (m_data); } - + /** * Attach a unit to a Time, to facilitate output in a specific unit. * @@ -574,10 +574,10 @@ private: * * \return A pointer to the current Resolution */ - static inline struct Resolution *PeekResolution (void) + static inline struct Resolution * PeekResolution (void) { static struct Time::Resolution resolution = SetDefaultNsResolution (); - return & resolution; + return &resolution; } /** * Get the Information record for \p timeUnit for the current Resolution @@ -585,9 +585,9 @@ private: * \param [in] timeUnit The Unit to get Information for * \return The Information for \p timeUnit */ - static inline struct Information *PeekInformation (enum Unit timeUnit) + static inline struct Information * PeekInformation (enum Unit timeUnit) { - return & (PeekResolution ()->info[timeUnit]); + return &(PeekResolution ()->info[timeUnit]); } /** @@ -641,6 +641,7 @@ private: * includes nstime.h. */ static MarkedTimes * g_markingTimes; + public: /** * Function to force static initialization of Time. @@ -648,6 +649,7 @@ public: * \return \c true on the first call */ static bool StaticInit (); + private: /* Friend the Simulator class so it can call the private function @@ -733,15 +735,15 @@ private: }; // class Time namespace TracedValueCallback { - - /** + +/** * TracedValue callback signature for Time * * \param [in] oldValue Original value of the traced variable * \param [in] newValue New value of the traced variable */ - typedef void (* Time)(Time oldValue, Time newValue); - +typedef void (* Time)(Time oldValue, Time newValue); + } // namespace TracedValueCallback /// Force static initialization of Time @@ -964,7 +966,7 @@ inline Time & operator -= (Time & lhs, const Time & rhs) lhs.m_data -= rhs.m_data; return lhs; } - + inline Time Abs (const Time & time) { return Time ((time.m_data < 0) ? -time.m_data : time.m_data); @@ -981,7 +983,7 @@ inline Time Min (const Time & ta, const Time & tb) /** * \ingroup time * \brief Time output streamer. - * + * * Generates output such as "3.96ns". Times are printed with the * following format flags (independent of the stream flags): * - `showpos` @@ -1108,7 +1110,7 @@ inline Time FemtoSeconds (int64x64_t value) return Time::From (value, Time::FS); } /**@}*/ - + /** * \ingroup time @@ -1176,7 +1178,7 @@ public: TimeWithUnit (const Time time, const Time::Unit unit) : m_time (time), m_unit (unit) - { }; + { } private: Time m_time; //!< The time diff --git a/src/core/model/object-base.cc b/src/core/model/object-base.cc index bee519762..562d5b5eb 100644 --- a/src/core/model/object-base.cc +++ b/src/core/model/object-base.cc @@ -57,7 +57,7 @@ GetObjectIid (void) return tid; } -TypeId +TypeId ObjectBase::GetTypeId (void) { NS_LOG_FUNCTION_NOARGS (); @@ -65,7 +65,7 @@ ObjectBase::GetTypeId (void) return tid; } -ObjectBase::~ObjectBase () +ObjectBase::~ObjectBase () { NS_LOG_FUNCTION (this); } @@ -82,34 +82,35 @@ ObjectBase::ConstructSelf (const AttributeConstructionList &attributes) // loop over the inheritance tree back to the Object base class. NS_LOG_FUNCTION (this << &attributes); TypeId tid = GetInstanceTypeId (); - do { + do + { // loop over all attributes in object type - NS_LOG_DEBUG ("construct tid="< value = attributes.Find(info.checker); + Ptr value = attributes.Find (info.checker); // See if this attribute should not be set here in the // constructor. if (!(info.flags & TypeId::ATTR_CONSTRUCT)) { - // Handle this attribute if it should not be + // Handle this attribute if it should not be // set here. if (value == 0) { // Skip this attribute if it's not in the // AttributeConstructionList. continue; - } + } else { // This is an error because this attribute is not // settable in its constructor but is present in // the AttributeConstructionList. - NS_FATAL_ERROR ("Attribute name="< accessor, +ObjectBase::DoSet (Ptr accessor, Ptr checker, const AttributeValue &value) { @@ -189,19 +191,19 @@ ObjectBase::SetAttribute (std::string name, const AttributeValue &value) TypeId tid = GetInstanceTypeId (); if (!tid.LookupAttributeByName (name, &info)) { - NS_FATAL_ERROR ("Attribute name="< v = info.checker->Create (); ok = info.accessor->Get (this, *PeekPointer (v)); if (!ok) { - NS_FATAL_ERROR ("Attribute name="<Set (v->SerializeToString (info.checker)); } @@ -264,8 +266,8 @@ ObjectBase::GetAttributeFailSafe (std::string name, AttributeValue &value) const { return false; } - if (!(info.flags & TypeId::ATTR_GET) || - !info.accessor->HasGetter ()) + if (!(info.flags & TypeId::ATTR_GET) + || !info.accessor->HasGetter ()) { return false; } @@ -289,7 +291,7 @@ ObjectBase::GetAttributeFailSafe (std::string name, AttributeValue &value) const return true; } -bool +bool ObjectBase::TraceConnectWithoutContext (std::string name, const CallbackBase &cb) { NS_LOG_FUNCTION (this << name << &cb); @@ -302,7 +304,7 @@ ObjectBase::TraceConnectWithoutContext (std::string name, const CallbackBase &cb bool ok = accessor->ConnectWithoutContext (this, cb); return ok; } -bool +bool ObjectBase::TraceConnect (std::string name, std::string context, const CallbackBase &cb) { NS_LOG_FUNCTION (this << name << context << &cb); @@ -315,7 +317,7 @@ ObjectBase::TraceConnect (std::string name, std::string context, const CallbackB bool ok = accessor->Connect (this, context, cb); return ok; } -bool +bool ObjectBase::TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb) { NS_LOG_FUNCTION (this << name << &cb); @@ -328,7 +330,7 @@ ObjectBase::TraceDisconnectWithoutContext (std::string name, const CallbackBase bool ok = accessor->DisconnectWithoutContext (this, cb); return ok; } -bool +bool ObjectBase::TraceDisconnect (std::string name, std::string context, const CallbackBase &cb) { NS_LOG_FUNCTION (this << name << context << &cb); diff --git a/src/core/model/object-base.h b/src/core/model/object-base.h index 7fc53755a..998ae4356 100644 --- a/src/core/model/object-base.h +++ b/src/core/model/object-base.h @@ -152,7 +152,7 @@ public: * - The attribute doesn't exist in this Object. * - The attribute can't be set (no Setter). * - The attribute couldn't be deserialized from the AttributeValue. - * + * * \param [in] name The name of the attribute to set. * \param [in] value The name of the attribute to set. */ @@ -165,7 +165,7 @@ public: * * \param [in] name The name of the attribute to set. * \param [in] value The value to set it to. - * \return \c true if the requested attribute exists and could be set, + * \return \c true if the requested attribute exists and could be set, * \c false otherwise. */ bool SetAttributeFailSafe (std::string name, const AttributeValue &value); @@ -245,23 +245,23 @@ protected: /** * Notifier called once the ObjectBase is fully constructed. * - * This method is invoked once all member attributes have been + * This method is invoked once all member attributes have been * initialized. Subclasses can override this method to be notified * of this event but if they do this, they must chain up to their * parent's NotifyConstructionCompleted method. */ virtual void NotifyConstructionCompleted (void); /** - * Complete construction of ObjectBase; invoked by derived classes. + * Complete construction of ObjectBase; invoked by derived classes. * - * Invoked from subclasses to initialize all of their + * Invoked from subclasses to initialize all of their * attribute members. This method will typically be invoked * automatically from ns3::CreateObject if your class derives * from ns3::Object. If you derive from ns3::ObjectBase directly, * you should make sure that you invoke this method from * your most-derived constructor. * - * \param [in] attributes The attribute values used to initialize + * \param [in] attributes The attribute values used to initialize * the member variables of this object's instance. */ void ConstructSelf (const AttributeConstructionList &attributes); @@ -278,7 +278,7 @@ private: * and written to the storage location. */ bool DoSet (Ptr spec, - Ptr checker, + Ptr checker, const AttributeValue &value); }; diff --git a/src/core/model/object-factory.cc b/src/core/model/object-factory.cc index 09e14acd8..c97d28899 100644 --- a/src/core/model/object-factory.cc +++ b/src/core/model/object-factory.cc @@ -29,7 +29,7 @@ namespace ns3 { -NS_LOG_COMPONENT_DEFINE("ObjectFactory"); +NS_LOG_COMPONENT_DEFINE ("ObjectFactory"); ObjectFactory::ObjectFactory () { @@ -77,7 +77,7 @@ ObjectFactory::Set (std::string name, const AttributeValue &value) { return; } - + struct TypeId::AttributeInformation info; if (!m_tid.LookupAttributeByName (name, &info)) { @@ -93,14 +93,14 @@ ObjectFactory::Set (std::string name, const AttributeValue &value) m_parameters.Add (name, info.checker, value.Copy ()); } -TypeId +TypeId ObjectFactory::GetTypeId (void) const { NS_LOG_FUNCTION (this); return m_tid; } -Ptr +Ptr ObjectFactory::Create (void) const { NS_LOG_FUNCTION (this); @@ -148,7 +148,7 @@ std::istream & operator >> (std::istream &is, ObjectFactory &factory) NS_ASSERT (lbracket != std::string::npos); NS_ASSERT (rbracket != std::string::npos); std::string tid = v.substr (0, lbracket); - std::string parameters = v.substr (lbracket+1,rbracket-(lbracket+1)); + std::string parameters = v.substr (lbracket + 1,rbracket - (lbracket + 1)); factory.SetTypeId (tid); std::string::size_type cur; cur = 0; @@ -162,7 +162,7 @@ std::istream & operator >> (std::istream &is, ObjectFactory &factory) } else { - std::string name = parameters.substr (cur, equal-cur); + std::string name = parameters.substr (cur, equal - cur); struct TypeId::AttributeInformation info; if (!factory.m_tid.LookupAttributeByName (name, &info)) { @@ -175,12 +175,12 @@ std::istream & operator >> (std::istream &is, ObjectFactory &factory) std::string value; if (next == std::string::npos) { - value = parameters.substr (equal+1, parameters.size () - (equal+1)); + value = parameters.substr (equal + 1, parameters.size () - (equal + 1)); cur = parameters.size (); } else { - value = parameters.substr (equal+1, next - (equal+1)); + value = parameters.substr (equal + 1, next - (equal + 1)); cur = next + 1; } Ptr val = info.checker->Create (); diff --git a/src/core/model/object-factory.h b/src/core/model/object-factory.h index 30a20681d..ab1bef95b 100644 --- a/src/core/model/object-factory.h +++ b/src/core/model/object-factory.h @@ -71,9 +71,9 @@ public: void SetTypeId (const char *tid); void SetTypeId (std::string tid); /**@}*/ - + /** - * Check if the ObjectFactory has been configured with a TypeId + * Check if the ObjectFactory has been configured with a TypeId * * \return true if a TypeId has been configured to the ObjectFactory */ @@ -142,7 +142,7 @@ private: * The list of attributes and values to be used in constructing * objects by this factory. */ - AttributeConstructionList m_parameters; + AttributeConstructionList m_parameters; }; std::ostream & operator << (std::ostream &os, const ObjectFactory &factory); @@ -175,18 +175,17 @@ std::istream & operator >> (std::istream &is, ObjectFactory &factory); * \returns A pointer to a newly allocated object. */ template -Ptr -CreateObjectWithAttributes - (std::string n1 = "", const AttributeValue & v1 = EmptyAttributeValue (), - std::string n2 = "", const AttributeValue & v2 = EmptyAttributeValue (), - std::string n3 = "", const AttributeValue & v3 = EmptyAttributeValue (), - std::string n4 = "", const AttributeValue & v4 = EmptyAttributeValue (), - std::string n5 = "", const AttributeValue & v5 = EmptyAttributeValue (), - std::string n6 = "", const AttributeValue & v6 = EmptyAttributeValue (), - std::string n7 = "", const AttributeValue & v7 = EmptyAttributeValue (), - std::string n8 = "", const AttributeValue & v8 = EmptyAttributeValue (), - std::string n9 = "", const AttributeValue & v9 = EmptyAttributeValue () - ); +Ptr +CreateObjectWithAttributes (std::string n1 = "", const AttributeValue & v1 = EmptyAttributeValue (), + std::string n2 = "", const AttributeValue & v2 = EmptyAttributeValue (), + std::string n3 = "", const AttributeValue & v3 = EmptyAttributeValue (), + std::string n4 = "", const AttributeValue & v4 = EmptyAttributeValue (), + std::string n5 = "", const AttributeValue & v5 = EmptyAttributeValue (), + std::string n6 = "", const AttributeValue & v6 = EmptyAttributeValue (), + std::string n7 = "", const AttributeValue & v7 = EmptyAttributeValue (), + std::string n8 = "", const AttributeValue & v8 = EmptyAttributeValue (), + std::string n9 = "", const AttributeValue & v9 = EmptyAttributeValue () + ); ATTRIBUTE_HELPER_HEADER (ObjectFactory); @@ -201,7 +200,7 @@ ATTRIBUTE_HELPER_HEADER (ObjectFactory); namespace ns3 { template -Ptr +Ptr ObjectFactory::Create (void) const { Ptr object = Create (); @@ -209,7 +208,7 @@ ObjectFactory::Create (void) const } template -Ptr +Ptr CreateObjectWithAttributes (std::string n1, const AttributeValue & v1, std::string n2, const AttributeValue & v2, std::string n3, const AttributeValue & v3, @@ -222,15 +221,15 @@ CreateObjectWithAttributes (std::string n1, const AttributeValue & v1, { ObjectFactory factory; factory.SetTypeId (T::GetTypeId ()); - factory.Set(n1, v1); - factory.Set(n2, v2); - factory.Set(n3, v3); - factory.Set(n4, v4); - factory.Set(n5, v5); - factory.Set(n6, v6); - factory.Set(n7, v7); - factory.Set(n8, v8); - factory.Set(n9, v9); + factory.Set (n1, v1); + factory.Set (n2, v2); + factory.Set (n3, v3); + factory.Set (n4, v4); + factory.Set (n5, v5); + factory.Set (n6, v6); + factory.Set (n7, v7); + factory.Set (n8, v8); + factory.Set (n9, v9); return factory.Create (); } diff --git a/src/core/model/object-map.h b/src/core/model/object-map.h index f04943a57..4cbb7ca2f 100644 --- a/src/core/model/object-map.h +++ b/src/core/model/object-map.h @@ -59,7 +59,7 @@ Ptr MakeObjectMapChecker (void); template Ptr MakeObjectMapAccessor (Ptr (T::*get)(INDEX) const, - INDEX (T::*getN)(void) const); + INDEX (T::*getN)(void) const); /** * \ingroup attribute_ObjectMap @@ -81,7 +81,8 @@ MakeObjectMapAccessor (U T::*memberVector) { struct MemberStdContainer : public ObjectPtrContainerAccessor { - virtual bool DoGetN (const ObjectBase *object, std::size_t *n) const { + virtual bool DoGetN (const ObjectBase *object, std::size_t *n) const + { const T *obj = dynamic_cast (object); if (obj == 0) { @@ -90,7 +91,8 @@ MakeObjectMapAccessor (U T::*memberVector) *n = (obj->*m_memberVector).size (); return true; } - virtual Ptr DoGet(const ObjectBase *object, std::size_t i, std::size_t *index) const { + virtual Ptr DoGet (const ObjectBase *object, std::size_t i, std::size_t *index) const + { const T *obj = static_cast (object); typename U::const_iterator begin = (obj->*m_memberVector).begin (); typename U::const_iterator end = (obj->*m_memberVector).end (); @@ -123,17 +125,17 @@ Ptr MakeObjectMapChecker (void) template Ptr MakeObjectMapAccessor (Ptr (T::*get)(INDEX) const, - INDEX (T::*getN)(void) const) + INDEX (T::*getN)(void) const) { - return MakeObjectPtrContainerAccessor(get, getN); + return MakeObjectPtrContainerAccessor (get, getN); } template Ptr MakeObjectMapAccessor (INDEX (T::*getN)(void) const, - Ptr (T::*get)(INDEX) const) + Ptr (T::*get)(INDEX) const) { - return MakeObjectPtrContainerAccessor(get, getN); + return MakeObjectPtrContainerAccessor (get, getN); } } // namespace ns3 diff --git a/src/core/model/object-ptr-container.cc b/src/core/model/object-ptr-container.cc index 48afed13e..94a1aedb6 100644 --- a/src/core/model/object-ptr-container.cc +++ b/src/core/model/object-ptr-container.cc @@ -57,12 +57,12 @@ Ptr ObjectPtrContainerValue::Get (std::size_t i) const { NS_LOG_FUNCTION (this << i); - Iterator it = m_objects.find (i); + Iterator it = m_objects.find (i); Ptr value = 0; if ( it != m_objects.end () ) - { - value = m_objects.find (i)->second; - } + { + value = m_objects.find (i)->second; + } return value; } @@ -72,7 +72,7 @@ ObjectPtrContainerValue::Copy (void) const NS_LOG_FUNCTION (this); return ns3::Create (*this); } -std::string +std::string ObjectPtrContainerValue::SerializeToString (Ptr checker) const { NS_LOG_FUNCTION (this << checker); @@ -88,7 +88,7 @@ ObjectPtrContainerValue::SerializeToString (Ptr checker) } return oss.str (); } -bool +bool ObjectPtrContainerValue::DeserializeFromString (std::string value, Ptr checker) { NS_LOG_FUNCTION (this << value << checker); @@ -96,14 +96,14 @@ ObjectPtrContainerValue::DeserializeFromString (std::string value, Ptr Ptr MakeObjectPtrContainerAccessor (Ptr (T::*get)(INDEX) const, - INDEX (T::*getN)(void) const); + INDEX (T::*getN)(void) const); /** * \ingroup attribute_ObjectPtrContainer @@ -145,7 +145,7 @@ MakeObjectPtrContainerAccessor (Ptr (T::*get)(INDEX) const, template Ptr MakeObjectPtrContainerAccessor (INDEX (T::*getN)(void) const, - Ptr (T::*get)(INDEX) const); + Ptr (T::*get)(INDEX) const); class ObjectPtrContainerChecker : public AttributeChecker { @@ -176,25 +176,32 @@ template class ObjectPtrContainerChecker : public ns3::ObjectPtrContainerChecker { public: - virtual TypeId GetItemTypeId (void) const { + virtual TypeId GetItemTypeId (void) const + { return T::GetTypeId (); } - virtual bool Check (const AttributeValue &value) const { + virtual bool Check (const AttributeValue &value) const + { return dynamic_cast (&value) != 0; } - virtual std::string GetValueTypeName (void) const { + virtual std::string GetValueTypeName (void) const + { return "ns3::ObjectPtrContainerValue"; } - virtual bool HasUnderlyingTypeInformation (void) const { + virtual bool HasUnderlyingTypeInformation (void) const + { return true; } - virtual std::string GetUnderlyingTypeInformation (void) const { + virtual std::string GetUnderlyingTypeInformation (void) const + { return "ns3::Ptr< " + T::GetTypeId ().GetName () + " >"; } - virtual Ptr Create (void) const { + virtual Ptr Create (void) const + { return ns3::Create (); } - virtual bool Copy (const AttributeValue &source, AttributeValue &destination) const { + virtual bool Copy (const AttributeValue &source, AttributeValue &destination) const + { const ObjectPtrContainerValue *src = dynamic_cast (&source); ObjectPtrContainerValue *dst = dynamic_cast (&destination); if (src == 0 || dst == 0) @@ -208,7 +215,7 @@ public: } // namespace internal - + /** * \ingroup attribute_ObjectPtrContainer * AttributeAccessor implementation for ObjectPtrContainerValue. @@ -220,6 +227,7 @@ public: virtual bool Get (const ObjectBase * object, AttributeValue &value) const; virtual bool HasGetter (void) const; virtual bool HasSetter (void) const; + private: /** * Get the number of instances in the container. @@ -228,7 +236,7 @@ private: * \param [out] n The number of instances in the container. * \returns true if the value could be obtained successfully. */ - virtual bool DoGetN(const ObjectBase *object, std::size_t *n) const = 0; + virtual bool DoGetN (const ObjectBase *object, std::size_t *n) const = 0; /** * Get an instance from the container, identified by index. * @@ -237,17 +245,18 @@ private: * \param [out] index The index retrieved. * \returns The index requested. */ - virtual Ptr DoGet(const ObjectBase *object, std::size_t i, std::size_t *index) const = 0; + virtual Ptr DoGet (const ObjectBase *object, std::size_t i, std::size_t *index) const = 0; }; template Ptr MakeObjectPtrContainerAccessor (Ptr (T::*get)(INDEX) const, - INDEX (T::*getN)(void) const) + INDEX (T::*getN)(void) const) { struct MemberGetters : public ObjectPtrContainerAccessor { - virtual bool DoGetN(const ObjectBase *object, std::size_t *n) const { + virtual bool DoGetN (const ObjectBase *object, std::size_t *n) const + { const T *obj = dynamic_cast (object); if (obj == 0) { @@ -256,7 +265,8 @@ MakeObjectPtrContainerAccessor (Ptr (T::*get)(INDEX) const, *n = (obj->*m_getN)(); return true; } - virtual Ptr DoGet(const ObjectBase *object, std::size_t i, std::size_t *index) const { + virtual Ptr DoGet (const ObjectBase *object, std::size_t i, std::size_t *index) const + { const T *obj = static_cast (object); *index = i; return (obj->*m_get)(i); @@ -272,7 +282,7 @@ MakeObjectPtrContainerAccessor (Ptr (T::*get)(INDEX) const, template Ptr MakeObjectPtrContainerAccessor (INDEX (T::*getN)(void) const, - Ptr (T::*get)(INDEX) const) + Ptr (T::*get)(INDEX) const) { return MakeObjectPtrContainerAccessor (get, getN); } diff --git a/src/core/model/object-vector.h b/src/core/model/object-vector.h index f3441ec14..fcd6f234c 100644 --- a/src/core/model/object-vector.h +++ b/src/core/model/object-vector.h @@ -82,7 +82,8 @@ MakeObjectVectorAccessor (U T::*memberVector) { struct MemberStdContainer : public ObjectPtrContainerAccessor { - virtual bool DoGetN(const ObjectBase *object, std::size_t *n) const { + virtual bool DoGetN (const ObjectBase *object, std::size_t *n) const + { const T *obj = dynamic_cast (object); if (obj == 0) { @@ -91,7 +92,8 @@ MakeObjectVectorAccessor (U T::*memberVector) *n = (obj->*m_memberVector).size (); return true; } - virtual Ptr DoGet(const ObjectBase *object, std::size_t i, std::size_t *index) const { + virtual Ptr DoGet (const ObjectBase *object, std::size_t i, std::size_t *index) const + { const T *obj = static_cast (object); typename U::const_iterator begin = (obj->*m_memberVector).begin (); typename U::const_iterator end = (obj->*m_memberVector).end (); @@ -124,17 +126,17 @@ Ptr MakeObjectVectorChecker (void) template Ptr MakeObjectVectorAccessor (Ptr (T::*get)(INDEX) const, - INDEX (T::*getN)(void) const) + INDEX (T::*getN)(void) const) { - return MakeObjectPtrContainerAccessor(get, getN); + return MakeObjectPtrContainerAccessor (get, getN); } template Ptr MakeObjectVectorAccessor (INDEX (T::*getN)(void) const, - Ptr (T::*get)(INDEX) const) + Ptr (T::*get)(INDEX) const) { - return MakeObjectPtrContainerAccessor(get, getN); + return MakeObjectPtrContainerAccessor (get, getN); } diff --git a/src/core/model/object.cc b/src/core/model/object.cc index 024e512d4..a99476066 100644 --- a/src/core/model/object.cc +++ b/src/core/model/object.cc @@ -104,7 +104,7 @@ Object::Object () m_aggregates->n = 1; m_aggregates->buffer[0] = this; } -Object::~Object () +Object::~Object () { // remove this object from the aggregate list NS_LOG_FUNCTION (this); @@ -114,9 +114,9 @@ Object::~Object () Object *current = m_aggregates->buffer[i]; if (current == this) { - std::memmove (&m_aggregates->buffer[i], - &m_aggregates->buffer[i+1], - sizeof (Object *)*(m_aggregates->n - (i+1))); + std::memmove (&m_aggregates->buffer[i], + &m_aggregates->buffer[i + 1], + sizeof (Object *) * (m_aggregates->n - (i + 1))); m_aggregates->n--; } } @@ -186,8 +186,8 @@ Object::Initialize (void) * Note: the code here is a bit tricky because we need to protect ourselves from * modifications in the aggregate array while DoInitialize is called. The user's * implementation of the DoInitialize method could call GetObject (which could - * reorder the array) and it could call AggregateObject which would add an - * object at the end of the array. To be safe, we restart iteration over the + * reorder the array) and it could call AggregateObject which would add an + * object at the end of the array. To be safe, we restart iteration over the * array whenever we call some user code, just in case. */ NS_LOG_FUNCTION (this); @@ -210,13 +210,13 @@ Object::IsInitialized (void) const NS_LOG_FUNCTION (this); return m_initialized; } -void +void Object::Dispose (void) { /** * Note: the code here is a bit tricky because we need to protect ourselves from * modifications in the aggregate array while DoDispose is called. The user's - * DoDispose implementation could call GetObject (which could reorder the array) + * DoDispose implementation could call GetObject (which could reorder the array) * and it could call AggregateObject which would add an object at the end of the array. * So, to be safe, we restart the iteration over the array whenever we call some * user code. @@ -239,16 +239,16 @@ void Object::UpdateSortedArray (struct Aggregates *aggregates, uint32_t j) const { NS_LOG_FUNCTION (this << aggregates << j); - while (j > 0 && - aggregates->buffer[j]->m_getObjectCount > aggregates->buffer[j-1]->m_getObjectCount) + while (j > 0 + && aggregates->buffer[j]->m_getObjectCount > aggregates->buffer[j - 1]->m_getObjectCount) { - Object *tmp = aggregates->buffer[j-1]; - aggregates->buffer[j-1] = aggregates->buffer[j]; + Object *tmp = aggregates->buffer[j - 1]; + aggregates->buffer[j - 1] = aggregates->buffer[j]; aggregates->buffer[j] = tmp; j--; } } -void +void Object::AggregateObject (Ptr o) { NS_LOG_FUNCTION (this << o); @@ -260,19 +260,19 @@ Object::AggregateObject (Ptr o) Object *other = PeekPointer (o); // first create the new aggregate buffer. uint32_t total = m_aggregates->n + other->m_aggregates->n; - struct Aggregates *aggregates = - (struct Aggregates *)std::malloc (sizeof(struct Aggregates)+(total-1)*sizeof(Object*)); + struct Aggregates *aggregates = + (struct Aggregates *)std::malloc (sizeof(struct Aggregates) + (total - 1) * sizeof(Object*)); aggregates->n = total; // copy our buffer to the new buffer - std::memcpy (&aggregates->buffer[0], - &m_aggregates->buffer[0], - m_aggregates->n*sizeof(Object*)); + std::memcpy (&aggregates->buffer[0], + &m_aggregates->buffer[0], + m_aggregates->n * sizeof(Object*)); // append the other buffer into the new buffer too for (uint32_t i = 0; i < other->m_aggregates->n; i++) { - aggregates->buffer[m_aggregates->n+i] = other->m_aggregates->buffer[i]; + aggregates->buffer[m_aggregates->n + i] = other->m_aggregates->buffer[i]; const TypeId typeId = other->m_aggregates->buffer[i]->GetInstanceTypeId (); if (DoGetObject (typeId)) { @@ -299,7 +299,7 @@ Object::AggregateObject (Ptr o) // Finally, call NotifyNewAggregate on all the objects aggregates together. // We purposely use the old aggregate buffers to iterate over the objects - // because this allows us to assume that they will not change from under + // because this allows us to assume that they will not change from under // our feet, even if our users call AggregateObject from within their // NotifyNewAggregate method. for (uint32_t i = 0; i < a->n; i++) @@ -327,14 +327,14 @@ Object::NotifyNewAggregate () NS_LOG_FUNCTION (this); } -Object::AggregateIterator +Object::AggregateIterator Object::GetAggregateIterator (void) const { NS_LOG_FUNCTION (this); return AggregateIterator (this); } -void +void Object::SetTypeId (TypeId tid) { NS_LOG_FUNCTION (this << tid); @@ -356,7 +356,7 @@ Object::DoInitialize (void) NS_ASSERT (!m_initialized); } -bool +bool Object::Check (void) const { NS_LOG_FUNCTION (this); @@ -370,7 +370,7 @@ Object::Check (void) const * manipulating an object with a refcount of zero. So, instead we * check the aggregate reference count. */ -bool +bool Object::CheckLoose (void) const { NS_LOG_FUNCTION (this); @@ -401,7 +401,7 @@ Object::DoDelete (void) } } - // Now, we know that we are alone to use this aggregate so, + // Now, we know that we are alone to use this aggregate so, // we can dispose and delete everything safely. uint32_t n = m_aggregates->n; @@ -421,7 +421,7 @@ Object::DoDelete (void) { // There is a trick here: each time we call delete below, // the deleted object is removed from the aggregate buffer - // in the destructor so, the index of the next element to + // in the destructor so, the index of the next element to // lookup is always zero Object *current = aggregates->buffer[0]; delete current; diff --git a/src/core/model/object.h b/src/core/model/object.h index 6f6a4cbe3..a4cb1eb20 100644 --- a/src/core/model/object.h +++ b/src/core/model/object.h @@ -49,7 +49,7 @@ class TraceSourceAccessor; * \defgroup object Object * \brief Base classes which provide memory management and object aggregation. */ - + /** * \ingroup object * \ingroup ptr @@ -97,13 +97,13 @@ public: * \brief Iterate over the Objects aggregated to an ns3::Object. * * This iterator does not allow you to iterate over the parent - * Object used to call Object::GetAggregateIterator. + * Object used to call Object::GetAggregateIterator. * * \note This is a java-style iterator. */ class AggregateIterator { -public: + public: /** Default constructor, which has no Object. */ AggregateIterator (); @@ -121,7 +121,8 @@ public: * \returns The next aggregated Object. */ Ptr Next (void); -private: + + private: friend class Object; /** * Construct from an Object. @@ -153,7 +154,7 @@ private: inline Ptr GetObject (void) const; /** * Get a pointer to the requested aggregated Object by TypeId. - * + * * \param [in] tid The TypeId of the requested Object. * \returns A pointer to the requested Object, or zero * if it could not be found. @@ -164,7 +165,7 @@ private: * Dispose of this Object. * * Run the DoDispose() methods of this Object and all the - * Objects aggregated to it. + * Objects aggregated to it. * After calling this method, this Object is expected to be * totally unusable except for the Ref() and Unref() methods. * @@ -182,7 +183,7 @@ private: * * This method aggregates the two Objects together: after this * method returns, it becomes possible to call GetObject() - * on one to get the other, and vice-versa. + * on one to get the other, and vice-versa. * * This method calls the virtual method NotifyNewAggregates() to * notify all aggregated Objects that they have been aggregated @@ -219,7 +220,7 @@ private: /** * Check if the object has been initialized. * - * \brief returns true if the object has been initialized. + * \brief returns true if the object has been initialized. */ bool IsInitialized (void) const; @@ -253,7 +254,7 @@ protected: /** * Destructor implementation. * - * This method is called by Dispose() or by the Object's + * This method is called by Dispose() or by the Object's * destructor, whichever comes first. * * Subclasses are expected to implement their real destruction @@ -287,7 +288,7 @@ protected: * valid state. */ Object (const Object &o); - + private: /** @@ -305,7 +306,7 @@ private: template friend Ptr CopyObject (Ptr object); /**@}*/ - + /** * Set the TypeId and construct all Attributes of an Object. * @@ -323,7 +324,7 @@ private: /** * The list of Objects aggregated to this one. * - * This data structure uses a classic C-style trick to + * This data structure uses a classic C-style trick to * hold an array of variable size without performing * two memory allocations: the declaration of the structure * declares a one-element array but when we allocate @@ -332,7 +333,8 @@ private: * variable sized buffer whose size is indicated by the element * \c n */ - struct Aggregates { + struct Aggregates + { /** The number of entries in \c buffer. */ uint32_t n; /** The array of Objects. */ @@ -366,7 +368,7 @@ private: bool CheckLoose (void) const; /** * Set the TypeId of this Object. - + * \param [in] tid The TypeId value to set. * * Invoked from ns3::CreateObject only. @@ -396,7 +398,7 @@ private: /** * Attempt to delete this Object. * - * This method iterates over all aggregated Objects to check if they all + * This method iterates over all aggregated Objects to check if they all * have a zero refcount. If yes, the Object and all * its aggregates are deleted. If not, nothing is done. */ @@ -419,7 +421,7 @@ private: /** * A pointer to an array of 'aggregates'. * - * A pointer to each Object aggregated to this Object is stored in this + * A pointer to each Object aggregated to this Object is stored in this * array. The array is shared by all aggregated Objects * so the size of the array is indirectly a reference count. */ @@ -448,14 +450,14 @@ namespace ns3 { * The Object implementation which depends on templates *************************************************************************/ -void +void ObjectDeleter::Delete (Object *object) { object->DoDelete (); } template -Ptr +Ptr Object::GetObject () const { // This is an optimization: if the cast works (which is likely), @@ -475,7 +477,7 @@ Object::GetObject () const } template -Ptr +Ptr Object::GetObject (TypeId tid) const { Ptr found = DoGetObject (tid); @@ -514,7 +516,7 @@ Ptr CompleteConstruct (T *object) return Ptr (object, false); } -/** +/** * \ingroup object * @{ */ diff --git a/src/core/model/pointer.cc b/src/core/model/pointer.cc index 37570ed45..69e3550fb 100644 --- a/src/core/model/pointer.cc +++ b/src/core/model/pointer.cc @@ -73,7 +73,7 @@ PointerValue::SerializeToString (Ptr checker) const return oss.str (); } -bool +bool PointerValue::DeserializeFromString (std::string value, Ptr checker) { // We assume that the string you want to deserialize contains @@ -82,9 +82,9 @@ PointerValue::DeserializeFromString (std::string value, Ptr> factory; - if (iss.fail()) + if (iss.fail ()) { return false; } diff --git a/src/core/model/pointer.h b/src/core/model/pointer.h index 53893e036..13ff15aaa 100644 --- a/src/core/model/pointer.h +++ b/src/core/model/pointer.h @@ -37,7 +37,7 @@ class PointerValue : public AttributeValue { public: PointerValue (); - + /** * Construct this PointerValue by referencing an explicit Object. * @@ -70,7 +70,7 @@ public: /** * Cast to an Object of type \c T. * \tparam T \explicit The type to cast to. - */ + */ template operator Ptr () const; @@ -94,7 +94,7 @@ private: }; -class PointerChecker : public AttributeChecker +class PointerChecker : public AttributeChecker { public: @@ -104,7 +104,7 @@ public: */ virtual TypeId GetPointeeTypeId (void) const = 0; }; - + /** * Create a PointerChecker for a type. * \tparam T \explicit The underlying type. @@ -129,7 +129,8 @@ namespace internal { template class PointerChecker : public ns3::PointerChecker { - virtual bool Check (const AttributeValue &val) const { + virtual bool Check (const AttributeValue &val) const + { const PointerValue *value = dynamic_cast (&val); if (value == 0) { @@ -146,20 +147,25 @@ class PointerChecker : public ns3::PointerChecker } return true; } - virtual std::string GetValueTypeName (void) const { + virtual std::string GetValueTypeName (void) const + { return "ns3::PointerValue"; } - virtual bool HasUnderlyingTypeInformation (void) const { + virtual bool HasUnderlyingTypeInformation (void) const + { return true; } - virtual std::string GetUnderlyingTypeInformation (void) const { + virtual std::string GetUnderlyingTypeInformation (void) const + { TypeId tid = T::GetTypeId (); return "ns3::Ptr< " + tid.GetName () + " >"; } - virtual Ptr Create (void) const { + virtual Ptr Create (void) const + { return ns3::Create (); } - virtual bool Copy (const AttributeValue &source, AttributeValue &destination) const { + virtual bool Copy (const AttributeValue &source, AttributeValue &destination) const + { const PointerValue *src = dynamic_cast (&source); PointerValue *dst = dynamic_cast (&destination); if (src == 0 || dst == 0) @@ -169,7 +175,8 @@ class PointerChecker : public ns3::PointerChecker *dst = *src; return true; } - virtual TypeId GetPointeeTypeId (void) const { + virtual TypeId GetPointeeTypeId (void) const + { return T::GetTypeId (); } }; @@ -183,14 +190,14 @@ PointerValue::PointerValue (const Ptr &object) } template -void +void PointerValue::Set (const Ptr &object) { m_value = object; } template -Ptr +Ptr PointerValue::Get (void) const { T *v = dynamic_cast (PeekPointer (m_value)); @@ -204,7 +211,7 @@ PointerValue::operator Ptr () const } template -bool +bool PointerValue::GetAccessor (Ptr &v) const { Ptr ptr = dynamic_cast (PeekPointer (m_value)); diff --git a/src/core/model/ptr.h b/src/core/model/ptr.h index eee94d40a..158cac175 100644 --- a/src/core/model/ptr.h +++ b/src/core/model/ptr.h @@ -70,7 +70,7 @@ namespace ns3 { * \tparam T \explicit The underlying type. */ template -class Ptr +class Ptr { private: @@ -78,15 +78,16 @@ private: T *m_ptr; /** Helper to test for null pointer. */ - class Tester { + class Tester + { private: /** Disable delete (by virtue that this is unimplemented). */ void operator delete (void *); }; - + /** Interoperate with const instances. */ friend class Ptr; - + /** * Get a permanent pointer to the underlying object. * @@ -98,7 +99,7 @@ private: * \return The pointer managed by this smart pointer. */ template - friend U *GetPointer (const Ptr &p); + friend U * GetPointer (const Ptr &p); /** * Get a temporary pointer to the underlying object. * @@ -110,11 +111,11 @@ private: * \return The pointer managed by this smart pointer. */ template - friend U *PeekPointer (const Ptr &p); + friend U * PeekPointer (const Ptr &p); /** Mark this as a a reference by incrementing the reference count. */ inline void Acquire (void) const; - + public: /** Create an empty smart pointer */ Ptr (); @@ -151,7 +152,7 @@ public: * \param [in] o The Ptr to copy. */ template - Ptr (Ptr const &o); + Ptr (Ptr const &o); /** Destructor. */ ~Ptr (); /** @@ -435,7 +436,7 @@ bool operator > (const Ptr &lhs, const Ptr &rhs); template bool operator >= (const Ptr &lhs, const Ptr &rhs); /** @} */ - + /** * Return a copy of \c p with its stored pointer const casted from * \c T2 to \c T1. @@ -448,7 +449,7 @@ bool operator >= (const Ptr &lhs, const Ptr &rhs); template Ptr const_pointer_cast (Ptr const&p); -// Duplicate of struct CallbackTraits as defined in callback.h +// Duplicate of struct CallbackTraits as defined in callback.h template struct CallbackTraits; @@ -496,7 +497,8 @@ struct EventMemberImplObjTraits > * \param [in] p Object pointer * \return A reference to the object pointed to by p */ - static T &GetReference (Ptr p) { + static T & GetReference (Ptr p) + { return *PeekPointer (p); } }; @@ -581,42 +583,42 @@ std::ostream &operator << (std::ostream &os, const Ptr &p) } template -bool +bool operator == (Ptr const &lhs, T2 const *rhs) { return PeekPointer (lhs) == rhs; } template -bool +bool operator == (T1 const *lhs, Ptr &rhs) { return lhs == PeekPointer (rhs); } template -bool +bool operator != (Ptr const &lhs, T2 const *rhs) { return PeekPointer (lhs) != rhs; } template -bool +bool operator != (T1 const *lhs, Ptr &rhs) { return lhs != PeekPointer (rhs); } template -bool +bool operator == (Ptr const &lhs, Ptr const &rhs) { return PeekPointer (lhs) == PeekPointer (rhs); } template -bool +bool operator != (Ptr const &lhs, Ptr const &rhs) { return PeekPointer (lhs) != PeekPointer (rhs); @@ -704,7 +706,7 @@ Ptr Copy (Ptr object) ***************************************************/ template -void +void Ptr::Acquire (void) const { if (m_ptr != 0) @@ -716,8 +718,7 @@ Ptr::Acquire (void) const template Ptr::Ptr () : m_ptr (0) -{ -} +{} template Ptr::Ptr (T *ptr) @@ -737,7 +738,7 @@ Ptr::Ptr (T *ptr, bool ref) } template -Ptr::Ptr (Ptr const&o) +Ptr::Ptr (Ptr const&o) : m_ptr (PeekPointer (o)) { Acquire (); @@ -751,9 +752,9 @@ Ptr::Ptr (Ptr const &o) } template -Ptr::~Ptr () +Ptr::~Ptr () { - if (m_ptr != 0) + if (m_ptr != 0) { m_ptr->Unref (); } @@ -761,13 +762,13 @@ Ptr::~Ptr () template Ptr & -Ptr::operator = (Ptr const& o) +Ptr::operator = (Ptr const& o) { if (&o == this) { return *this; } - if (m_ptr != 0) + if (m_ptr != 0) { m_ptr->Unref (); } @@ -778,7 +779,7 @@ Ptr::operator = (Ptr const& o) template T * -Ptr::operator -> () +Ptr::operator -> () { NS_ASSERT_MSG (m_ptr, "Attempted to dereference zero pointer"); return m_ptr; @@ -809,8 +810,8 @@ Ptr::operator * () } template -bool -Ptr::operator! () +bool +Ptr::operator! () { return m_ptr == 0; } @@ -818,7 +819,7 @@ Ptr::operator! () template Ptr::operator Tester * () const { - if (m_ptr == 0) + if (m_ptr == 0) { return 0; } diff --git a/src/core/model/random-variable-stream.cc b/src/core/model/random-variable-stream.cc index b5a54bcc6..dbe86f023 100644 --- a/src/core/model/random-variable-stream.cc +++ b/src/core/model/random-variable-stream.cc @@ -49,48 +49,48 @@ NS_LOG_COMPONENT_DEFINE ("RandomVariableStream"); NS_OBJECT_ENSURE_REGISTERED (RandomVariableStream); -TypeId +TypeId RandomVariableStream::GetTypeId (void) { static TypeId tid = TypeId ("ns3::RandomVariableStream") .SetParent () .SetGroupName ("Core") - .AddAttribute("Stream", - "The stream number for this RNG stream. -1 means \"allocate a stream automatically\". " - "Note that if -1 is set, Get will return -1 so that it is not possible to know which " - "value was automatically allocated.", - IntegerValue(-1), - MakeIntegerAccessor(&RandomVariableStream::SetStream, - &RandomVariableStream::GetStream), - MakeIntegerChecker()) - .AddAttribute("Antithetic", "Set this RNG stream to generate antithetic values", - BooleanValue (false), - MakeBooleanAccessor(&RandomVariableStream::SetAntithetic, - &RandomVariableStream::IsAntithetic), - MakeBooleanChecker()) - ; + .AddAttribute ("Stream", + "The stream number for this RNG stream. -1 means \"allocate a stream automatically\". " + "Note that if -1 is set, Get will return -1 so that it is not possible to know which " + "value was automatically allocated.", + IntegerValue (-1), + MakeIntegerAccessor (&RandomVariableStream::SetStream, + &RandomVariableStream::GetStream), + MakeIntegerChecker()) + .AddAttribute ("Antithetic", "Set this RNG stream to generate antithetic values", + BooleanValue (false), + MakeBooleanAccessor (&RandomVariableStream::SetAntithetic, + &RandomVariableStream::IsAntithetic), + MakeBooleanChecker ()) + ; return tid; } -RandomVariableStream::RandomVariableStream() +RandomVariableStream::RandomVariableStream () : m_rng (0) { NS_LOG_FUNCTION (this); } -RandomVariableStream::~RandomVariableStream() +RandomVariableStream::~RandomVariableStream () { NS_LOG_FUNCTION (this); delete m_rng; } void -RandomVariableStream::SetAntithetic(bool isAntithetic) +RandomVariableStream::SetAntithetic (bool isAntithetic) { NS_LOG_FUNCTION (this << isAntithetic); m_isAntithetic = isAntithetic; } bool -RandomVariableStream::IsAntithetic(void) const +RandomVariableStream::IsAntithetic (void) const { NS_LOG_FUNCTION (this); return m_isAntithetic; @@ -107,7 +107,7 @@ RandomVariableStream::SetStream (int64_t stream) // The first 2^63 streams are reserved for automatic stream // number assignment. uint64_t nextStream = RngSeedManager::GetNextStreamIndex (); - NS_ASSERT(nextStream <= ((1ULL)<<63)); + NS_ASSERT (nextStream <= ((1ULL) << 63)); m_rng = new RngStream (RngSeedManager::GetSeed (), nextStream, RngSeedManager::GetRun ()); @@ -116,7 +116,7 @@ RandomVariableStream::SetStream (int64_t stream) { // The last 2^63 streams are reserved for deterministic stream // number assignment. - uint64_t base = ((1ULL)<<63); + uint64_t base = ((1ULL) << 63); uint64_t target = base + stream; m_rng = new RngStream (RngSeedManager::GetSeed (), target, @@ -125,37 +125,37 @@ RandomVariableStream::SetStream (int64_t stream) m_stream = stream; } int64_t -RandomVariableStream::GetStream(void) const +RandomVariableStream::GetStream (void) const { NS_LOG_FUNCTION (this); return m_stream; } RngStream * -RandomVariableStream::Peek(void) const +RandomVariableStream::Peek (void) const { NS_LOG_FUNCTION (this); return m_rng; } -NS_OBJECT_ENSURE_REGISTERED(UniformRandomVariable); +NS_OBJECT_ENSURE_REGISTERED (UniformRandomVariable); -TypeId +TypeId UniformRandomVariable::GetTypeId (void) { static TypeId tid = TypeId ("ns3::UniformRandomVariable") .SetParent() .SetGroupName ("Core") .AddConstructor () - .AddAttribute("Min", "The lower bound on the values returned by this RNG stream.", - DoubleValue(0), - MakeDoubleAccessor(&UniformRandomVariable::m_min), - MakeDoubleChecker()) - .AddAttribute("Max", "The upper bound on the values returned by this RNG stream.", - DoubleValue(1.0), - MakeDoubleAccessor(&UniformRandomVariable::m_max), - MakeDoubleChecker()) - ; + .AddAttribute ("Min", "The lower bound on the values returned by this RNG stream.", + DoubleValue (0), + MakeDoubleAccessor (&UniformRandomVariable::m_min), + MakeDoubleChecker()) + .AddAttribute ("Max", "The upper bound on the values returned by this RNG stream.", + DoubleValue (1.0), + MakeDoubleAccessor (&UniformRandomVariable::m_max), + MakeDoubleChecker()) + ; return tid; } UniformRandomVariable::UniformRandomVariable () @@ -164,20 +164,20 @@ UniformRandomVariable::UniformRandomVariable () NS_LOG_FUNCTION (this); } -double +double UniformRandomVariable::GetMin (void) const { NS_LOG_FUNCTION (this); return m_min; } -double +double UniformRandomVariable::GetMax (void) const { NS_LOG_FUNCTION (this); return m_max; } -double +double UniformRandomVariable::GetValue (double min, double max) { NS_LOG_FUNCTION (this << min << max); @@ -188,7 +188,7 @@ UniformRandomVariable::GetValue (double min, double max) } return v; } -uint32_t +uint32_t UniformRandomVariable::GetInteger (uint32_t min, uint32_t max) { NS_LOG_FUNCTION (this << min << max); @@ -196,33 +196,33 @@ UniformRandomVariable::GetInteger (uint32_t min, uint32_t max) return static_cast ( GetValue ((double) (min), (double) (max) + 1.0) ); } -double +double UniformRandomVariable::GetValue (void) { NS_LOG_FUNCTION (this); return GetValue (m_min, m_max); } -uint32_t +uint32_t UniformRandomVariable::GetInteger (void) { NS_LOG_FUNCTION (this); return (uint32_t)GetValue (m_min, m_max + 1); } -NS_OBJECT_ENSURE_REGISTERED(ConstantRandomVariable); +NS_OBJECT_ENSURE_REGISTERED (ConstantRandomVariable); -TypeId +TypeId ConstantRandomVariable::GetTypeId (void) { static TypeId tid = TypeId ("ns3::ConstantRandomVariable") .SetParent() .SetGroupName ("Core") .AddConstructor () - .AddAttribute("Constant", "The constant value returned by this RNG stream.", - DoubleValue(0), - MakeDoubleAccessor(&ConstantRandomVariable::m_constant), - MakeDoubleChecker()) - ; + .AddAttribute ("Constant", "The constant value returned by this RNG stream.", + DoubleValue (0), + MakeDoubleAccessor (&ConstantRandomVariable::m_constant), + MakeDoubleChecker()) + ; return tid; } ConstantRandomVariable::ConstantRandomVariable () @@ -231,69 +231,68 @@ ConstantRandomVariable::ConstantRandomVariable () NS_LOG_FUNCTION (this); } -double +double ConstantRandomVariable::GetConstant (void) const { NS_LOG_FUNCTION (this); return m_constant; } -double +double ConstantRandomVariable::GetValue (double constant) { NS_LOG_FUNCTION (this << constant); return constant; } -uint32_t +uint32_t ConstantRandomVariable::GetInteger (uint32_t constant) { NS_LOG_FUNCTION (this << constant); return constant; } -double +double ConstantRandomVariable::GetValue (void) { NS_LOG_FUNCTION (this); return GetValue (m_constant); } -uint32_t +uint32_t ConstantRandomVariable::GetInteger (void) { NS_LOG_FUNCTION (this); return (uint32_t)GetValue (m_constant); } -NS_OBJECT_ENSURE_REGISTERED(SequentialRandomVariable); +NS_OBJECT_ENSURE_REGISTERED (SequentialRandomVariable); -TypeId +TypeId SequentialRandomVariable::GetTypeId (void) { static TypeId tid = TypeId ("ns3::SequentialRandomVariable") .SetParent() .SetGroupName ("Core") .AddConstructor () - .AddAttribute("Min", "The first value of the sequence.", - DoubleValue(0), - MakeDoubleAccessor(&SequentialRandomVariable::m_min), - MakeDoubleChecker()) - .AddAttribute("Max", "One more than the last value of the sequence.", - DoubleValue(0), - MakeDoubleAccessor(&SequentialRandomVariable::m_max), - MakeDoubleChecker()) - .AddAttribute("Increment", "The sequence random variable increment.", - StringValue("ns3::ConstantRandomVariable[Constant=1]"), - MakePointerAccessor (&SequentialRandomVariable::m_increment), - MakePointerChecker ()) - .AddAttribute("Consecutive", "The number of times each member of the sequence is repeated.", - IntegerValue(1), - MakeIntegerAccessor(&SequentialRandomVariable::m_consecutive), - MakeIntegerChecker()); - ; + .AddAttribute ("Min", "The first value of the sequence.", + DoubleValue (0), + MakeDoubleAccessor (&SequentialRandomVariable::m_min), + MakeDoubleChecker()) + .AddAttribute ("Max", "One more than the last value of the sequence.", + DoubleValue (0), + MakeDoubleAccessor (&SequentialRandomVariable::m_max), + MakeDoubleChecker()) + .AddAttribute ("Increment", "The sequence random variable increment.", + StringValue ("ns3::ConstantRandomVariable[Constant=1]"), + MakePointerAccessor (&SequentialRandomVariable::m_increment), + MakePointerChecker ()) + .AddAttribute ("Consecutive", "The number of times each member of the sequence is repeated.", + IntegerValue (1), + MakeIntegerAccessor (&SequentialRandomVariable::m_consecutive), + MakeIntegerChecker()); return tid; } SequentialRandomVariable::SequentialRandomVariable () - : + : m_current (0), m_currentConsecutive (0), m_isCurrentSet (false) @@ -303,35 +302,35 @@ SequentialRandomVariable::SequentialRandomVariable () NS_LOG_FUNCTION (this); } -double +double SequentialRandomVariable::GetMin (void) const { NS_LOG_FUNCTION (this); return m_min; } -double +double SequentialRandomVariable::GetMax (void) const { NS_LOG_FUNCTION (this); return m_max; } -Ptr +Ptr SequentialRandomVariable::GetIncrement (void) const { NS_LOG_FUNCTION (this); return m_increment; } -uint32_t +uint32_t SequentialRandomVariable::GetConsecutive (void) const { NS_LOG_FUNCTION (this); return m_consecutive; } -double +double SequentialRandomVariable::GetValue (void) { // Set the current sequence value if it hasn't been set. @@ -343,7 +342,7 @@ SequentialRandomVariable::GetValue (void) m_isCurrentSet = true; } - // Return a sequential series of values + // Return a sequential series of values double r = m_current; if (++m_currentConsecutive == m_consecutive) { // Time to advance to next @@ -357,31 +356,31 @@ SequentialRandomVariable::GetValue (void) return r; } -uint32_t +uint32_t SequentialRandomVariable::GetInteger (void) { NS_LOG_FUNCTION (this); return (uint32_t)GetValue (); } -NS_OBJECT_ENSURE_REGISTERED(ExponentialRandomVariable); +NS_OBJECT_ENSURE_REGISTERED (ExponentialRandomVariable); -TypeId +TypeId ExponentialRandomVariable::GetTypeId (void) { static TypeId tid = TypeId ("ns3::ExponentialRandomVariable") .SetParent() .SetGroupName ("Core") .AddConstructor () - .AddAttribute("Mean", "The mean of the values returned by this RNG stream.", - DoubleValue(1.0), - MakeDoubleAccessor(&ExponentialRandomVariable::m_mean), - MakeDoubleChecker()) - .AddAttribute("Bound", "The upper bound on the values returned by this RNG stream.", - DoubleValue(0.0), - MakeDoubleAccessor(&ExponentialRandomVariable::m_bound), - MakeDoubleChecker()) - ; + .AddAttribute ("Mean", "The mean of the values returned by this RNG stream.", + DoubleValue (1.0), + MakeDoubleAccessor (&ExponentialRandomVariable::m_mean), + MakeDoubleChecker()) + .AddAttribute ("Bound", "The upper bound on the values returned by this RNG stream.", + DoubleValue (0.0), + MakeDoubleAccessor (&ExponentialRandomVariable::m_bound), + MakeDoubleChecker()) + ; return tid; } ExponentialRandomVariable::ExponentialRandomVariable () @@ -390,20 +389,20 @@ ExponentialRandomVariable::ExponentialRandomVariable () NS_LOG_FUNCTION (this); } -double +double ExponentialRandomVariable::GetMean (void) const { NS_LOG_FUNCTION (this); return m_mean; } -double +double ExponentialRandomVariable::GetBound (void) const { NS_LOG_FUNCTION (this); return m_bound; } -double +double ExponentialRandomVariable::GetValue (double mean, double bound) { NS_LOG_FUNCTION (this << mean << bound); @@ -426,54 +425,54 @@ ExponentialRandomVariable::GetValue (double mean, double bound) } } } -uint32_t +uint32_t ExponentialRandomVariable::GetInteger (uint32_t mean, uint32_t bound) { NS_LOG_FUNCTION (this << mean << bound); return static_cast ( GetValue (mean, bound) ); } -double +double ExponentialRandomVariable::GetValue (void) { NS_LOG_FUNCTION (this); return GetValue (m_mean, m_bound); } -uint32_t +uint32_t ExponentialRandomVariable::GetInteger (void) { NS_LOG_FUNCTION (this); return (uint32_t)GetValue (m_mean, m_bound); } -NS_OBJECT_ENSURE_REGISTERED(ParetoRandomVariable); +NS_OBJECT_ENSURE_REGISTERED (ParetoRandomVariable); -TypeId +TypeId ParetoRandomVariable::GetTypeId (void) { static TypeId tid = TypeId ("ns3::ParetoRandomVariable") .SetParent() .SetGroupName ("Core") .AddConstructor () - .AddAttribute("Mean", "The mean parameter for the Pareto distribution returned by this RNG stream.", - DoubleValue(0.0), - MakeDoubleAccessor(&ParetoRandomVariable::m_mean), - MakeDoubleChecker(), - TypeId::DEPRECATED, - "Not anymore used. Use 'Scale' instead - changing this attribute has no effect.") - .AddAttribute("Scale", "The scale parameter for the Pareto distribution returned by this RNG stream.", - DoubleValue(1.0), - MakeDoubleAccessor(&ParetoRandomVariable::m_scale), - MakeDoubleChecker()) - .AddAttribute("Shape", "The shape parameter for the Pareto distribution returned by this RNG stream.", - DoubleValue(2.0), - MakeDoubleAccessor(&ParetoRandomVariable::m_shape), - MakeDoubleChecker()) - .AddAttribute("Bound", "The upper bound on the values returned by this RNG stream (if non-zero).", - DoubleValue(0.0), - MakeDoubleAccessor(&ParetoRandomVariable::m_bound), - MakeDoubleChecker()) - ; + .AddAttribute ("Mean", "The mean parameter for the Pareto distribution returned by this RNG stream.", + DoubleValue (0.0), + MakeDoubleAccessor (&ParetoRandomVariable::m_mean), + MakeDoubleChecker(), + TypeId::DEPRECATED, + "Not anymore used. Use 'Scale' instead - changing this attribute has no effect.") + .AddAttribute ("Scale", "The scale parameter for the Pareto distribution returned by this RNG stream.", + DoubleValue (1.0), + MakeDoubleAccessor (&ParetoRandomVariable::m_scale), + MakeDoubleChecker()) + .AddAttribute ("Shape", "The shape parameter for the Pareto distribution returned by this RNG stream.", + DoubleValue (2.0), + MakeDoubleAccessor (&ParetoRandomVariable::m_shape), + MakeDoubleChecker()) + .AddAttribute ("Bound", "The upper bound on the values returned by this RNG stream (if non-zero).", + DoubleValue (0.0), + MakeDoubleAccessor (&ParetoRandomVariable::m_bound), + MakeDoubleChecker()) + ; return tid; } ParetoRandomVariable::ParetoRandomVariable () @@ -484,22 +483,22 @@ ParetoRandomVariable::ParetoRandomVariable () NS_UNUSED (m_mean); } -double +double ParetoRandomVariable::GetMean (void) const { NS_LOG_FUNCTION (this); - double mean = std::numeric_limits::infinity(); + double mean = std::numeric_limits::infinity (); if (m_shape > 1) { - mean = m_shape * m_scale / (m_shape -1); + mean = m_shape * m_scale / (m_shape - 1); } return mean; } -double +double ParetoRandomVariable::GetScale (void) const { NS_LOG_FUNCTION (this); @@ -513,14 +512,14 @@ ParetoRandomVariable::GetShape (void) const return m_shape; } -double +double ParetoRandomVariable::GetBound (void) const { NS_LOG_FUNCTION (this); return m_bound; } -double +double ParetoRandomVariable::GetValue (double scale, double shape, double bound) { // Calculate the scale parameter. @@ -545,48 +544,48 @@ ParetoRandomVariable::GetValue (double scale, double shape, double bound) } } } -uint32_t +uint32_t ParetoRandomVariable::GetInteger (uint32_t scale, uint32_t shape, uint32_t bound) { NS_LOG_FUNCTION (this << scale << shape << bound); return static_cast ( GetValue (scale, shape, bound) ); } -double +double ParetoRandomVariable::GetValue (void) { NS_LOG_FUNCTION (this); return GetValue (m_scale, m_shape, m_bound); } -uint32_t +uint32_t ParetoRandomVariable::GetInteger (void) { NS_LOG_FUNCTION (this); return (uint32_t)GetValue (m_scale, m_shape, m_bound); } -NS_OBJECT_ENSURE_REGISTERED(WeibullRandomVariable); +NS_OBJECT_ENSURE_REGISTERED (WeibullRandomVariable); -TypeId +TypeId WeibullRandomVariable::GetTypeId (void) { static TypeId tid = TypeId ("ns3::WeibullRandomVariable") .SetParent() .SetGroupName ("Core") .AddConstructor () - .AddAttribute("Scale", "The scale parameter for the Weibull distribution returned by this RNG stream.", - DoubleValue(1.0), - MakeDoubleAccessor(&WeibullRandomVariable::m_scale), - MakeDoubleChecker()) - .AddAttribute("Shape", "The shape parameter for the Weibull distribution returned by this RNG stream.", - DoubleValue(1), - MakeDoubleAccessor(&WeibullRandomVariable::m_shape), - MakeDoubleChecker()) - .AddAttribute("Bound", "The upper bound on the values returned by this RNG stream.", - DoubleValue(0.0), - MakeDoubleAccessor(&WeibullRandomVariable::m_bound), - MakeDoubleChecker()) - ; + .AddAttribute ("Scale", "The scale parameter for the Weibull distribution returned by this RNG stream.", + DoubleValue (1.0), + MakeDoubleAccessor (&WeibullRandomVariable::m_scale), + MakeDoubleChecker()) + .AddAttribute ("Shape", "The shape parameter for the Weibull distribution returned by this RNG stream.", + DoubleValue (1), + MakeDoubleAccessor (&WeibullRandomVariable::m_shape), + MakeDoubleChecker()) + .AddAttribute ("Bound", "The upper bound on the values returned by this RNG stream.", + DoubleValue (0.0), + MakeDoubleAccessor (&WeibullRandomVariable::m_bound), + MakeDoubleChecker()) + ; return tid; } WeibullRandomVariable::WeibullRandomVariable () @@ -596,26 +595,26 @@ WeibullRandomVariable::WeibullRandomVariable () NS_LOG_FUNCTION (this); } -double +double WeibullRandomVariable::GetScale (void) const { NS_LOG_FUNCTION (this); return m_scale; } -double +double WeibullRandomVariable::GetShape (void) const { NS_LOG_FUNCTION (this); return m_shape; } -double +double WeibullRandomVariable::GetBound (void) const { NS_LOG_FUNCTION (this); return m_bound; } -double +double WeibullRandomVariable::GetValue (double scale, double shape, double bound) { NS_LOG_FUNCTION (this << scale << shape << bound); @@ -639,81 +638,81 @@ WeibullRandomVariable::GetValue (double scale, double shape, double bound) } } } -uint32_t +uint32_t WeibullRandomVariable::GetInteger (uint32_t scale, uint32_t shape, uint32_t bound) { NS_LOG_FUNCTION (this << scale << shape << bound); return static_cast ( GetValue (scale, shape, bound) ); } -double +double WeibullRandomVariable::GetValue (void) { NS_LOG_FUNCTION (this); return GetValue (m_scale, m_shape, m_bound); } -uint32_t +uint32_t WeibullRandomVariable::GetInteger (void) { NS_LOG_FUNCTION (this); return (uint32_t)GetValue (m_scale, m_shape, m_bound); } -NS_OBJECT_ENSURE_REGISTERED(NormalRandomVariable); +NS_OBJECT_ENSURE_REGISTERED (NormalRandomVariable); const double NormalRandomVariable::INFINITE_VALUE = 1e307; -TypeId +TypeId NormalRandomVariable::GetTypeId (void) { static TypeId tid = TypeId ("ns3::NormalRandomVariable") .SetParent() .SetGroupName ("Core") .AddConstructor () - .AddAttribute("Mean", "The mean value for the normal distribution returned by this RNG stream.", - DoubleValue(0.0), - MakeDoubleAccessor(&NormalRandomVariable::m_mean), - MakeDoubleChecker()) - .AddAttribute("Variance", "The variance value for the normal distribution returned by this RNG stream.", - DoubleValue(1.0), - MakeDoubleAccessor(&NormalRandomVariable::m_variance), - MakeDoubleChecker()) - .AddAttribute("Bound", "The bound on the values returned by this RNG stream.", - DoubleValue(INFINITE_VALUE), - MakeDoubleAccessor(&NormalRandomVariable::m_bound), - MakeDoubleChecker()) - ; + .AddAttribute ("Mean", "The mean value for the normal distribution returned by this RNG stream.", + DoubleValue (0.0), + MakeDoubleAccessor (&NormalRandomVariable::m_mean), + MakeDoubleChecker()) + .AddAttribute ("Variance", "The variance value for the normal distribution returned by this RNG stream.", + DoubleValue (1.0), + MakeDoubleAccessor (&NormalRandomVariable::m_variance), + MakeDoubleChecker()) + .AddAttribute ("Bound", "The bound on the values returned by this RNG stream.", + DoubleValue (INFINITE_VALUE), + MakeDoubleAccessor (&NormalRandomVariable::m_bound), + MakeDoubleChecker()) + ; return tid; } NormalRandomVariable::NormalRandomVariable () : - m_nextValid (false) + m_nextValid (false) { // m_mean, m_variance, and m_bound are initialized after constructor // by attributes NS_LOG_FUNCTION (this); } -double +double NormalRandomVariable::GetMean (void) const { NS_LOG_FUNCTION (this); return m_mean; } -double +double NormalRandomVariable::GetVariance (void) const { NS_LOG_FUNCTION (this); return m_variance; } -double +double NormalRandomVariable::GetBound (void) const { NS_LOG_FUNCTION (this); return m_bound; } -double +double NormalRandomVariable::GetValue (double mean, double variance, double bound) { NS_LOG_FUNCTION (this << mean << variance << bound); @@ -759,44 +758,44 @@ NormalRandomVariable::GetValue (double mean, double variance, double bound) } } -uint32_t +uint32_t NormalRandomVariable::GetInteger (uint32_t mean, uint32_t variance, uint32_t bound) { NS_LOG_FUNCTION (this << mean << variance << bound); return static_cast ( GetValue (mean, variance, bound) ); } -double +double NormalRandomVariable::GetValue (void) { NS_LOG_FUNCTION (this); return GetValue (m_mean, m_variance, m_bound); } -uint32_t +uint32_t NormalRandomVariable::GetInteger (void) { NS_LOG_FUNCTION (this); return (uint32_t)GetValue (m_mean, m_variance, m_bound); } -NS_OBJECT_ENSURE_REGISTERED(LogNormalRandomVariable); +NS_OBJECT_ENSURE_REGISTERED (LogNormalRandomVariable); -TypeId +TypeId LogNormalRandomVariable::GetTypeId (void) { static TypeId tid = TypeId ("ns3::LogNormalRandomVariable") .SetParent() .SetGroupName ("Core") .AddConstructor () - .AddAttribute("Mu", "The mu value for the log-normal distribution returned by this RNG stream.", - DoubleValue(0.0), - MakeDoubleAccessor(&LogNormalRandomVariable::m_mu), - MakeDoubleChecker()) - .AddAttribute("Sigma", "The sigma value for the log-normal distribution returned by this RNG stream.", - DoubleValue(1.0), - MakeDoubleAccessor(&LogNormalRandomVariable::m_sigma), - MakeDoubleChecker()) - ; + .AddAttribute ("Mu", "The mu value for the log-normal distribution returned by this RNG stream.", + DoubleValue (0.0), + MakeDoubleAccessor (&LogNormalRandomVariable::m_mu), + MakeDoubleChecker()) + .AddAttribute ("Sigma", "The sigma value for the log-normal distribution returned by this RNG stream.", + DoubleValue (1.0), + MakeDoubleAccessor (&LogNormalRandomVariable::m_sigma), + MakeDoubleChecker()) + ; return tid; } LogNormalRandomVariable::LogNormalRandomVariable () @@ -806,13 +805,13 @@ LogNormalRandomVariable::LogNormalRandomVariable () NS_LOG_FUNCTION (this); } -double +double LogNormalRandomVariable::GetMu (void) const { NS_LOG_FUNCTION (this); return m_mu; } -double +double LogNormalRandomVariable::GetSigma (void) const { NS_LOG_FUNCTION (this); @@ -845,7 +844,7 @@ LogNormalRandomVariable::GetSigma (void) const for x > 0. Lognormal random numbers are the exponentials of gaussian random numbers */ -double +double LogNormalRandomVariable::GetValue (double mu, double sigma) { double v1, v2, r2, normal, x; @@ -879,62 +878,62 @@ LogNormalRandomVariable::GetValue (double mu, double sigma) return x; } -uint32_t +uint32_t LogNormalRandomVariable::GetInteger (uint32_t mu, uint32_t sigma) { NS_LOG_FUNCTION (this << mu << sigma); return static_cast ( GetValue (mu, sigma)); } -double +double LogNormalRandomVariable::GetValue (void) { NS_LOG_FUNCTION (this); return GetValue (m_mu, m_sigma); } -uint32_t +uint32_t LogNormalRandomVariable::GetInteger (void) { NS_LOG_FUNCTION (this); return (uint32_t)GetValue (m_mu, m_sigma); } -NS_OBJECT_ENSURE_REGISTERED(GammaRandomVariable); +NS_OBJECT_ENSURE_REGISTERED (GammaRandomVariable); -TypeId +TypeId GammaRandomVariable::GetTypeId (void) { static TypeId tid = TypeId ("ns3::GammaRandomVariable") .SetParent() .SetGroupName ("Core") .AddConstructor () - .AddAttribute("Alpha", "The alpha value for the gamma distribution returned by this RNG stream.", - DoubleValue(1.0), - MakeDoubleAccessor(&GammaRandomVariable::m_alpha), - MakeDoubleChecker()) - .AddAttribute("Beta", "The beta value for the gamma distribution returned by this RNG stream.", - DoubleValue(1.0), - MakeDoubleAccessor(&GammaRandomVariable::m_beta), - MakeDoubleChecker()) - ; + .AddAttribute ("Alpha", "The alpha value for the gamma distribution returned by this RNG stream.", + DoubleValue (1.0), + MakeDoubleAccessor (&GammaRandomVariable::m_alpha), + MakeDoubleChecker()) + .AddAttribute ("Beta", "The beta value for the gamma distribution returned by this RNG stream.", + DoubleValue (1.0), + MakeDoubleAccessor (&GammaRandomVariable::m_beta), + MakeDoubleChecker()) + ; return tid; } GammaRandomVariable::GammaRandomVariable () : - m_nextValid (false) + m_nextValid (false) { // m_alpha and m_beta are initialized after constructor by // attributes NS_LOG_FUNCTION (this); } -double +double GammaRandomVariable::GetAlpha (void) const { NS_LOG_FUNCTION (this); return m_alpha; } -double +double GammaRandomVariable::GetBeta (void) const { NS_LOG_FUNCTION (this); @@ -957,7 +956,7 @@ GammaRandomVariable::GetBeta (void) const for x > 0. */ -double +double GammaRandomVariable::GetValue (double alpha, double beta) { NS_LOG_FUNCTION (this << alpha << beta); @@ -1009,27 +1008,27 @@ GammaRandomVariable::GetValue (double alpha, double beta) return beta * d * v; } -uint32_t +uint32_t GammaRandomVariable::GetInteger (uint32_t alpha, uint32_t beta) { NS_LOG_FUNCTION (this << alpha << beta); return static_cast ( GetValue (alpha, beta)); } -double +double GammaRandomVariable::GetValue (void) { NS_LOG_FUNCTION (this); return GetValue (m_alpha, m_beta); } -uint32_t +uint32_t GammaRandomVariable::GetInteger (void) { NS_LOG_FUNCTION (this); return (uint32_t)GetValue (m_alpha, m_beta); } -double +double GammaRandomVariable::GetNormalValue (double mean, double variance, double bound) { NS_LOG_FUNCTION (this << mean << variance << bound); @@ -1075,24 +1074,24 @@ GammaRandomVariable::GetNormalValue (double mean, double variance, double bound) } } -NS_OBJECT_ENSURE_REGISTERED(ErlangRandomVariable); +NS_OBJECT_ENSURE_REGISTERED (ErlangRandomVariable); -TypeId +TypeId ErlangRandomVariable::GetTypeId (void) { static TypeId tid = TypeId ("ns3::ErlangRandomVariable") .SetParent() .SetGroupName ("Core") .AddConstructor () - .AddAttribute("K", "The k value for the Erlang distribution returned by this RNG stream.", - IntegerValue(1), - MakeIntegerAccessor(&ErlangRandomVariable::m_k), - MakeIntegerChecker()) - .AddAttribute("Lambda", "The lambda value for the Erlang distribution returned by this RNG stream.", - DoubleValue(1.0), - MakeDoubleAccessor(&ErlangRandomVariable::m_lambda), - MakeDoubleChecker()) - ; + .AddAttribute ("K", "The k value for the Erlang distribution returned by this RNG stream.", + IntegerValue (1), + MakeIntegerAccessor (&ErlangRandomVariable::m_k), + MakeIntegerChecker()) + .AddAttribute ("Lambda", "The lambda value for the Erlang distribution returned by this RNG stream.", + DoubleValue (1.0), + MakeDoubleAccessor (&ErlangRandomVariable::m_lambda), + MakeDoubleChecker()) + ; return tid; } ErlangRandomVariable::ErlangRandomVariable () @@ -1101,13 +1100,13 @@ ErlangRandomVariable::ErlangRandomVariable () NS_LOG_FUNCTION (this); } -uint32_t +uint32_t ErlangRandomVariable::GetK (void) const { NS_LOG_FUNCTION (this); return m_k; } -double +double ErlangRandomVariable::GetLambda (void) const { NS_LOG_FUNCTION (this); @@ -1126,7 +1125,7 @@ ErlangRandomVariable::GetLambda (void) const for x > 0. */ -double +double ErlangRandomVariable::GetValue (uint32_t k, double lambda) { NS_LOG_FUNCTION (this << k << lambda); @@ -1143,27 +1142,27 @@ ErlangRandomVariable::GetValue (uint32_t k, double lambda) return result; } -uint32_t +uint32_t ErlangRandomVariable::GetInteger (uint32_t k, uint32_t lambda) { NS_LOG_FUNCTION (this << k << lambda); return static_cast ( GetValue (k, lambda)); } -double +double ErlangRandomVariable::GetValue (void) { NS_LOG_FUNCTION (this); return GetValue (m_k, m_lambda); } -uint32_t +uint32_t ErlangRandomVariable::GetInteger (void) { NS_LOG_FUNCTION (this); return (uint32_t)GetValue (m_k, m_lambda); } -double +double ErlangRandomVariable::GetExponentialValue (double mean, double bound) { NS_LOG_FUNCTION (this << mean << bound); @@ -1187,28 +1186,28 @@ ErlangRandomVariable::GetExponentialValue (double mean, double bound) } } -NS_OBJECT_ENSURE_REGISTERED(TriangularRandomVariable); +NS_OBJECT_ENSURE_REGISTERED (TriangularRandomVariable); -TypeId +TypeId TriangularRandomVariable::GetTypeId (void) { static TypeId tid = TypeId ("ns3::TriangularRandomVariable") .SetParent() .SetGroupName ("Core") .AddConstructor () - .AddAttribute("Mean", "The mean value for the triangular distribution returned by this RNG stream.", - DoubleValue(0.5), - MakeDoubleAccessor(&TriangularRandomVariable::m_mean), - MakeDoubleChecker()) - .AddAttribute("Min", "The lower bound on the values returned by this RNG stream.", - DoubleValue(0.0), - MakeDoubleAccessor(&TriangularRandomVariable::m_min), - MakeDoubleChecker()) - .AddAttribute("Max", "The upper bound on the values returned by this RNG stream.", - DoubleValue(1.0), - MakeDoubleAccessor(&TriangularRandomVariable::m_max), - MakeDoubleChecker()) - ; + .AddAttribute ("Mean", "The mean value for the triangular distribution returned by this RNG stream.", + DoubleValue (0.5), + MakeDoubleAccessor (&TriangularRandomVariable::m_mean), + MakeDoubleChecker()) + .AddAttribute ("Min", "The lower bound on the values returned by this RNG stream.", + DoubleValue (0.0), + MakeDoubleAccessor (&TriangularRandomVariable::m_min), + MakeDoubleChecker()) + .AddAttribute ("Max", "The upper bound on the values returned by this RNG stream.", + DoubleValue (1.0), + MakeDoubleAccessor (&TriangularRandomVariable::m_max), + MakeDoubleChecker()) + ; return tid; } TriangularRandomVariable::TriangularRandomVariable () @@ -1218,26 +1217,26 @@ TriangularRandomVariable::TriangularRandomVariable () NS_LOG_FUNCTION (this); } -double +double TriangularRandomVariable::GetMean (void) const { NS_LOG_FUNCTION (this); return m_mean; } -double +double TriangularRandomVariable::GetMin (void) const { NS_LOG_FUNCTION (this); return m_min; } -double +double TriangularRandomVariable::GetMax (void) const { NS_LOG_FUNCTION (this); return m_max; } -double +double TriangularRandomVariable::GetValue (double mean, double min, double max) { // Calculate the mode. @@ -1262,44 +1261,44 @@ TriangularRandomVariable::GetValue (double mean, double min, double max) } } -uint32_t +uint32_t TriangularRandomVariable::GetInteger (uint32_t mean, uint32_t min, uint32_t max) { NS_LOG_FUNCTION (this << mean << min << max); return static_cast ( GetValue (mean, min, max) ); } -double +double TriangularRandomVariable::GetValue (void) { NS_LOG_FUNCTION (this); return GetValue (m_mean, m_min, m_max); } -uint32_t +uint32_t TriangularRandomVariable::GetInteger (void) { NS_LOG_FUNCTION (this); return (uint32_t)GetValue (m_mean, m_min, m_max); } -NS_OBJECT_ENSURE_REGISTERED(ZipfRandomVariable); +NS_OBJECT_ENSURE_REGISTERED (ZipfRandomVariable); -TypeId +TypeId ZipfRandomVariable::GetTypeId (void) { static TypeId tid = TypeId ("ns3::ZipfRandomVariable") .SetParent() .SetGroupName ("Core") .AddConstructor () - .AddAttribute("N", "The n value for the Zipf distribution returned by this RNG stream.", - IntegerValue(1), - MakeIntegerAccessor(&ZipfRandomVariable::m_n), - MakeIntegerChecker()) - .AddAttribute("Alpha", "The alpha value for the Zipf distribution returned by this RNG stream.", - DoubleValue(0.0), - MakeDoubleAccessor(&ZipfRandomVariable::m_alpha), - MakeDoubleChecker()) - ; + .AddAttribute ("N", "The n value for the Zipf distribution returned by this RNG stream.", + IntegerValue (1), + MakeIntegerAccessor (&ZipfRandomVariable::m_n), + MakeIntegerChecker()) + .AddAttribute ("Alpha", "The alpha value for the Zipf distribution returned by this RNG stream.", + DoubleValue (0.0), + MakeDoubleAccessor (&ZipfRandomVariable::m_alpha), + MakeDoubleChecker()) + ; return tid; } ZipfRandomVariable::ZipfRandomVariable () @@ -1308,20 +1307,20 @@ ZipfRandomVariable::ZipfRandomVariable () NS_LOG_FUNCTION (this); } -uint32_t +uint32_t ZipfRandomVariable::GetN (void) const { NS_LOG_FUNCTION (this); return m_n; } -double +double ZipfRandomVariable::GetAlpha (void) const { NS_LOG_FUNCTION (this); return m_alpha; } -double +double ZipfRandomVariable::GetValue (uint32_t n, double alpha) { NS_LOG_FUNCTION (this << n << alpha); @@ -1353,40 +1352,40 @@ ZipfRandomVariable::GetValue (uint32_t n, double alpha) return zipf_value; } -uint32_t +uint32_t ZipfRandomVariable::GetInteger (uint32_t n, uint32_t alpha) { NS_LOG_FUNCTION (this << n << alpha); return static_cast ( GetValue (n, alpha)); } -double +double ZipfRandomVariable::GetValue (void) { NS_LOG_FUNCTION (this); return GetValue (m_n, m_alpha); } -uint32_t +uint32_t ZipfRandomVariable::GetInteger (void) { NS_LOG_FUNCTION (this); return (uint32_t)GetValue (m_n, m_alpha); } -NS_OBJECT_ENSURE_REGISTERED(ZetaRandomVariable); +NS_OBJECT_ENSURE_REGISTERED (ZetaRandomVariable); -TypeId +TypeId ZetaRandomVariable::GetTypeId (void) { static TypeId tid = TypeId ("ns3::ZetaRandomVariable") .SetParent() .SetGroupName ("Core") .AddConstructor () - .AddAttribute("Alpha", "The alpha value for the zeta distribution returned by this RNG stream.", - DoubleValue(3.14), - MakeDoubleAccessor(&ZetaRandomVariable::m_alpha), - MakeDoubleChecker()) - ; + .AddAttribute ("Alpha", "The alpha value for the zeta distribution returned by this RNG stream.", + DoubleValue (3.14), + MakeDoubleAccessor (&ZetaRandomVariable::m_alpha), + MakeDoubleChecker()) + ; return tid; } ZetaRandomVariable::ZetaRandomVariable () @@ -1395,14 +1394,14 @@ ZetaRandomVariable::ZetaRandomVariable () NS_LOG_FUNCTION (this); } -double +double ZetaRandomVariable::GetAlpha (void) const { NS_LOG_FUNCTION (this); return m_alpha; } -double +double ZetaRandomVariable::GetValue (double alpha) { NS_LOG_FUNCTION (this << alpha); @@ -1437,43 +1436,43 @@ ZetaRandomVariable::GetValue (double alpha) return X; } -uint32_t +uint32_t ZetaRandomVariable::GetInteger (uint32_t alpha) { NS_LOG_FUNCTION (this << alpha); return static_cast ( GetValue (alpha)); } -double +double ZetaRandomVariable::GetValue (void) { NS_LOG_FUNCTION (this); return GetValue (m_alpha); } -uint32_t +uint32_t ZetaRandomVariable::GetInteger (void) { NS_LOG_FUNCTION (this); return (uint32_t)GetValue (m_alpha); } -NS_OBJECT_ENSURE_REGISTERED(DeterministicRandomVariable); +NS_OBJECT_ENSURE_REGISTERED (DeterministicRandomVariable); -TypeId +TypeId DeterministicRandomVariable::GetTypeId (void) { static TypeId tid = TypeId ("ns3::DeterministicRandomVariable") .SetParent() .SetGroupName ("Core") .AddConstructor () - ; + ; return tid; } DeterministicRandomVariable::DeterministicRandomVariable () : - m_count (0), - m_next (0), - m_data (0) + m_count (0), + m_next (0), + m_data (0) { NS_LOG_FUNCTION (this); } @@ -1482,9 +1481,9 @@ DeterministicRandomVariable::~DeterministicRandomVariable () // Delete any values currently set. NS_LOG_FUNCTION (this); if (m_data != 0) - { - delete[] m_data; - } + { + delete[] m_data; + } } void @@ -1493,9 +1492,9 @@ DeterministicRandomVariable::SetValueArray (double* values, std::size_t length) NS_LOG_FUNCTION (this << values << length); // Delete any values currently set. if (m_data != 0) - { - delete[] m_data; - } + { + delete[] m_data; + } // Make room for the values being set. m_data = new double[length]; @@ -1509,7 +1508,7 @@ DeterministicRandomVariable::SetValueArray (double* values, std::size_t length) } } -double +double DeterministicRandomVariable::GetValue (void) { NS_LOG_FUNCTION (this); @@ -1523,14 +1522,14 @@ DeterministicRandomVariable::GetValue (void) return m_data[m_next++]; } -uint32_t +uint32_t DeterministicRandomVariable::GetInteger (void) { NS_LOG_FUNCTION (this); return (uint32_t)GetValue (); } -NS_OBJECT_ENSURE_REGISTERED(EmpiricalRandomVariable); +NS_OBJECT_ENSURE_REGISTERED (EmpiricalRandomVariable); // ValueCDF methods EmpiricalRandomVariable::ValueCDF::ValueCDF () @@ -1553,24 +1552,24 @@ EmpiricalRandomVariable::ValueCDF::ValueCDF (const ValueCDF& c) NS_LOG_FUNCTION (this << &c); } -TypeId +TypeId EmpiricalRandomVariable::GetTypeId (void) { static TypeId tid = TypeId ("ns3::EmpiricalRandomVariable") .SetParent() .SetGroupName ("Core") .AddConstructor () - ; + ; return tid; } EmpiricalRandomVariable::EmpiricalRandomVariable () : - m_validated (false) + m_validated (false) { NS_LOG_FUNCTION (this); } -double +double EmpiricalRandomVariable::GetValue (void) { NS_LOG_FUNCTION (this); @@ -1620,7 +1619,7 @@ EmpiricalRandomVariable::GetValue (void) } } -uint32_t +uint32_t EmpiricalRandomVariable::GetInteger (void) { NS_LOG_FUNCTION (this); @@ -1648,9 +1647,9 @@ void EmpiricalRandomVariable::Validate () if (current.value < prior.value || current.cdf < prior.cdf) { // Error std::cerr << "Empirical Dist error," - << " current value " << current.value - << " prior value " << prior.value - << " current cdf " << current.cdf + << " current value " << current.value + << " prior value " << prior.value + << " current cdf " << current.cdf << " prior cdf " << prior.cdf << std::endl; NS_FATAL_ERROR ("Empirical Dist error"); } @@ -1664,7 +1663,7 @@ void EmpiricalRandomVariable::Validate () } double EmpiricalRandomVariable::Interpolate (double c1, double c2, - double v1, double v2, double r) + double v1, double v2, double r) { // Interpolate random value in range [v1..v2) based on [c1 .. r .. c2) NS_LOG_FUNCTION (this << c1 << c2 << v1 << v2 << r); return (v1 + ((v2 - v1) / (c2 - c1)) * (r - c1)); diff --git a/src/core/model/random-variable-stream.h b/src/core/model/random-variable-stream.h index 942d4569f..10ea27386 100644 --- a/src/core/model/random-variable-stream.h +++ b/src/core/model/random-variable-stream.h @@ -53,22 +53,22 @@ namespace ns3 { * this marks a change in policy starting with ns-3.4. * - In ns-3.14 and earlier, ns-3 simulations used a different wrapper * class called ns3::RandomVariable. This implementation is documented - * above under Legacy Random Variables. As of ns-3.15, this class has - * been replaced by ns3::RandomVariableStream; the underlying + * above under Legacy Random Variables. As of ns-3.15, this class has + * been replaced by ns3::RandomVariableStream; the underlying * pseudo-random number generator has not changed. * - To obtain randomness across multiple simulation runs, you must * either set the seed differently or set the run number differently. * To set a seed, call ns3::RngSeedManager::SetSeed() at the beginning - * of the program; to set a run number with the same seed, call + * of the program; to set a run number with the same seed, call * ns3::RngSeedManager::SetRun() at the beginning of the program. - * - Each RandomVariableStream used in ns-3 has a virtual random number - * generator associated with it; all random variables use either - * a fixed or random seed based on the use of the global seed. - * - If you intend to perform multiple runs of the same scenario, - * with different random numbers, please be sure to read the manual + * - Each RandomVariableStream used in ns-3 has a virtual random number + * generator associated with it; all random variables use either + * a fixed or random seed based on the use of the global seed. + * - If you intend to perform multiple runs of the same scenario, + * with different random numbers, please be sure to read the manual * section on how to perform independent replications. */ - + class RngStream; /** @@ -109,7 +109,7 @@ public: /** * \brief Destructor. */ - virtual ~RandomVariableStream(); + virtual ~RandomVariableStream (); /** * \brief Specifies the stream number for the RngStream. @@ -123,19 +123,19 @@ public: * \return The stream number for the RngStream. * -1 means this stream was allocated automatically. */ - int64_t GetStream(void) const; + int64_t GetStream (void) const; /** * \brief Specify whether antithetic values should be generated. * \param [in] isAntithetic If \c true antithetic value will be generated. */ - void SetAntithetic(bool isAntithetic); + void SetAntithetic (bool isAntithetic); /** * \brief Check if antithetic values will be generated. * \return \c true if antithetic values will be generated. */ - bool IsAntithetic(void) const; + bool IsAntithetic (void) const; /** * \brief Get the next random value as a double drawn from the distribution. @@ -154,7 +154,7 @@ protected: * \brief Get the pointer to the underlying RngStream. * \return The underlying RngStream */ - RngStream *Peek(void) const; + RngStream * Peek (void) const; private: /** @@ -189,7 +189,7 @@ private: }; // class RandomVariableStream - + /** * \ingroup randomvariable * \brief The uniform distribution Random Number Generator (RNG). @@ -208,11 +208,11 @@ private: * \code * double min = 0.0; * double max = 10.0; - * + * * Ptr x = CreateObject (); * x->SetAttribute ("Min", DoubleValue (min)); * x->SetAttribute ("Max", DoubleValue (max)); - * + * * // The values returned by a uniformly distributed random * // variable should always be within the range * // @@ -294,7 +294,7 @@ public: * \note The upper limit is included in the output range. */ virtual uint32_t GetInteger (void); - + private: /** The lower bound on values that can be returned by this RNG stream. */ double m_min; @@ -304,7 +304,7 @@ private: }; // class UniformRandomVariable - + /** * \ingroup randomvariable * \brief The Random Number Generator (RNG) that returns a constant. @@ -360,7 +360,7 @@ private: }; // class ConstantRandomVariable - + /** * \ingroup randomvariable * \brief The Random Number Generator (RNG) that returns a pattern of @@ -465,7 +465,7 @@ private: }; // class SequentialRandomVariable - + /** * \ingroup randomvariable * \brief The exponential distribution Random Number Generator (RNG). @@ -515,11 +515,11 @@ private: * \code * double mean = 3.14; * double bound = 0.0; - * + * * Ptr x = CreateObject (); * x->SetAttribute ("Mean", DoubleValue (mean)); * x->SetAttribute ("Bound", DoubleValue (bound)); - * + * * // The expected value for the mean of the values returned by an * // exponentially distributed random variable is equal to mean. * double value = x->GetValue (); @@ -530,7 +530,7 @@ private: * The antithetic value is calculated from * * \f[ - * x' = - mean * \log(1 - u), + * x' = - mean * \log(1 - u), * \f] * * where again \f$u\f$ is a uniform random variable on \f$[0,1)\f$. @@ -596,7 +596,7 @@ private: }; // class ExponentialRandomVariable - + /** * \ingroup randomvariable * \brief The Pareto distribution Random Number Generator (RNG). @@ -622,11 +622,11 @@ private: * \code * double scale = 5.0; * double shape = 2.0; - * + * * Ptr x = CreateObject (); * x->SetAttribute ("Scale", DoubleValue (scale)); * x->SetAttribute ("Shape", DoubleValue (shape)); - * + * * // The expected value for the mean of the values returned by a * // Pareto distributed random variable is * // @@ -693,7 +693,7 @@ public: * \f] * * is a value that would be returned normally. - * + * * The value returned in the antithetic case, \f$x'\f$, is * calculated as * @@ -746,11 +746,11 @@ public: * \f] * * is a value that would be returned normally, where - * + * * \f[ * scale = mean * (shape - 1.0) / shape . * \f] - * + * * The value returned in the antithetic case, \f$x'\f$, is * calculated as * @@ -807,7 +807,7 @@ private: }; // class ParetoRandomVariable - + /** * \ingroup randomvariable * \brief The Weibull distribution Random Number Generator (RNG) that allows stream numbers to be set deterministically. @@ -831,20 +831,20 @@ private: * \code * double scale = 5.0; * double shape = 1.0; - * + * * Ptr x = CreateObject (); * x->SetAttribute ("Scale", DoubleValue (scale)); * x->SetAttribute ("Shape", DoubleValue (shape)); - * + * * // The expected value for the mean of the values returned by a * // Weibull distributed random variable is * // * // E[value] = scale * Gamma(1 + 1 / shape) , - * // - * // where Gamma() is the Gamma function. Note that - * // + * // + * // where Gamma() is the Gamma function. Note that + * // * // Gamma(n) = (n - 1)! - * // + * // * // if n is a positive integer. * // * // For this example, @@ -857,7 +857,7 @@ private: * // which means * // * // E[value] = scale . - * // + * // * double value = x->GetValue (); * \endcode */ @@ -1013,7 +1013,7 @@ private: }; // class WeibullRandomVariable - + /** * \ingroup randomvariable * \brief The normal (Gaussian) distribution Random Number Generator @@ -1037,11 +1037,11 @@ private: * \code * double mean = 5.0; * double variance = 2.0; - * + * * Ptr x = CreateObject (); * x->SetAttribute ("Mean", DoubleValue (mean)); * x->SetAttribute ("Variance", DoubleValue (variance)); - * + * * // The expected value for the mean of the values returned by a * // normally distributed random variable is equal to mean. * double value = x->GetValue (); @@ -1252,7 +1252,7 @@ private: }; // class NormalRandomVariable - + /** * \ingroup randomvariable * \brief The log-normal distribution Random Number Generator @@ -1281,13 +1281,13 @@ private: * \code * double mu = 5.0; * double sigma = 2.0; - * + * * Ptr x = CreateObject (); * x->SetAttribute ("Mu", DoubleValue (mu)); * x->SetAttribute ("Sigma", DoubleValue (sigma)); - * + * * // The expected value for the mean of the values returned by a - * // log-normally distributed random variable is equal to + * // log-normally distributed random variable is equal to * // * // 2 * // mu + sigma / 2 @@ -1472,7 +1472,7 @@ private: double m_sigma; }; // class LogNormalRandomVariable - + /** * \ingroup randomvariable @@ -1492,13 +1492,13 @@ private: * \code * double alpha = 5.0; * double beta = 2.0; - * + * * Ptr x = CreateObject (); * x->SetAttribute ("Alpha", DoubleValue (alpha)); * x->SetAttribute ("Beta", DoubleValue (beta)); - * + * * // The expected value for the mean of the values returned by a - * // gammaly distributed random variable is equal to + * // gammaly distributed random variable is equal to * // * // E[value] = alpha * beta . * // @@ -1645,7 +1645,7 @@ private: double m_next; }; // class GammaRandomVariable - + /** * \ingroup randomvariable @@ -1669,13 +1669,13 @@ private: * \code * uint32_t k = 5; * double lambda = 2.0; - * + * * Ptr x = CreateObject (); * x->SetAttribute ("K", IntegerValue (k)); * x->SetAttribute ("Lambda", DoubleValue (lambda)); - * + * * // The expected value for the mean of the values returned by a - * // Erlangly distributed random variable is equal to + * // Erlangly distributed random variable is equal to * // * // E[value] = k * lambda . * // @@ -1782,7 +1782,7 @@ private: * over [0,1] and * * \f[ - * x = - mean * \log(u) + * x = - mean * \log(u) * \f] * * is a value that would be returned normally, then \f$(1 - u\f$) is @@ -1790,7 +1790,7 @@ private: * returned in the antithetic case, \f$x'\f$, is calculated as * * \f[ - * x' = - mean * \log(1 - u), + * x' = - mean * \log(1 - u), * \f] * * which now involves the log of the distance \f$u\f$ is from the 1. @@ -1804,7 +1804,7 @@ private: double m_lambda; }; // class ErlangRandomVariable - + /** * \ingroup randomvariable @@ -1823,12 +1823,12 @@ private: * double mean = 5.0; * double min = 2.0; * double max = 10.0; - * + * * Ptr x = CreateObject (); * x->SetAttribute ("Mean", DoubleValue (mean)); * x->SetAttribute ("Min", DoubleValue (min)); * x->SetAttribute ("Max", DoubleValue (max)); - * + * * // The expected value for the mean of the values returned by a * // triangularly distributed random variable is equal to mean. * double value = x->GetValue (); @@ -2037,7 +2037,7 @@ private: double m_max; }; // class TriangularRandomVariable - + /** * \ingroup randomvariable @@ -2061,29 +2061,29 @@ private: * \code * uint32_t n = 1; * double alpha = 2.0; - * + * * Ptr x = CreateObject (); * x->SetAttribute ("N", IntegerValue (n)); * x->SetAttribute ("Alpha", DoubleValue (alpha)); - * + * * // The expected value for the mean of the values returned by a - * // Zipfly distributed random variable is equal to + * // Zipfly distributed random variable is equal to * // * // H * // N, alpha - 1 * // E[value] = --------------- * // H * // N, alpha - * // + * // * // where * // - * // N - * // --- + * // N + * // --- * // \ -alpha * // H = / m . * // N, alpha --- - * // m=1 - * // + * // m=1 + * // * // For this test, * // * // -(alpha - 1) @@ -2093,7 +2093,7 @@ private: * // 1 * // * // = 1 . - * // + * // * double value = x->GetValue (); * \endcode */ @@ -2196,7 +2196,7 @@ private: double m_c; }; // class ZipfRandomVariable - + /** * \ingroup randomvariable @@ -2217,23 +2217,23 @@ private: * Here is an example of how to use this class: * \code * double alpha = 2.0; - * + * * Ptr x = CreateObject (); * x->SetAttribute ("Alpha", DoubleValue (alpha)); - * + * * // The expected value for the mean of the values returned by a - * // zetaly distributed random variable is equal to + * // zetaly distributed random variable is equal to * // * // zeta(alpha - 1) * // E[value] = --------------- for alpha > 2 , * // zeta(alpha) - * // + * // * // where zeta(alpha) is the Riemann zeta function. - * // + * // * // There are no simple analytic forms for the Riemann zeta * // function, which is the reason the known mean of the values * // cannot be calculated in this example. - * // + * // * double value = x->GetValue (); * \endcode */ @@ -2325,7 +2325,7 @@ private: double m_b; }; // class ZetaRandomVariable - + /** * \ingroup randomvariable @@ -2345,7 +2345,7 @@ private: * Here is an example of how to use this class: * \code * Ptr s = CreateObject (); - * + * * // The following array should give the sequence * // * // 4, 4, 7, 7, 10, 10 . @@ -2353,7 +2353,7 @@ private: * double array [] = { 4, 4, 7, 7, 10, 10}; * uint64_t count = 6; * s->SetValueArray (array, count); - * + * * double value = x->GetValue (); * \endcode */ @@ -2406,7 +2406,7 @@ private: double* m_data; }; // class DeterministicRandomVariable - + /** * \ingroup randomvariable @@ -2430,12 +2430,12 @@ private: * x->CDF ( 0.0, 0.0); * x->CDF ( 5.0, 0.5); * x->CDF (10.0, 1.0); - * + * * // The expected value for the mean of the values returned by this * // empirical distribution is the midpoint of the distribution * // * // E[value] = 5 . - * // + * // * double value = x->GetValue (); * \endcode */ @@ -2491,7 +2491,7 @@ private: /** Helper to hold one point of the CDF. */ class ValueCDF { -public: + public: /** Constructor. */ ValueCDF (); /** @@ -2537,14 +2537,14 @@ public: */ virtual double Interpolate (double c1, double c2, double v1, double v2, double r); - + /** \c true once the CDF has been validated. */ bool m_validated; /** The vector of CDF points. */ std::vector m_emp; }; // class EmpiricalRandomVariable - + } // namespace ns3 diff --git a/src/core/model/realtime-simulator-impl.cc b/src/core/model/realtime-simulator-impl.cc index c8b79fbcb..7d098ebd5 100644 --- a/src/core/model/realtime-simulator-impl.cc +++ b/src/core/model/realtime-simulator-impl.cc @@ -58,13 +58,13 @@ RealtimeSimulatorImpl::GetTypeId (void) .SetParent () .SetGroupName ("Core") .AddConstructor () - .AddAttribute ("SynchronizationMode", + .AddAttribute ("SynchronizationMode", "What to do if the simulation cannot keep up with real time.", EnumValue (SYNC_BEST_EFFORT), MakeEnumAccessor (&RealtimeSimulatorImpl::SetSynchronizationMode), MakeEnumChecker (SYNC_BEST_EFFORT, "BestEffort", SYNC_HARD_LIMIT, "HardLimit")) - .AddAttribute ("HardLimit", + .AddAttribute ("HardLimit", "Maximum acceptable real-time jitter (used in conjunction with SynchronizationMode=HardLimit)", TimeValue (Seconds (0.1)), MakeTimeAccessor (&RealtimeSimulatorImpl::m_hardLimit), @@ -84,7 +84,7 @@ RealtimeSimulatorImpl::RealtimeSimulatorImpl () // uid 0 is "invalid" events // uid 1 is "now" events // uid 2 is "destroy" events - m_uid = 4; + m_uid = 4; // before ::Run is entered, the m_currentUid will be zero m_currentUid = 0; m_currentTs = 0; @@ -92,7 +92,7 @@ RealtimeSimulatorImpl::RealtimeSimulatorImpl () m_unscheduledEvents = 0; m_eventCount = 0; - m_main = SystemThread::Self(); + m_main = SystemThread::Self (); // Be very careful not to do anything that would cause a change or assignment // of the underlying reference counts of m_synchronizer or you will be sorry. @@ -125,13 +125,13 @@ RealtimeSimulatorImpl::Destroy () // // This function is only called with the private version "disconnected" from - // the main simulator functions. We rely on the user not calling + // the main simulator functions. We rely on the user not calling // Simulator::Destroy while there is a chance that a worker thread could be // accessing the current instance of the private object. In practice this // means shutting down the workers and doing a Join() before calling the // Simulator::Destroy(). // - while (m_destroyEvents.empty () == false) + while (m_destroyEvents.empty () == false) { Ptr ev = m_destroyEvents.front ().PeekEventImpl (); m_destroyEvents.pop_front (); @@ -150,7 +150,7 @@ RealtimeSimulatorImpl::SetScheduler (ObjectFactory schedulerFactory) Ptr scheduler = schedulerFactory.Create (); - { + { CriticalSection cs (m_mutex); if (m_events != 0) @@ -177,28 +177,28 @@ RealtimeSimulatorImpl::ProcessOneEvent (void) // We need to be able to have external events (such as a packet reception event) // cause us to re-evaluate our state. The way this works is that the synchronizer // gets interrupted and returns. So, there is a possibility that things may change - // out from under us dynamically. In this case, we need to re-evaluate how long to - // wait in a for-loop until we have waited successfully (until a timeout) for the + // out from under us dynamically. In this case, we need to re-evaluate how long to + // wait in a for-loop until we have waited successfully (until a timeout) for the // event at the head of the event list. // - // m_synchronizer->Synchronize will return true if the wait was completed without + // m_synchronizer->Synchronize will return true if the wait was completed without // interruption, otherwise it will return false indicating that something has changed - // out from under us. If we sit in the for-loop trying to synchronize until - // Synchronize() returns true, we will have successfully synchronized the execution + // out from under us. If we sit in the for-loop trying to synchronize until + // Synchronize() returns true, we will have successfully synchronized the execution // time of the next event with the wall clock time of the synchronizer. // - for (;;) + for (;;) { uint64_t tsDelay = 0; uint64_t tsNext = 0; // - // It is important to understand that m_currentTs is interpreted only as the - // timestamp of the last event we executed. Current time can a bit of a - // slippery concept in realtime mode. What we have here is a discrete event + // It is important to understand that m_currentTs is interpreted only as the + // timestamp of the last event we executed. Current time can a bit of a + // slippery concept in realtime mode. What we have here is a discrete event // simulator, so the last event is, by definition, executed entirely at a single - // discrete time. This is the definition of m_currentTs. It really has + // discrete time. This is the definition of m_currentTs. It really has // nothing to do with the current real time, except that we are trying to arrange // that at the instant of the beginning of event execution, the current real time // and m_currentTs coincide. @@ -207,19 +207,19 @@ RealtimeSimulatorImpl::ProcessOneEvent (void) // uint64_t tsNow; - { + { CriticalSection cs (m_mutex); // - // Since we are in realtime mode, the time to delay has got to be the - // difference between the current realtime and the timestamp of the next - // event. Since m_currentTs is actually the timestamp of the last event we + // Since we are in realtime mode, the time to delay has got to be the + // difference between the current realtime and the timestamp of the next + // event. Since m_currentTs is actually the timestamp of the last event we // executed, it's not particularly meaningful for us here since real time has // certainly elapsed since it was last updated. // // It is possible that the current realtime has drifted past the next event // time so we need to be careful about that and not delay in that case. // - NS_ASSERT_MSG (m_synchronizer->Realtime (), + NS_ASSERT_MSG (m_synchronizer->Realtime (), "RealtimeSimulatorImpl::ProcessOneEvent (): Synchronizer reports not Realtime ()"); // @@ -251,9 +251,9 @@ RealtimeSimulatorImpl::ProcessOneEvent (void) } // - // We've figured out how long we need to delay in order to pace the + // We've figured out how long we need to delay in order to pace the // simulation time with the real time. We're going to sleep, but need - // to work with the synchronizer to make sure we're awakened if something + // to work with the synchronizer to make sure we're awakened if something // external happens (like a packet is received). This next line resets // the synchronizer so that any future event will cause it to interrupt. // @@ -263,17 +263,17 @@ RealtimeSimulatorImpl::ProcessOneEvent (void) // // We have a time to delay. This time may actually not be valid anymore // since we released the critical section immediately above, and a real-time - // ScheduleReal or ScheduleRealNow may have snuck in, well, between the - // closing brace above and this comment so to speak. If this is the case, - // that schedule operation will have done a synchronizer Signal() that - // will set the condition variable to true and cause the Synchronize call + // ScheduleReal or ScheduleRealNow may have snuck in, well, between the + // closing brace above and this comment so to speak. If this is the case, + // that schedule operation will have done a synchronizer Signal() that + // will set the condition variable to true and cause the Synchronize call // below to return immediately. // // It's easiest to understand if you just consider a short tsDelay that only - // requires a SpinWait down in the synchronizer. What will happen is that - // whan Synchronize calls SpinWait, SpinWait will look directly at its - // condition variable. Note that we set this condition variable to false - // inside the critical section above. + // requires a SpinWait down in the synchronizer. What will happen is that + // whan Synchronize calls SpinWait, SpinWait will look directly at its + // condition variable. Note that we set this condition variable to false + // inside the critical section above. // // SpinWait will go into a forever loop until either the time has expired or // until the condition variable becomes true. A true condition indicates that @@ -282,11 +282,11 @@ RealtimeSimulatorImpl::ProcessOneEvent (void) // a Simulator::ScheduleReal is done, the wait down in Synchronize will exit and // Synchronize will return false. This means we have not actually synchronized // to the event expiration time. If no real-time schedule operation is done - // while down in Synchronize, the wait will time out and Synchronize will return + // while down in Synchronize, the wait will time out and Synchronize will return // true. This indicates that we have synchronized to the event time. // - // So we need to stay in this for loop, looking for the next event timestamp and - // attempting to sleep until its due. If we've slept until the timestamp is due, + // So we need to stay in this for loop, looking for the next event timestamp and + // attempting to sleep until its due. If we've slept until the timestamp is due, // Synchronize returns true and we break out of the sync loop. If an external // event happens that requires a re-schedule, Synchronize returns false and // we re-evaluate our timing by continuing in the loop. @@ -299,11 +299,11 @@ RealtimeSimulatorImpl::ProcessOneEvent (void) NS_LOG_LOGIC ("Interrupted ..."); break; } - + // // If we get to this point, we have been interrupted during a wait by a real-time // schedule operation. This means all bets are off regarding tsDelay and we need - // to re-evaluate what it is we want to do. We'll loop back around in the + // to re-evaluate what it is we want to do. We'll loop back around in the // for-loop and start again from scratch. // } @@ -318,24 +318,24 @@ RealtimeSimulatorImpl::ProcessOneEvent (void) // Scheduler::Event next; - { + { CriticalSection cs (m_mutex); - // - // We do know we're waiting for an event, so there had better be an event on the + // + // We do know we're waiting for an event, so there had better be an event on the // event queue. Let's pull it off. When we release the critical section, the // event we're working on won't be on the list and so subsequent operations won't // mess with us. // - NS_ASSERT_MSG (m_events->IsEmpty () == false, + NS_ASSERT_MSG (m_events->IsEmpty () == false, "RealtimeSimulatorImpl::ProcessOneEvent(): event queue is empty"); next = m_events->RemoveNext (); m_unscheduledEvents--; m_eventCount++; // - // We cannot make any assumption that "next" is the same event we originally waited - // for. We can only assume that only that it must be due and cannot cause time + // We cannot make any assumption that "next" is the same event we originally waited + // for. We can only assume that only that it must be due and cannot cause time // to move backward. // NS_ASSERT_MSG (next.key.m_ts >= m_currentTs, @@ -343,8 +343,8 @@ RealtimeSimulatorImpl::ProcessOneEvent (void) "next.GetTs() earlier than m_currentTs (list order error)"); NS_LOG_LOGIC ("handle " << next.key.m_ts); - // - // Update the current simulation time to be the timestamp of the event we're + // + // Update the current simulation time to be the timestamp of the event we're // executing. From the rest of the simulation's point of view, simulation time // is frozen until the next event is executed. // @@ -352,7 +352,7 @@ RealtimeSimulatorImpl::ProcessOneEvent (void) m_currentContext = next.key.m_context; m_currentUid = next.key.m_uid; - // + // // We're about to run the event and we've done our best to synchronize this // event execution time to real time. Now, if we're in SYNC_HARD_LIMIT mode // we have to decide if we've done a good enough job and if we haven't, we've @@ -384,7 +384,7 @@ RealtimeSimulatorImpl::ProcessOneEvent (void) } // - // We have got the event we're about to execute completely disentangled from the + // We have got the event we're about to execute completely disentangled from the // event list so we can execute it outside a critical section without fear of someone // changing things out from under us. @@ -395,7 +395,7 @@ RealtimeSimulatorImpl::ProcessOneEvent (void) event->Unref (); } -bool +bool RealtimeSimulatorImpl::IsFinished (void) const { bool rc; @@ -413,7 +413,7 @@ RealtimeSimulatorImpl::IsFinished (void) const uint64_t RealtimeSimulatorImpl::NextTs (void) const { - NS_ASSERT_MSG (m_events->IsEmpty () == false, + NS_ASSERT_MSG (m_events->IsEmpty () == false, "RealtimeSimulatorImpl::NextTs(): event queue is empty"); Scheduler::Event ev = m_events->PeekNext (); return ev.key.m_ts; @@ -424,11 +424,11 @@ RealtimeSimulatorImpl::Run (void) { NS_LOG_FUNCTION (this); - NS_ASSERT_MSG (m_running == false, + NS_ASSERT_MSG (m_running == false, "RealtimeSimulatorImpl::Run(): Simulator already running"); // Set the current threadId as the main threadId - m_main = SystemThread::Self(); + m_main = SystemThread::Self (); m_stop = false; m_running = true; @@ -437,8 +437,8 @@ RealtimeSimulatorImpl::Run (void) // Sleep until signalled uint64_t tsNow = 0; uint64_t tsDelay = 1000000000; // wait time of 1 second (in nanoseconds) - - while (!m_stop) + + while (!m_stop) { bool process = false; { @@ -454,7 +454,7 @@ RealtimeSimulatorImpl::Run (void) tsNow = m_synchronizer->GetCurrentRealtime (); } } - + if (!process) { // Sleep until signalled @@ -493,14 +493,14 @@ RealtimeSimulatorImpl::Realtime (void) const return m_synchronizer->Realtime (); } -void +void RealtimeSimulatorImpl::Stop (void) { NS_LOG_FUNCTION (this); m_stop = true; } -void +void RealtimeSimulatorImpl::Stop (Time const &delay) { NS_LOG_FUNCTION (this << delay); @@ -520,7 +520,7 @@ RealtimeSimulatorImpl::Schedule (Time const &delay, EventImpl *impl) CriticalSection cs (m_mutex); // // This is the reason we had to bring the absolute time calculation in from the - // simulator.h into the implementation. Since the implementations may be + // simulator.h into the implementation. Since the implementations may be // multi-threaded, we need this calculation to be atomic. You can see it is // here since we are running in a CriticalSection. // @@ -555,9 +555,9 @@ RealtimeSimulatorImpl::ScheduleWithContext (uint32_t context, Time const &delay, else { // - // If the simulator is running, we're pacing and have a meaningful + // If the simulator is running, we're pacing and have a meaningful // realtime clock. If we're not, then m_currentTs is where we stopped. - // + // ts = m_running ? m_synchronizer->GetCurrentRealtime () : m_currentTs; ts += delay.GetTimeStep (); } @@ -641,11 +641,11 @@ RealtimeSimulatorImpl::ScheduleRealtimeNowWithContext (uint32_t context, EventIm CriticalSection cs (m_mutex); // - // If the simulator is running, we're pacing and have a meaningful + // If the simulator is running, we're pacing and have a meaningful // realtime clock. If we're not, then m_currentTs is were we stopped. - // + // uint64_t ts = m_running ? m_synchronizer->GetCurrentRealtime () : m_currentTs; - NS_ASSERT_MSG (ts >= m_currentTs, + NS_ASSERT_MSG (ts >= m_currentTs, "RealtimeSimulatorImpl::ScheduleRealtimeNowWithContext(): schedule for time < m_currentTs"); Scheduler::Event ev; ev.impl = impl; @@ -682,8 +682,8 @@ RealtimeSimulatorImpl::ScheduleDestroy (EventImpl *impl) CriticalSection cs (m_mutex); // - // Time doesn't really matter here (especially in realtime mode). It is - // overridden by the uid of 2 which identifies this as an event to be + // Time doesn't really matter here (especially in realtime mode). It is + // overridden by the uid of 2 which identifies this as an event to be // executed at Simulator::Destroy time. // id = EventId (Ptr (impl, false), m_currentTs, 0xffffffff, 2); @@ -694,7 +694,7 @@ RealtimeSimulatorImpl::ScheduleDestroy (EventImpl *impl) return id; } -Time +Time RealtimeSimulatorImpl::GetDelayLeft (const EventId &id) const { // @@ -715,8 +715,8 @@ RealtimeSimulatorImpl::Remove (const EventId &id) if (id.GetUid () == 2) { // destroy events. - for (DestroyEvents::iterator i = m_destroyEvents.begin (); - i != m_destroyEvents.end (); + for (DestroyEvents::iterator i = m_destroyEvents.begin (); + i != m_destroyEvents.end (); i++) { if (*i == id) @@ -762,13 +762,13 @@ RealtimeSimulatorImpl::IsExpired (const EventId &id) const { if (id.GetUid () == 2) { - if (id.PeekEventImpl () == 0 || - id.PeekEventImpl ()->IsCancelled ()) + if (id.PeekEventImpl () == 0 + || id.PeekEventImpl ()->IsCancelled ()) { return true; } // destroy events. - for (DestroyEvents::const_iterator i = m_destroyEvents.begin (); + for (DestroyEvents::const_iterator i = m_destroyEvents.begin (); i != m_destroyEvents.end (); i++) { if (*i == id) @@ -780,17 +780,17 @@ RealtimeSimulatorImpl::IsExpired (const EventId &id) const } // - // If the time of the event is less than the current timestamp of the - // simulator, the simulator has gone past the invocation time of the - // event, so the statement ev.GetTs () < m_currentTs does mean that + // If the time of the event is less than the current timestamp of the + // simulator, the simulator has gone past the invocation time of the + // event, so the statement ev.GetTs () < m_currentTs does mean that // the event has been fired even in realtime mode. // // The same is true for the next line involving the m_currentUid. // - if (id.PeekEventImpl () == 0 || - id.GetTs () < m_currentTs || - (id.GetTs () == m_currentTs && id.GetUid () <= m_currentUid) || - id.PeekEventImpl ()->IsCancelled ()) + if (id.PeekEventImpl () == 0 + || id.GetTs () < m_currentTs + || (id.GetTs () == m_currentTs && id.GetUid () <= m_currentUid) + || id.PeekEventImpl ()->IsCancelled ()) { return true; } @@ -800,14 +800,14 @@ RealtimeSimulatorImpl::IsExpired (const EventId &id) const } } -Time +Time RealtimeSimulatorImpl::GetMaximumSimulationTime (void) const { return TimeStep (0x7fffffffffffffffLL); } // System ID for non-distributed simulation is always zero -uint32_t +uint32_t RealtimeSimulatorImpl::GetSystemId (void) const { return 0; @@ -825,7 +825,7 @@ RealtimeSimulatorImpl::GetEventCount (void) const return m_eventCount; } -void +void RealtimeSimulatorImpl::SetSynchronizationMode (enum SynchronizationMode mode) { NS_LOG_FUNCTION (this << mode); @@ -839,7 +839,7 @@ RealtimeSimulatorImpl::GetSynchronizationMode (void) const return m_synchronizationMode; } -void +void RealtimeSimulatorImpl::SetHardLimit (Time limit) { NS_LOG_FUNCTION (this << limit); diff --git a/src/core/model/realtime-simulator-impl.h b/src/core/model/realtime-simulator-impl.h index 3e9c21d97..269693be4 100644 --- a/src/core/model/realtime-simulator-impl.h +++ b/src/core/model/realtime-simulator-impl.h @@ -47,7 +47,7 @@ namespace ns3 { * * Realtime simulator implementation. */ - + /** * \ingroup realtime * @@ -65,13 +65,14 @@ public: /** * What to do when we can't maintain real time synchrony. */ - enum SynchronizationMode { + enum SynchronizationMode + { /** * Make a best effort to keep synced to real-time. * * If we fall behind, keep going. */ - SYNC_BEST_EFFORT, + SYNC_BEST_EFFORT, /** * Keep to real time within the hard limit tolerance configured * with SetHardLimit, or die trying. @@ -80,7 +81,7 @@ public: * a fatal error. * \see SetHardLimit */ - SYNC_HARD_LIMIT, + SYNC_HARD_LIMIT, }; /** Constructor. */ @@ -202,13 +203,13 @@ private: /**< Timestep of the current event. */ uint64_t m_currentTs; /**< Execution context. */ - uint32_t m_currentContext; + uint32_t m_currentContext; /** The event count. */ uint64_t m_eventCount; /**@}*/ - /** Mutex to control access to key state. */ - mutable SystemMutex m_mutex; + /** Mutex to control access to key state. */ + mutable SystemMutex m_mutex; /** The synchronizer in use to track real time. */ Ptr m_synchronizer; diff --git a/src/core/model/ref-count-base.h b/src/core/model/ref-count-base.h index 48f6bd661..cf6e007c4 100644 --- a/src/core/model/ref-count-base.h +++ b/src/core/model/ref-count-base.h @@ -43,7 +43,7 @@ namespace ns3 { * purely for compatibility to avoid breaking the code of users. */ class RefCountBase : public SimpleRefCount -{ +{ public: /** * This only thing this class does it declare a virtual destructor diff --git a/src/core/model/rng-seed-manager.cc b/src/core/model/rng-seed-manager.cc index 055e35206..7504c898e 100644 --- a/src/core/model/rng-seed-manager.cc +++ b/src/core/model/rng-seed-manager.cc @@ -49,9 +49,9 @@ static uint64_t g_nextStreamIndex = 0; * * This is accessible as "--RngSeed" from CommandLine. */ -static ns3::GlobalValue g_rngSeed ("RngSeed", +static ns3::GlobalValue g_rngSeed ("RngSeed", "The global seed of all rng streams", - ns3::UintegerValue(1), + ns3::UintegerValue (1), ns3::MakeUintegerChecker ()); /** * \relates RngSeedManager @@ -62,7 +62,7 @@ static ns3::GlobalValue g_rngSeed ("RngSeed", * * This is accessible as "--RngRun" from CommandLine. */ -static ns3::GlobalValue g_rngRun ("RngRun", +static ns3::GlobalValue g_rngRun ("RngRun", "The substream index used for all streams", ns3::UintegerValue (1), ns3::MakeUintegerChecker ()); @@ -75,11 +75,11 @@ uint32_t RngSeedManager::GetSeed (void) g_rngSeed.GetValue (seedValue); return static_cast (seedValue.Get ()); } -void +void RngSeedManager::SetSeed (uint32_t seed) { NS_LOG_FUNCTION (seed); - Config::SetGlobal ("RngSeed", UintegerValue(seed)); + Config::SetGlobal ("RngSeed", UintegerValue (seed)); } void RngSeedManager::SetRun (uint64_t run) @@ -93,7 +93,7 @@ uint64_t RngSeedManager::GetRun () NS_LOG_FUNCTION_NOARGS (); UintegerValue value; g_rngRun.GetValue (value); - uint64_t run = value.Get(); + uint64_t run = value.Get (); return run; } diff --git a/src/core/model/rng-seed-manager.h b/src/core/model/rng-seed-manager.h index 7b64d5f84..6b8f45f65 100644 --- a/src/core/model/rng-seed-manager.h +++ b/src/core/model/rng-seed-manager.h @@ -31,7 +31,7 @@ namespace ns3 { /** - * \ingroup randomvariable + * \ingroup randomvariable * * Manage the seed number and run number of the underlying * random number generator, and automatic assignment of stream numbers. @@ -61,10 +61,10 @@ public: /** * \brief Get the current seed value which will be used by all * subsequently instantiated RandomVariableStream objects. - * + * * \return The seed value. * - * This returns the current seed value. + * This returns the current seed value. */ static uint32_t GetSeed (void); @@ -103,7 +103,7 @@ public: * Get the next automatically assigned stream index. * \returns The next stream index. */ - static uint64_t GetNextStreamIndex(void); + static uint64_t GetNextStreamIndex (void); }; diff --git a/src/core/model/rng-stream.cc b/src/core/model/rng-stream.cc index abff6de4a..ec1afdc89 100644 --- a/src/core/model/rng-stream.cc +++ b/src/core/model/rng-stream.cc @@ -15,7 +15,7 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// Modified for ns-3 by: +// Modified for ns-3 by: // - Rajib Bhattacharjea // - Mathieu Lacage // @@ -33,7 +33,7 @@ */ namespace ns3 { - + // Note: Logging in this file is largely avoided due to the // number of calls that are made to these functions and the possibility // of causing recursions leading to stack overflow @@ -47,8 +47,9 @@ NS_LOG_COMPONENT_DEFINE ("RngStream"); * @{ */ /** Namespace for MRG32k3a implementation details. */ -namespace MRG32k3a -{ +namespace MRG32k3a { + +// *NS_CHECK_STYLE_OFF* /** Type for 3x3 matrix of doubles. */ typedef double Matrix[3][3]; @@ -58,28 +59,28 @@ const double m1 = 4294967087.0; /** Second component modulus, 232 - 22853. */ const double m2 = 4294944443.0; - + /** Normalization to obtain randoms on [0,1). */ const double norm = 1.0 / (m1 + 1.0); - + /** First component multiplier of n - 2 value. */ const double a12 = 1403580.0; - + /** First component multiplier of n - 3 value. */ const double a13n = 810728.0; - + /** Second component multiplier of n - 1 value. */ const double a21 = 527612.0; - + /** Second component multiplier of n - 3 value. */ const double a23n = 1370589.0; /** Decomposition factor for computing a*s in less than 53 bits, 217 */ const double two17 = 131072.0; - + /** IEEE-754 floating point precision, 253 */ const double two53 = 9007199254740992.0; - + /** First component transition matrix. */ const Matrix A1p0 = { { 0.0, 1.0, 0.0 }, @@ -324,11 +325,13 @@ void PowerOfTwoMatrix (int n, Matrix a1p, Matrix a2p) } // namespace MRG32k3a +// *NS_CHECK_STYLE_ON* + namespace ns3 { using namespace MRG32k3a; - + double RngStream::RandU01 () { int32_t k; @@ -342,7 +345,9 @@ double RngStream::RandU01 () { p1 += m1; } - m_currentState[0] = m_currentState[1]; m_currentState[1] = m_currentState[2]; m_currentState[2] = p1; + m_currentState[0] = m_currentState[1]; + m_currentState[1] = m_currentState[2]; + m_currentState[2] = p1; /* Component 2 */ p2 = a21 * m_currentState[5] - a23n * m_currentState[3]; @@ -352,7 +357,9 @@ double RngStream::RandU01 () { p2 += m2; } - m_currentState[3] = m_currentState[4]; m_currentState[4] = m_currentState[5]; m_currentState[5] = p2; + m_currentState[3] = m_currentState[4]; + m_currentState[4] = m_currentState[5]; + m_currentState[5] = p2; /* Combination */ u = ((p1 > p2) ? (p1 - p2) * norm : (p1 - p2 + m1) * norm); @@ -374,7 +381,7 @@ RngStream::RngStream (uint32_t seedNumber, uint64_t stream, uint64_t substream) AdvanceNthBy (substream, 76, m_currentState); } -RngStream::RngStream(const RngStream& r) +RngStream::RngStream (const RngStream& r) { for (int i = 0; i < 6; ++i) { @@ -382,7 +389,7 @@ RngStream::RngStream(const RngStream& r) } } -void +void RngStream::AdvanceNthBy (uint64_t nth, int by, double state[6]) { Matrix matrix1,matrix2; @@ -392,7 +399,7 @@ RngStream::AdvanceNthBy (uint64_t nth, int by, double state[6]) int bit = (nth >> nbit) & 0x1; if (bit) { - PowerOfTwoMatrix(by + nbit, matrix1, matrix2); + PowerOfTwoMatrix (by + nbit, matrix1, matrix2); MatVecModM (matrix1, state, state, m1); MatVecModM (matrix2, &state[3], &state[3], m2); } diff --git a/src/core/model/rng-stream.h b/src/core/model/rng-stream.h index 1218ceb52..4f8eb6466 100644 --- a/src/core/model/rng-stream.h +++ b/src/core/model/rng-stream.h @@ -34,7 +34,7 @@ namespace ns3 { * \ingroup randomvariable * \defgroup rngimpl RNG Implementation */ - + /** * \ingroup rngimpl * @@ -88,5 +88,5 @@ private: } // namespace ns3 #endif - + diff --git a/src/core/model/show-progress.cc b/src/core/model/show-progress.cc index b86e1d28d..eb96d90f7 100644 --- a/src/core/model/show-progress.cc +++ b/src/core/model/show-progress.cc @@ -37,7 +37,7 @@ namespace ns3 { -NS_LOG_COMPONENT_DEFINE ("ShowProgress"); +NS_LOG_COMPONENT_DEFINE ("ShowProgress"); ShowProgress::ShowProgress (const Time interval /* = Seconds (1.0) */, std::ostream & os /* = std::cout */) @@ -80,20 +80,20 @@ ShowProgress::SetVerbose (bool verbose) NS_LOG_FUNCTION (this << verbose); m_verbose = verbose; } - + void ShowProgress::SetStream (std::ostream & os) { m_os = &os; } - + void ShowProgress::Start (void) { NS_LOG_FUNCTION (this); m_event = Simulator::Schedule (m_vtime, &ShowProgress::Feedback, this); m_timer.Start (); - + } // ShowProgress::Start void @@ -113,7 +113,7 @@ ShowProgress::Feedback (void) // Speed: how fast are we compared to real time const int64x64_t speed = m_vtime / elapsed; - + // Ratio: how much real time did we use, // compared to reporting interval target const int64x64_t ratio = elapsed / m_interval; @@ -122,7 +122,7 @@ ShowProgress::Feedback (void) uint64_t events = Simulator::GetEventCount (); uint64_t nEvents = events - m_eventCount; m_eventCount = events; - + /** * \internal Update algorithm * @@ -141,32 +141,32 @@ ShowProgress::Feedback (void) * updates to \c m_vtime are sketched in this figure: * \verbatim ^ - | + | ratio | vtime update | - | + | | *= MAXGAIN - | + | MAXGAIN -|-------------- *= min (ratio, MAXGAIN) - | + | | *= ratio - | + | HYSTERESIS -|============================================= - | - | - | + | + | + | 1 -| No change - | - | + | + | | 1/ HYSTERESIS -|============================================== - | + | | *= ratio - | - 1/ MAXGAIN -|--------------- *= max (ratio, 1/ MAXGAIN) - | + | + 1/ MAXGAIN -|--------------- *= max (ratio, 1/ MAXGAIN) + | | *= 1/MAXGAIN - | + | \endverbatim * * As indicated, when ratio is outside the hysteresis band @@ -185,24 +185,24 @@ ShowProgress::Feedback (void) // Save stream state auto precision = m_os->precision (); auto flags = m_os->flags (); - + m_os->setf (std::ios::fixed, std:: ios::floatfield); if (m_verbose) { (*m_os) << m_repCount - << " [del: " << elapsed.As(Time::S) - << "/ int: " << m_interval.As(Time::S) - << " = rat: " << ratio + << " [del: " << elapsed.As (Time::S) + << "/ int: " << m_interval.As (Time::S) + << " = rat: " << ratio << (ratio > HYSTERESIS ? " up" : - (ratio < 1.0 / HYSTERESIS ? " dn" : " --")) - << ", vt: " << m_vtime.As(Time::S) << "] "; + (ratio < 1.0 / HYSTERESIS ? " dn" : " --")) + << ", vt: " << m_vtime.As (Time::S) << "] "; } m_repCount++; - + // Print the current time (*m_printer)(*m_os); - + (*m_os) << " (" << std::setprecision (3) << std::setw (8) << speed.GetDouble () << "x real time) " << nEvents << " events processed" @@ -218,5 +218,5 @@ ShowProgress::Feedback (void) } // ShowProgress::Feedback - + } // namespace ns3 diff --git a/src/core/model/show-progress.h b/src/core/model/show-progress.h index efc14405d..e6695625a 100644 --- a/src/core/model/show-progress.h +++ b/src/core/model/show-progress.h @@ -61,7 +61,7 @@ namespace ns3 { * Simulator::Destroy (); * } * \endcode - * + * * Based on a python version by Gustavo Carneiro , * as released here: * http://mailman.isi.edu/pipermail/ns-developers/2009-January/005201.html @@ -75,7 +75,7 @@ public: * \param [in] os The stream to print on. */ ShowProgress (const Time interval = Seconds (1.0), - std::ostream & os = std::cout); + std::ostream & os = std::cout); /** * Set the target update interval, in wallclock time. @@ -98,7 +98,7 @@ public: * \param [in] os The output stream; defaults to std::cerr. */ void SetStream (std::ostream & os); - + /** Start the progress timer. */ void Start (void); @@ -109,7 +109,6 @@ public: */ void SetVerbose (bool verbose); - private: /** Show execution progress. */ void Feedback (void); @@ -124,7 +123,7 @@ private: * \see Feedback() */ const int64x64_t MAXGAIN = 2.0; - + SystemWallClockMs m_timer; //!< Wallclock timer Time m_interval; //!< The target update interval, in wallclock time Time m_vtime; //!< The virtual time interval. @@ -135,9 +134,9 @@ private: std::ostream *m_os; //!< The output stream to use. bool m_verbose; //!< Verbose mode flag uint64_t m_repCount; //!< Count of progress lines printed - + }; // class ShowProgress - + } // namespace ns3 #endif /* SHOW_PROGRESS_H */ diff --git a/src/core/model/simple-ref-count.h b/src/core/model/simple-ref-count.h index f614bfadf..923194dec 100644 --- a/src/core/model/simple-ref-count.h +++ b/src/core/model/simple-ref-count.h @@ -44,7 +44,7 @@ namespace ns3 { * This template can be used to give reference-counting powers * to a class. This template does not require this class to * have a virtual destructor or a specific (or any) parent class. - * + * * \note If you are moving to this template from the RefCountBase class, * you need to be careful to mark appropriately your destructor virtual * if needed. i.e., if your class has subclasses, _do_ mark your destructor @@ -104,12 +104,12 @@ public: */ inline void Ref (void) const { - NS_ASSERT (m_count < std::numeric_limits::max()); + NS_ASSERT (m_count < std::numeric_limits::max ()); m_count++; } /** * Decrement the reference count. This method should not be called - * by user code. SimpleRefCount instances are expected to be used in + * by user code. SimpleRefCount instances are expected to be used in * conjunction with the Ptr template which would make calling Ref * unnecessary and dangerous. */ diff --git a/src/core/model/simulation-singleton.h b/src/core/model/simulation-singleton.h index a2b695d3b..c84803adb 100644 --- a/src/core/model/simulation-singleton.h +++ b/src/core/model/simulation-singleton.h @@ -51,10 +51,10 @@ public: * * \returns A pointer to the singleton instance. */ - static T *Get (void); - + static T * Get (void); + private: - + /** * Get the singleton object, creating a new one if it doesn't exist yet. * @@ -64,8 +64,8 @@ private: * * \returns The address of the pointer holding the static instance. */ - static T **GetObject (void); - + static T ** GetObject (void); + /** Delete the static instance. */ static void DeleteObject (void); @@ -79,7 +79,7 @@ private: /**@{*/ /** Default constructor */ SimulationSingleton (void); - + /** Copy constructor. */ SimulationSingleton (const SimulationSingleton &); /** diff --git a/src/core/model/simulator-impl.cc b/src/core/model/simulator-impl.cc index 35a9a36a2..d1a5a919a 100644 --- a/src/core/model/simulator-impl.cc +++ b/src/core/model/simulator-impl.cc @@ -31,8 +31,8 @@ namespace ns3 { NS_LOG_COMPONENT_DEFINE ("SimulatorImpl"); NS_OBJECT_ENSURE_REGISTERED (SimulatorImpl); - -TypeId + +TypeId SimulatorImpl::GetTypeId (void) { static TypeId tid = TypeId ("ns3::SimulatorImpl") diff --git a/src/core/model/simulator-impl.h b/src/core/model/simulator-impl.h index 6381d8439..afde956bc 100644 --- a/src/core/model/simulator-impl.h +++ b/src/core/model/simulator-impl.h @@ -48,7 +48,7 @@ class Scheduler; class SimulatorImpl : public Object { public: - + /** * Get the registered TypeId for this class. * \return The object TypeId. @@ -96,7 +96,7 @@ public: */ virtual void SetScheduler (ObjectFactory schedulerFactory) = 0; /** \copydoc Simulator::GetSystemId */ - virtual uint32_t GetSystemId () const = 0; + virtual uint32_t GetSystemId () const = 0; /** \copydoc Simulator::GetContext */ virtual uint32_t GetContext (void) const = 0; /** \copydoc Simulator::GetEventCount */ diff --git a/src/core/model/simulator.cc b/src/core/model/simulator.cc index edd1fb319..f0c467c16 100644 --- a/src/core/model/simulator.cc +++ b/src/core/model/simulator.cc @@ -60,10 +60,10 @@ NS_LOG_COMPONENT_DEFINE ("Simulator"); * Must be derived from SimulatorImpl. */ static GlobalValue g_simTypeImpl = GlobalValue - ("SimulatorImplementationType", - "The object class to use as the simulator implementation", - StringValue ("ns3::DefaultSimulatorImpl"), - MakeStringChecker ()); + ("SimulatorImplementationType", + "The object class to use as the simulator implementation", + StringValue ("ns3::DefaultSimulatorImpl"), + MakeStringChecker ()); /** * \ingroup scheduler @@ -81,7 +81,7 @@ static GlobalValue g_schedTypeImpl = GlobalValue ("SchedulerType", * \brief Get the static SimulatorImpl instance. * \return The SimulatorImpl instance pointer. */ -static SimulatorImpl **PeekImpl (void) +static SimulatorImpl ** PeekImpl (void) { static SimulatorImpl *impl = 0; return &impl; @@ -119,9 +119,9 @@ static SimulatorImpl * GetImpl (void) // // Note: we call LogSetTimePrinter _after_ creating the implementation -// object because the act of creation can trigger calls to the logging -// framework which would call the TimePrinter function which would call -// Simulator::Now which would call Simulator::GetImpl, and, thus, get us +// object because the act of creation can trigger calls to the logging +// framework which would call the TimePrinter function which would call +// Simulator::Now which would call Simulator::GetImpl, and, thus, get us // in an infinite recursion until the stack explodes. // LogSetTimePrinter (&DefaultTimePrinter); @@ -135,13 +135,13 @@ Simulator::Destroy (void) { NS_LOG_FUNCTION_NOARGS (); - SimulatorImpl **pimpl = PeekImpl (); + SimulatorImpl **pimpl = PeekImpl (); if (*pimpl == 0) { return; } /* Note: we have to call LogSetTimePrinter (0) below because if we do not do - * this, and restart a simulation after this call to Destroy, (which is + * this, and restart a simulation after this call to Destroy, (which is * legal), Simulator::GetImpl will trigger again an infinite recursion until * the stack explodes. */ @@ -159,14 +159,14 @@ Simulator::SetScheduler (ObjectFactory schedulerFactory) GetImpl ()->SetScheduler (schedulerFactory); } -bool +bool Simulator::IsFinished (void) { NS_LOG_FUNCTION_NOARGS (); return GetImpl ()->IsFinished (); } -void +void Simulator::Run (void) { NS_LOG_FUNCTION_NOARGS (); @@ -174,7 +174,7 @@ Simulator::Run (void) GetImpl ()->Run (); } -void +void Simulator::Stop (void) { NS_LOG_FUNCTION_NOARGS (); @@ -182,7 +182,7 @@ Simulator::Stop (void) GetImpl ()->Stop (); } -void +void Simulator::Stop (Time const &delay) { NS_LOG_FUNCTION (delay); @@ -229,7 +229,7 @@ Simulator::ScheduleDestroy (const Ptr &ev) { return DoScheduleDestroy (GetPointer (ev)); } -EventId +EventId Simulator::DoSchedule (Time const &time, EventImpl *impl) { #ifdef ENABLE_DES_METRICS @@ -237,7 +237,7 @@ Simulator::DoSchedule (Time const &time, EventImpl *impl) #endif return GetImpl ()->Schedule (time, impl); } -EventId +EventId Simulator::DoScheduleNow (EventImpl *impl) { #ifdef ENABLE_DES_METRICS @@ -245,7 +245,7 @@ Simulator::DoScheduleNow (EventImpl *impl) #endif return GetImpl ()->ScheduleNow (impl); } -EventId +EventId Simulator::DoScheduleDestroy (EventImpl *impl) { return GetImpl ()->ScheduleDestroy (impl); @@ -296,7 +296,7 @@ Simulator::Cancel (const EventId &id) return GetImpl ()->Cancel (id); } -bool +bool Simulator::IsExpired (const EventId &id) { if (*PeekImpl () == 0) @@ -311,7 +311,7 @@ Time Now (void) return Time (Simulator::Now ()); } -Time +Time Simulator::GetMaximumSimulationTime (void) { NS_LOG_FUNCTION_NOARGS (); @@ -323,11 +323,11 @@ Simulator::GetContext (void) { return GetImpl ()->GetContext (); } - + uint64_t Simulator::GetEventCount (void) { - return GetImpl ()-> GetEventCount (); + return GetImpl ()->GetEventCount (); } uint32_t @@ -362,9 +362,9 @@ Simulator::SetImplementation (Ptr impl) impl->SetScheduler (factory); // // Note: we call LogSetTimePrinter _after_ creating the implementation -// object because the act of creation can trigger calls to the logging -// framework which would call the TimePrinter function which would call -// Simulator::Now which would call Simulator::GetImpl, and, thus, get us +// object because the act of creation can trigger calls to the logging +// framework which would call the TimePrinter function which would call +// Simulator::Now which would call Simulator::GetImpl, and, thus, get us // in an infinite recursion until the stack explodes. // LogSetTimePrinter (&DefaultTimePrinter); diff --git a/src/core/model/simulator.h b/src/core/model/simulator.h index 23ea07e37..672afc1f0 100644 --- a/src/core/model/simulator.h +++ b/src/core/model/simulator.h @@ -45,27 +45,27 @@ class Scheduler; /** * @ingroup core * @defgroup simulator Simulator - * @brief Control the virtual time and the execution of simulation events. + * @brief Control the virtual time and the execution of simulation events. */ /** * @ingroup simulator * - * @brief Control the scheduling of simulation events. + * @brief Control the scheduling of simulation events. * * The internal simulation clock is maintained * as a 64-bit integer in a unit specified by the user * through the Time::SetResolution function. This means that it is * not possible to specify event expiration times with anything better * than this user-specified accuracy. Events whose expiration time is - * the same modulo this accuracy are scheduled in FIFO order: the - * first event inserted in the scheduling queue is scheduled to + * the same modulo this accuracy are scheduled in FIFO order: the + * first event inserted in the scheduling queue is scheduled to * expire first. - * + * * A simple example of how to use the Simulator class to schedule events * is shown in sample-simulator.cc: * @include src/core/examples/sample-simulator.cc */ -class Simulator +class Simulator { public: /** @@ -77,7 +77,7 @@ public: * can substitute in a new simulator implementation that might be multi- * threaded and synchronize events to a realtime clock. * - * The simulator implementation can be set when the simulator is not + * The simulator implementation can be set when the simulator is not * running. */ static void SetImplementation (Ptr impl); @@ -96,7 +96,7 @@ public: * LogSetNodePrinter() with the default implementations * since we can't really do any logging until we have * a SimulatorImpl and Scheduler. - + * @return The SimulatorImpl singleton. */ static Ptr GetImplementation (void); @@ -191,7 +191,8 @@ public: * This enum type is fixed to match the representation size * of simulation context. */ - enum : uint32_t { + enum : uint32_t + { /** * Flag for events not associated with any particular context. */ @@ -203,7 +204,7 @@ public: * \returns The total number of events executed. */ static uint64_t GetEventCount (void); - + /** * @name Schedule events (in the same context) to run at a future time. @@ -215,7 +216,7 @@ public: * for the current simulation time plus the @p delay passed as a * parameter. * - * When the event expires (when it becomes due to be run), the + * When the event expires (when it becomes due to be run), the * input method will be invoked on the input object. * * @tparam MEM @deduced Class method function signature type. @@ -273,7 +274,7 @@ public: * @param [in] a3 The third argument to pass to the invoked method * @returns The id for the scheduled event. */ - template static EventId Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3); @@ -294,7 +295,7 @@ public: * @param [in] a4 The fourth argument to pass to the invoked method * @returns The id for the scheduled event. */ - template static EventId Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4); @@ -317,9 +318,9 @@ public: * @param [in] a5 The fifth argument to pass to the invoked method * @returns The id for the scheduled event. */ - template - static EventId Schedule (Time const &delay, MEM mem_ptr, OBJ obj, + static EventId Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4, T5 a5); /** @@ -334,9 +335,9 @@ public: * @param a6 the sixth argument to pass to the invoked method * @returns an id for the scheduled event. */ - template - static EventId Schedule (Time const &time, MEM mem_ptr, OBJ obj, + static EventId Schedule (Time const &time, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6); /** @@ -418,7 +419,7 @@ public: * @param [in] a4 The fourth argument to pass to the function to invoke * @returns The id for the scheduled event. */ - template static EventId Schedule (Time const &delay, void (*f)(U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4); @@ -532,7 +533,7 @@ public: * @param [in] a2 The second argument to pass to the invoked method * @param [in] a3 The third argument to pass to the invoked method */ - template static void ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3); @@ -553,7 +554,7 @@ public: * @param [in] a3 The third argument to pass to the invoked method * @param [in] a4 The fourth argument to pass to the invoked method */ - template static void ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4); @@ -576,9 +577,9 @@ public: * @param [in] a4 The fourth argument to pass to the invoked method * @param [in] a5 The fifth argument to pass to the invoked method */ - template - static void ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj, + static void ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4, T5 a5); /** @@ -595,11 +596,11 @@ public: * @param a5 the fifth argument to pass to the invoked method * @param a6 the sixth argument to pass to the invoked method */ - template - static void ScheduleWithContext (uint32_t context, Time const &time, MEM mem_ptr, OBJ obj, + static void ScheduleWithContext (uint32_t context, Time const &time, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6); - + /** * Schedule an event with the given context. * A context of 0xffffffff means no context is specified. @@ -681,7 +682,7 @@ public: * @param [in] a3 The third argument to pass to the function to invoke * @param [in] a4 The fourth argument to pass to the function to invoke */ - template static void ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4); @@ -728,7 +729,7 @@ public: static void ScheduleWithContext (uint32_t context, Time const &time, void (*f)(U1,U2,U3,U4,U5,U6), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6); /** @} */ // Schedule events (in a different context) to run now or at a future time. - + /** * @name Schedule events (in the same context) to run now. */ @@ -736,7 +737,7 @@ public: /** * Schedule an event to expire Now. All events scheduled to * to expire "Now" are scheduled FIFO, after all normal events - * have expired. + * have expired. * * @tparam MEM @deduced Class method function signature type. * @tparam OBJ @deduced Class type of the object. @@ -757,7 +758,7 @@ public: * @param [in] a1 The first argument to pass to the invoked method * @return The EventId of the scheduled event. */ - template static EventId ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1); @@ -773,7 +774,7 @@ public: * @param [in] a2 The second argument to pass to the invoked method * @return The EventId of the scheduled event. */ - template static EventId ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2); @@ -791,7 +792,7 @@ public: * @param [in] a3 The third argument to pass to the invoked method * @return The EventId of the scheduled event. */ - template static EventId ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3); @@ -811,9 +812,9 @@ public: * @param [in] a4 The fourth argument to pass to the invoked method * @return The EventId of the scheduled event. */ - template - static EventId ScheduleNow (MEM mem_ptr, OBJ obj, + static EventId ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4); /** * @see ScheduleNow(MEM,OBJ) @@ -833,9 +834,9 @@ public: * @param [in] a5 The fifth argument to pass to the invoked method * @return The EventId of the scheduled event. */ - template - static EventId ScheduleNow (MEM mem_ptr, OBJ obj, + static EventId ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4, T5 a5); /** @@ -849,9 +850,9 @@ public: * @param a6 the sixth argument to pass to the invoked method * @return The EventId of the scheduled event. */ - template - static EventId ScheduleNow (MEM mem_ptr, OBJ obj, + static EventId ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6); /** @@ -976,8 +977,8 @@ public: /** @{ */ /** * Schedule an event to expire when Simulator::Destroy is called. - * All events scheduled to expire at "Destroy" time are scheduled FIFO, - * after all normal events have expired and only when + * All events scheduled to expire at "Destroy" time are scheduled FIFO, + * after all normal events have expired and only when * Simulator::Destroy is invoked. * * @tparam MEM @deduced Class method function signature type. @@ -999,7 +1000,7 @@ public: * @param [in] a1 The first argument to pass to the invoked method * @return The EventId of the scheduled event. */ - template static EventId ScheduleDestroy (MEM mem_ptr, OBJ obj, T1 a1); @@ -1033,7 +1034,7 @@ public: * @param [in] a3 The third argument to pass to the invoked method * @return The EventId of the scheduled event. */ - template static EventId ScheduleDestroy (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3); @@ -1053,9 +1054,9 @@ public: * @param [in] a4 The fourth argument to pass to the invoked method * @return The EventId of the scheduled event. */ - template - static EventId ScheduleDestroy (MEM mem_ptr, OBJ obj, + static EventId ScheduleDestroy (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4); /** * @see ScheduleDestroy(MEM,OBJ) @@ -1075,9 +1076,9 @@ public: * @param [in] a5 The fifth argument to pass to the invoked method * @return The EventId of the scheduled event. */ - template - static EventId ScheduleDestroy (MEM mem_ptr, OBJ obj, + static EventId ScheduleDestroy (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4, T5 a5); /** @@ -1091,9 +1092,9 @@ public: * @param a6 the sixth argument to pass to the invoked method * @return The EventId of the scheduled event. */ - template - static EventId ScheduleDestroy (MEM mem_ptr, OBJ obj, + static EventId ScheduleDestroy (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6); /** @@ -1212,11 +1213,11 @@ public: /** @} */ // Schedule events to run when Simulator:Destroy() is called. /** - * Remove an event from the event list. - * - * This method has the same visible effect as the + * Remove an event from the event list. + * + * This method has the same visible effect as the * ns3::EventId::Cancel method - * but its algorithmic complexity is much higher: it has often + * but its algorithmic complexity is much higher: it has often * O(log(n)) complexity, sometimes O(n), sometimes worse. * Note that it is not possible to remove events which were scheduled * for the "destroy" time. Doing so will result in a program error (crash). @@ -1229,13 +1230,13 @@ public: * Set the cancel bit on this event: the event's associated function * will not be invoked when it expires. * - * This method has the same visible effect as the - * ns3::Simulator::Remove method but its algorithmic complexity is + * This method has the same visible effect as the + * ns3::Simulator::Remove method but its algorithmic complexity is * much lower: it has O(1) complexity. * This method has the exact same semantics as ns3::EventId::Cancel. * Note that it is not possible to cancel events which were scheduled * for the "destroy" time. Doing so will result in a program error (crash). - * + * * @param [in] id the event to cancel */ static void Cancel (const EventId &id); @@ -1276,7 +1277,7 @@ public: /** * Get the maximum representable simulation time. * - * @return The maximum simulation time at which an event + * @return The maximum simulation time at which an event * can be scheduled. * * The returned value will always be bigger than or equal to Simulator::Now. @@ -1328,7 +1329,7 @@ public: * @return The system id for this simulator. */ static uint32_t GetSystemId (void); - + private: /** Default constructor. */ Simulator (); @@ -1354,7 +1355,7 @@ private: * @return The EventId. */ static EventId DoScheduleDestroy (EventImpl *event); - + }; // class Simulator /** @@ -1384,9 +1385,9 @@ namespace ns3 { // Doxygen has trouble with static template functions in a class: // it treats the in-class declaration as different from the // out of class definition, so makes two entries in the member list. Ugh - + template -EventId Simulator::Schedule (Time const &delay, MEM mem_ptr, OBJ obj) +EventId Simulator::Schedule (Time const &delay, MEM mem_ptr, OBJ obj) { return DoSchedule (delay, MakeEvent (mem_ptr, obj)); } @@ -1394,12 +1395,12 @@ EventId Simulator::Schedule (Time const &delay, MEM mem_ptr, OBJ obj) template -EventId Simulator::Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1) +EventId Simulator::Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1) { return DoSchedule (delay, MakeEvent (mem_ptr, obj, a1)); } -template EventId Simulator::Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2) { @@ -1408,30 +1409,30 @@ EventId Simulator::Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 template -EventId Simulator::Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3) +EventId Simulator::Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3) { return DoSchedule (delay, MakeEvent (mem_ptr, obj, a1, a2, a3)); } -template -EventId Simulator::Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4) +EventId Simulator::Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4) { return DoSchedule (delay, MakeEvent (mem_ptr, obj, a1, a2, a3, a4)); } -template -EventId Simulator::Schedule (Time const &delay, MEM mem_ptr, OBJ obj, - T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) +EventId Simulator::Schedule (Time const &delay, MEM mem_ptr, OBJ obj, + T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) { return DoSchedule (delay, MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5)); } -template -EventId Simulator::Schedule (Time const &time, MEM mem_ptr, OBJ obj, - T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6) +EventId Simulator::Schedule (Time const &time, MEM mem_ptr, OBJ obj, + T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6) { return DoSchedule (time, MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5, a6)); } @@ -1443,7 +1444,7 @@ EventId Simulator::Schedule (Time const &delay, void (*f)(U1), T1 a1) return DoSchedule (delay, MakeEvent (f, a1)); } -template EventId Simulator::Schedule (Time const &delay, void (*f)(U1,U2), T1 a1, T2 a2) { @@ -1575,58 +1576,58 @@ void Simulator::ScheduleWithContext (uint32_t context, Time const &time, void (* template EventId -Simulator::ScheduleNow (MEM mem_ptr, OBJ obj) +Simulator::ScheduleNow (MEM mem_ptr, OBJ obj) { return DoScheduleNow (MakeEvent (mem_ptr, obj)); } -template EventId -Simulator::ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1) +Simulator::ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1) { return DoScheduleNow (MakeEvent (mem_ptr, obj, a1)); } -template EventId -Simulator::ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2) +Simulator::ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2) { return DoScheduleNow (MakeEvent (mem_ptr, obj, a1, a2)); } -template EventId -Simulator::ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3) +Simulator::ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3) { return DoScheduleNow (MakeEvent (mem_ptr, obj, a1, a2, a3)); } -template EventId -Simulator::ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4) +Simulator::ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4) { return DoScheduleNow (MakeEvent (mem_ptr, obj, a1, a2, a3, a4)); } -template EventId -Simulator::ScheduleNow (MEM mem_ptr, OBJ obj, - T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) +Simulator::ScheduleNow (MEM mem_ptr, OBJ obj, + T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) { return DoScheduleNow (MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5)); } -template EventId -Simulator::ScheduleNow (MEM mem_ptr, OBJ obj, - T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6) +Simulator::ScheduleNow (MEM mem_ptr, OBJ obj, + T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6) { return DoScheduleNow (MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5, a6)); } @@ -1682,32 +1683,32 @@ Simulator::ScheduleNow (void (*f)(U1,U2,U3,U4,U5,U6), T1 a1, T2 a2, T3 a3, T4 a4 template EventId -Simulator::ScheduleDestroy (MEM mem_ptr, OBJ obj) +Simulator::ScheduleDestroy (MEM mem_ptr, OBJ obj) { return DoScheduleDestroy (MakeEvent (mem_ptr, obj)); } -template EventId -Simulator::ScheduleDestroy (MEM mem_ptr, OBJ obj, T1 a1) +Simulator::ScheduleDestroy (MEM mem_ptr, OBJ obj, T1 a1) { return DoScheduleDestroy (MakeEvent (mem_ptr, obj, a1)); } -template EventId -Simulator::ScheduleDestroy (MEM mem_ptr, OBJ obj, T1 a1, T2 a2) +Simulator::ScheduleDestroy (MEM mem_ptr, OBJ obj, T1 a1, T2 a2) { return DoScheduleDestroy (MakeEvent (mem_ptr, obj, a1, a2)); } -template EventId -Simulator::ScheduleDestroy (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3) +Simulator::ScheduleDestroy (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3) { return DoScheduleDestroy (MakeEvent (mem_ptr, obj, a1, a2, a3)); } @@ -1715,25 +1716,25 @@ Simulator::ScheduleDestroy (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3) template EventId -Simulator::ScheduleDestroy (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4) +Simulator::ScheduleDestroy (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4) { return DoScheduleDestroy (MakeEvent (mem_ptr, obj, a1, a2, a3, a4)); } -template EventId -Simulator::ScheduleDestroy (MEM mem_ptr, OBJ obj, - T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) +Simulator::ScheduleDestroy (MEM mem_ptr, OBJ obj, + T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) { return DoScheduleDestroy (MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5)); } -template EventId -Simulator::ScheduleDestroy (MEM mem_ptr, OBJ obj, - T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6) +Simulator::ScheduleDestroy (MEM mem_ptr, OBJ obj, + T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6) { return DoScheduleDestroy (MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5, a6)); } diff --git a/src/core/model/singleton.h b/src/core/model/singleton.h index 8983da847..f6a2654a1 100644 --- a/src/core/model/singleton.h +++ b/src/core/model/singleton.h @@ -71,7 +71,7 @@ public: * * \return A pointer to the singleton instance. */ - static T *Get (void); + static T * Get (void); }; diff --git a/src/core/model/synchronizer.cc b/src/core/model/synchronizer.cc index 5243a47a1..b84219794 100644 --- a/src/core/model/synchronizer.cc +++ b/src/core/model/synchronizer.cc @@ -31,7 +31,7 @@ NS_LOG_COMPONENT_DEFINE ("Synchronizer"); NS_OBJECT_ENSURE_REGISTERED (Synchronizer); -TypeId +TypeId Synchronizer::GetTypeId (void) { static TypeId tid = TypeId ("ns3::Synchronizer") @@ -88,10 +88,12 @@ Synchronizer::GetDrift (uint64_t ts) NS_LOG_FUNCTION (this << ts); int64_t tDrift = DoGetDrift (TimeStepToNanosecond (ts)); - if (tDrift < 0) + if (tDrift < 0) { return -static_cast (NanosecondToTimeStep (-tDrift)); - } else { + } + else + { return static_cast (NanosecondToTimeStep (tDrift)); } } @@ -100,7 +102,7 @@ bool Synchronizer::Synchronize (uint64_t tsCurrent, uint64_t tsDelay) { NS_LOG_FUNCTION (this << tsCurrent << tsDelay); - return DoSynchronize (TimeStepToNanosecond (tsCurrent), + return DoSynchronize (TimeStepToNanosecond (tsCurrent), TimeStepToNanosecond (tsDelay)); } diff --git a/src/core/model/synchronizer.h b/src/core/model/synchronizer.h index 2bab776f5..e0e34a46f 100644 --- a/src/core/model/synchronizer.h +++ b/src/core/model/synchronizer.h @@ -48,7 +48,7 @@ namespace ns3 { * is maintained using a combination of sleep-waiting, busy-waiting and a * feedback loop. */ -class Synchronizer : public Object +class Synchronizer : public Object { public: /** @@ -86,7 +86,7 @@ public: * synchronizer real time. * * This method is expected to be called at the "instant" before simulation - * begins. At this point, simulation time = 0, and a + * begins. At this point, simulation time = 0, and a * set = 0 in this method. We then associate this time with the current * value of the real time clock that will be used to actually perform the * synchronization. @@ -102,7 +102,7 @@ public: void SetOrigin (uint64_t ts); /** - * @brief Retrieve the value of the origin of the simulation time in + * @brief Retrieve the value of the origin of the simulation time in * Time.resolution units. * * @returns The simulation time used as the origin (in Time resolution units). @@ -111,7 +111,7 @@ public: uint64_t GetOrigin (void); /** - * @brief Retrieve the difference between the real time clock used to + * @brief Retrieve the difference between the real time clock used to * synchronize the simulation and the simulation time (in * Time resolution units). * @@ -134,7 +134,7 @@ public: * to wait until that synchronizer / simulation time comes around. * * Subclasses are expected to implement the corresponding DoSynchronize pure - * virtual method to do the actual real-time-clock-specific work of waiting + * virtual method to do the actual real-time-clock-specific work of waiting * (either busy-waiting or sleeping, or some combination thereof) until the * requested simulation time. * @@ -161,7 +161,7 @@ public: void Signal (void); /** - * @brief Set the condition variable that tells a possible simulator thread + * @brief Set the condition variable that tells a possible simulator thread * waiting in the Synchronize method that an event has happened which demands * a reevaluation of the wait time. * @@ -193,7 +193,7 @@ public: protected: /** - * @brief Establish a correspondence between a simulation time and a + * @brief Establish a correspondence between a simulation time and a * wall-clock (real) time. * * There are three timelines involved here: the simulation (virtual) time, @@ -207,10 +207,10 @@ protected: * value of the real time clock that will be used to actually perform the * synchronization. * - * Subclasses are expected to implement this method to do the actual + * Subclasses are expected to implement this method to do the actual * real-time-clock-specific work of making the correspondence mentioned above. * for example, this is where the differences between Time parameters and - * parameters to clock_nanosleep would be dealt with. + * parameters to clock_nanosleep would be dealt with. * * @param [in] ns The simulation time we need to use as the origin (normalized to * nanosecond units). @@ -259,7 +259,7 @@ protected: * or some combination) until the requested simulation time. * * @param [in] nsCurrent The current simulation time (in nanosecond units). - * @param [in] nsDelay The simulation time we need to wait for (normalized to + * @param [in] nsDelay The simulation time we need to wait for (normalized to * nanosecond units). * @returns @c true if the function ran to completion, * @c false if it was interrupted by a Signal. diff --git a/src/core/model/system-condition.h b/src/core/model/system-condition.h index 91cd9de82..7485c8451 100644 --- a/src/core/model/system-condition.h +++ b/src/core/model/system-condition.h @@ -35,12 +35,12 @@ namespace ns3 { * * System-independent interfaces to threads, signal conditions, and mutex. */ - + class SystemConditionPrivate; /** * @ingroup thread - * @brief A class which provides a relatively platform-independent + * @brief A class which provides a relatively platform-independent * conditional-wait thread synchronization primitive. * * It is often desirable to have a mechanism by which a thread can suspend its @@ -50,10 +50,10 @@ class SystemConditionPrivate; * * There are two ways to tell the underlying primitive that the condition has * become true: Signal and Broadcast. Signal will only wake up one thread - * waiting on the condition (according to the OS scheduling policy); - * Broadcast will wake up all of the threads waiting on the condition + * waiting on the condition (according to the OS scheduling policy); + * Broadcast will wake up all of the threads waiting on the condition * (cf. "The Thundering Herd"). - * + * * In order to wait for the underlying condition, you also have two * alternatives: Wait and TimedWait. The Wait call will wait forever for the * condition to become true; but the TimedWait has a timeout. @@ -61,11 +61,11 @@ class SystemConditionPrivate; * The condition underlying this class is a simple boolean variable. It is * set to false in each call to Wait and TimedWait. It is set to true in each * call to Signal and Broadcast. This is a fairly simple-minded condition - * designed for + * designed for * * A typical use case will be to call Wait() or TimedWait() in one thread - * context and put the processor to sleep until an event happens somewhere - * else that + * context and put the processor to sleep until an event happens somewhere + * else that */ class SystemCondition { @@ -86,14 +86,14 @@ public: bool GetCondition (void); /** - * Release one thread if waiting for the condition to be true. If you want + * Release one thread if waiting for the condition to be true. If you want * a waiting thread to return, you should have done a SetCondition (true) * prior to calling. */ void Signal (void); /** - * Release all threads waiting for the condition to be true. If you want + * Release all threads waiting for the condition to be true. If you want * all waiting threads to return, you should have done a SetCondition (true) * prior to calling. */ @@ -103,7 +103,7 @@ public: * Wait, possibly forever, for the condition to be true. */ void Wait (void); - + /** * Wait a maximum of ns nanoseconds for the condition to be true. If the * wait times out, return true else return false. @@ -111,7 +111,6 @@ public: * @returns \c true if the timer expired, otherwise return \c false. */ bool TimedWait (uint64_t ns); - private: /** The (system-dependent) implementation. */ diff --git a/src/core/model/system-mutex.h b/src/core/model/system-mutex.h index 41224f344..974dc43ad 100644 --- a/src/core/model/system-mutex.h +++ b/src/core/model/system-mutex.h @@ -30,8 +30,8 @@ * and ns3::CriticalSection. */ -namespace ns3 { - +namespace ns3 { + class SystemMutexPrivate; /** @@ -45,17 +45,17 @@ class SystemMutexPrivate; * primitive to provide that capability. We provide platform-independent * access to the OS-dependent capability with the SystemMutex class. * - * There are two operations: Lock and Unlock. Lock allows an executing - * SystemThread to attempt to acquire ownership of the Mutual Exclusion + * There are two operations: Lock and Unlock. Lock allows an executing + * SystemThread to attempt to acquire ownership of the Mutual Exclusion * object. If the SystemMutex object is not owned by another thread, then - * ownership is granted to the calling SystemThread and Lock returns + * ownership is granted to the calling SystemThread and Lock returns * immediately, However, if the SystemMutex is already owned by another * SystemThread, the calling SystemThread is blocked until the current owner * releases the SystemMutex by calling Unlock. * * @see CriticalSection */ -class SystemMutex +class SystemMutex { public: SystemMutex (); @@ -70,7 +70,7 @@ public: * Release ownership of the Mutual Exclusion object. */ void Unlock (); - + private: /** The (system-dependent) implementation. */ SystemMutexPrivate * m_priv; @@ -93,8 +93,8 @@ private: * ... * } * @endcode - * In this case, the critical section is entered when the CriticalSection - * object is created, and the critical section is exited when the + * In this case, the critical section is entered when the CriticalSection + * object is created, and the critical section is exited when the * CriticalSection object goes out of scope at the end of the method. * * Finer granularity is achieved by using local scope blocks. @@ -126,6 +126,7 @@ public: CriticalSection (SystemMutex &mutex); /** Destructor */ ~CriticalSection (); + private: SystemMutex &m_mutex; /**< The mutex. */ }; diff --git a/src/core/model/system-path.cc b/src/core/model/system-path.cc index 1a4cbbac3..c27a69cec 100644 --- a/src/core/model/system-path.cc +++ b/src/core/model/system-path.cc @@ -81,7 +81,7 @@ namespace SystemPath { * * This is an internal function (by virtue of not being * declared in a \c .h file); the public API is FindSelfDirectory(). - * + * * \param [in] path The full path to a file. * \returns The full path to the containing directory. */ @@ -89,14 +89,14 @@ std::string Dirname (std::string path) { NS_LOG_FUNCTION (path); std::list elements = Split (path); - std::list::const_iterator last = elements.end(); + std::list::const_iterator last = elements.end (); last--; return Join (elements.begin (), last); } std::string FindSelfDirectory (void) { - /** + /** * This function returns the path to the running $PREFIX. * Mac OS X: _NSGetExecutablePath() (man 3 dyld) * Linux: readlink /proc/self/exe @@ -115,7 +115,7 @@ std::string FindSelfDirectory (void) int status; while (true) { - status = readlink("/proc/self/exe", buffer, size); + status = readlink ("/proc/self/exe", buffer, size); if (status != 1 || (status == -1 && errno != ENAMETOOLONG)) { break; @@ -123,7 +123,7 @@ std::string FindSelfDirectory (void) size *= 2; free (buffer); buffer = (char*)malloc (size); - memset (buffer, 0, size); + memset (buffer, 0, size); } if (status == -1) { @@ -142,10 +142,10 @@ std::string FindSelfDirectory (void) DWORD status = GetModuleFilename (0, lpFilename, size); while (status == size) { - size = size * 2; - free (lpFilename); - lpFilename = (LPTSTR) malloc (sizeof(TCHAR) * size); - status = GetModuleFilename (0, lpFilename, size); + size = size * 2; + free (lpFilename); + lpFilename = (LPTSTR) malloc (sizeof(TCHAR) * size); + status = GetModuleFilename (0, lpFilename, size); } NS_ASSERT (status != 0); filename = lpFilename; @@ -159,32 +159,32 @@ std::string FindSelfDirectory (void) int status = _NSGetExecutablePath (buffer, &bufsize); if (status == -1) { - free (buffer); - buffer = (char *) malloc (bufsize); - status = _NSGetExecutablePath (buffer, &bufsize); + free (buffer); + buffer = (char *) malloc (bufsize); + status = _NSGetExecutablePath (buffer, &bufsize); } NS_ASSERT (status == 0); filename = buffer; free (buffer); - } + } #elif defined (__FreeBSD__) { int mib[4]; std::size_t bufSize = 1024; - char *buf = (char *) malloc(bufSize); + char *buf = (char *) malloc (bufSize); mib[0] = CTL_KERN; mib[1] = KERN_PROC; mib[2] = KERN_PROC_PATHNAME; mib[3] = -1; - sysctl(mib, 4, buf, &bufSize, NULL, 0); + sysctl (mib, 4, buf, &bufSize, NULL, 0); filename = buf; } #endif - return Dirname (filename); + return Dirname (filename); } - + std::string Append (std::string left, std::string right) { // removing trailing separators from 'left' @@ -193,11 +193,11 @@ std::string Append (std::string left, std::string right) { std::string::size_type lastSep = left.rfind (SYSTEM_PATH_SEP); if (lastSep != left.size () - 1) - { - break; - } + { + break; + } left = left.substr (0, left.size () - 1); - } + } std::string retval = left + SYSTEM_PATH_SEP + right; return retval; } @@ -221,24 +221,24 @@ std::list Split (std::string path) } std::string Join (std::list::const_iterator begin, - std::list::const_iterator end) + std::list::const_iterator end) { NS_LOG_FUNCTION (&begin << &end); std::string retval = ""; for (std::list::const_iterator i = begin; i != end; i++) { if (i == begin) - { - retval = *i; - } + { + retval = *i; + } else - { - retval = retval + SYSTEM_PATH_SEP + *i; - } + { + retval = retval + SYSTEM_PATH_SEP + *i; + } } return retval; } - + std::list ReadFiles (std::string path) { NS_LOG_FUNCTION (path); @@ -260,7 +260,7 @@ std::list ReadFiles (std::string path) /** \todo untested */ HANDLE hFind; WIN32_FIND_DATA fileData; - + hFind = FindFirstFile (path.c_str (), &FindFileData); if (hFind == INVALID_HANDLE_VALUE) { @@ -269,15 +269,16 @@ std::list ReadFiles (std::string path) do { files.push_back (fileData.cFileName); - } while (FindNextFile (hFind, &fileData)); - FindClose(hFind); + } + while (FindNextFile (hFind, &fileData)); + FindClose (hFind); #else #error "No support for reading a directory on this platform" #endif return files; } -std::string +std::string MakeTemporaryDirectoryName (void) { NS_LOG_FUNCTION_NOARGS (); @@ -288,9 +289,9 @@ MakeTemporaryDirectoryName (void) { path = getenv ("TEMP"); if (path == NULL) - { - path = const_cast ("/tmp"); - } + { + path = const_cast ("/tmp"); + } } // @@ -308,10 +309,10 @@ MakeTemporaryDirectoryName (void) // // The final path to the directory is going to look something like - // + // // /tmp/ns3-14.30.29.32767 // - // The first segment comes from one of the temporary directory env + // The first segment comes from one of the temporary directory env // variables or /tmp if not found. The directory name starts with an // identifier telling folks who is making all of the temp directories // and then the local time (in this case 14.30.29 -- which is 2:30 and @@ -324,7 +325,7 @@ MakeTemporaryDirectoryName (void) return oss.str (); } -void +void MakeDirectories (std::string path) { NS_LOG_FUNCTION (path); @@ -344,7 +345,7 @@ MakeDirectories (std::string path) ++i; // Now points to one past the directory we want to create std::string tmp = Join (elements.begin (), i); bool makeDirErr = false; - + #if defined(HAVE_MKDIR_H) makeDirErr = mkdir (tmp.c_str (), S_IRWXU); #endif diff --git a/src/core/model/system-path.h b/src/core/model/system-path.h index 8d7abc264..b9bb111de 100644 --- a/src/core/model/system-path.h +++ b/src/core/model/system-path.h @@ -47,80 +47,80 @@ namespace ns3 { */ namespace SystemPath { - /** - * \ingroup systempath - * Get the file system path to the current executable. - * - * \return The directory in which the currently-executing binary is located - */ - std::string FindSelfDirectory (void); - - /** - * \ingroup systempath - * Join two file system path elements. - * - * \param [in] left A path element - * \param [in] right A path element - * \return A concatenation of the two input paths - */ - std::string Append (std::string left, std::string right); +/** + * \ingroup systempath + * Get the file system path to the current executable. + * + * \return The directory in which the currently-executing binary is located + */ +std::string FindSelfDirectory (void); - /** - * \ingroup systempath - * Split a file system path into directories according to - * the local path separator. - * - * This is the inverse of Join. - * - * \param [in] path A path - * \return A list of path elements that can be joined together again with - * the Join function. - * \sa ns3::SystemPath::Join - */ - std::list Split (std::string path); +/** + * \ingroup systempath + * Join two file system path elements. + * + * \param [in] left A path element + * \param [in] right A path element + * \return A concatenation of the two input paths + */ +std::string Append (std::string left, std::string right); - /** - * Join a list of file system path directories into a single - * file system path. - * - * This is the inverse of Split. - * - * \ingroup systempath - * \param [in] begin Iterator to first element to join - * \param [in] end Iterator to one past the last element to join - * \return A path that is a concatenation of all the input elements. - */ - std::string Join (std::list::const_iterator begin, - std::list::const_iterator end); - - /** - * \ingroup systempath - * Get the list of files located in a file system directory. - * - * \param [in] path A path which identifies a directory - * \return A list of the filenames which are located in the input directory - */ - std::list ReadFiles (std::string path); +/** + * \ingroup systempath + * Split a file system path into directories according to + * the local path separator. + * + * This is the inverse of Join. + * + * \param [in] path A path + * \return A list of path elements that can be joined together again with + * the Join function. + * \sa ns3::SystemPath::Join + */ +std::list Split (std::string path); - /** - * \ingroup systempath - * Get the name of a temporary directory. - * - * The returned path identifies a directory which does not exist yet. - * Call ns3::SystemPath::MakeDirectories to create it. Yes, there is a - * well-known security race in this API but we don't care in ns-3. - * - * \return A path which identifies a temporary directory. - */ - std::string MakeTemporaryDirectoryName (void); +/** + * Join a list of file system path directories into a single + * file system path. + * + * This is the inverse of Split. + * + * \ingroup systempath + * \param [in] begin Iterator to first element to join + * \param [in] end Iterator to one past the last element to join + * \return A path that is a concatenation of all the input elements. + */ +std::string Join (std::list::const_iterator begin, + std::list::const_iterator end); - /** - * \ingroup systempath - * Create all the directories leading to path. - * - * \param [in] path A path to a directory - */ - void MakeDirectories (std::string path); +/** + * \ingroup systempath + * Get the list of files located in a file system directory. + * + * \param [in] path A path which identifies a directory + * \return A list of the filenames which are located in the input directory + */ +std::list ReadFiles (std::string path); + +/** + * \ingroup systempath + * Get the name of a temporary directory. + * + * The returned path identifies a directory which does not exist yet. + * Call ns3::SystemPath::MakeDirectories to create it. Yes, there is a + * well-known security race in this API but we don't care in ns-3. + * + * \return A path which identifies a temporary directory. + */ +std::string MakeTemporaryDirectoryName (void); + +/** + * \ingroup systempath + * Create all the directories leading to path. + * + * \param [in] path A path to a directory + */ +void MakeDirectories (std::string path); } // namespace SystemPath diff --git a/src/core/model/system-thread.cc b/src/core/model/system-thread.cc index d87d5aa38..0fca99f40 100644 --- a/src/core/model/system-thread.cc +++ b/src/core/model/system-thread.cc @@ -41,7 +41,7 @@ SystemThread::SystemThread (Callback callback) NS_LOG_FUNCTION (this << &callback); } -SystemThread::~SystemThread() +SystemThread::~SystemThread () { NS_LOG_FUNCTION (this); } @@ -54,9 +54,9 @@ SystemThread::Start (void) int rc = pthread_create (&m_thread, NULL, &SystemThread::DoRun, (void *)this); - if (rc) + if (rc) { - NS_FATAL_ERROR ("pthread_create failed: " << rc << "=\"" << + NS_FATAL_ERROR ("pthread_create failed: " << rc << "=\"" << strerror (rc) << "\"."); } } @@ -68,9 +68,9 @@ SystemThread::Join (void) void *thread_return; int rc = pthread_join (m_thread, &thread_return); - if (rc) + if (rc) { - NS_FATAL_ERROR ("pthread_join failed: " << rc << "=\"" << + NS_FATAL_ERROR ("pthread_join failed: " << rc << "=\"" << strerror (rc) << "\"."); } } @@ -85,14 +85,14 @@ SystemThread::DoRun (void *arg) return 0; } -SystemThread::ThreadId +SystemThread::ThreadId SystemThread::Self (void) { NS_LOG_FUNCTION_NOARGS (); return pthread_self (); } -bool +bool SystemThread::Equals (SystemThread::ThreadId id) { NS_LOG_FUNCTION (id); diff --git a/src/core/model/system-thread.h b/src/core/model/system-thread.h index 359c8d030..37a30025d 100644 --- a/src/core/model/system-thread.h +++ b/src/core/model/system-thread.h @@ -33,7 +33,7 @@ * System-independent thread class ns3::SystemThread declaration. */ -namespace ns3 { +namespace ns3 { /** * @ingroup thread @@ -41,12 +41,12 @@ namespace ns3 { * primitive. * * This class allows for creation of multiple threads of execution in a - * process. The exact implementation of the thread functionality is - * operating system dependent, but typically in ns-3 one is using an + * process. The exact implementation of the thread functionality is + * operating system dependent, but typically in ns-3 one is using an * environment in which Posix Threads are supported (either natively or - * in the case of Windows via Cygwin's implementation of pthreads on the + * in the case of Windows via Cygwin's implementation of pthreads on the * Win32 API. In either case we expect that these will be kernel-level - * threads and therefore a system with multiple CPUs will see truly concurrent + * threads and therefore a system with multiple CPUs will see truly concurrent * execution. * * Synchronization between threads is provided via the SystemMutex class. @@ -66,7 +66,7 @@ public: * @brief Create a SystemThread object. * * A system thread object is not created running. A thread of execution - * must be explicitly started by calling the Start method. When the + * must be explicitly started by calling the Start method. When the * Start method is called, it will spawn a thread of execution and cause * that thread to call out into the callback function provided here as * a parameter. @@ -99,7 +99,7 @@ public: * @endcode * * Object lifetime is always an issue with threads, so it is common to use - * smart pointers. If you are spinning up a thread in an object that is + * smart pointers. If you are spinning up a thread in an object that is * managed by a smart pointer, you can use that pointer directly: * @code * Ptr myPtr = Create (); @@ -108,12 +108,12 @@ public: * st->Start (); * @endcode * - * Just like any thread, you can synchronize with its termination. The + * Just like any thread, you can synchronize with its termination. The * method provided to do this is Join(). If you call Join() you will block * until the SystemThread run method returns. * * @param [in] callback entry point of the thread - * + * * @warning I've made the system thread class look like a normal ns3 object * with smart pointers, and living in the heap. This makes it very easy to * manage threads from a single master thread context. You should be very @@ -123,13 +123,13 @@ public: * atomic operation. CREATE AND MANAGE YOUR THREADS IN ONE PLACE -- LEAVE * THE PTR THERE. */ - SystemThread(Callback callback); + SystemThread (Callback callback); /** * @brief Destroy a SystemThread object. * */ - ~SystemThread(); + ~SystemThread (); /** * @brief Start a thread of execution, running the provided callback. @@ -137,16 +137,16 @@ public: void Start (void); /** - * @brief Suspend the caller until the thread of execution, running the + * @brief Suspend the caller until the thread of execution, running the * provided callback, finishes. */ void Join (void); /** * @brief Returns the current thread Id. * - * @returns Current thread Id. + * @returns Current thread Id. */ - static ThreadId Self(void); + static ThreadId Self (void); /** * @brief Compares an ThreadId with the current ThreadId . @@ -154,7 +154,7 @@ public: * @param [in] id The ThreadId to compare to. * @returns @c true if @c id matches the current ThreadId. */ - static bool Equals(ThreadId id); + static bool Equals (ThreadId id); private: #ifdef HAVE_PTHREAD_H @@ -164,11 +164,11 @@ private: * @param [in] arg This SystemThread instance to communicate to the newly * launched thread. */ - static void *DoRun (void *arg); + static void * DoRun (void *arg); Callback m_callback; /**< The main function for this thread when launched. */ pthread_t m_thread; /**< The thread id of the child thread. */ -#endif +#endif }; } // namespace ns3 diff --git a/src/core/model/system-wall-clock-ms.h b/src/core/model/system-wall-clock-ms.h index 9019e76bb..a0a39c78c 100644 --- a/src/core/model/system-wall-clock-ms.h +++ b/src/core/model/system-wall-clock-ms.h @@ -50,7 +50,8 @@ namespace ns3 { * \ingroup system * \brief Measure elapsed wall clock time in milliseconds. */ -class SystemWallClockMs { +class SystemWallClockMs +{ public: SystemWallClockMs (); ~SystemWallClockMs (); @@ -61,7 +62,7 @@ public: void Start (void); /** * \brief Stop measuring the time since Start() was called. - * \returns the measured elapsed wall clock time (in milliseconds) since + * \returns the measured elapsed wall clock time (in milliseconds) since * Start() was invoked. * * It is possible to start a new measurement with Start() after @@ -72,7 +73,7 @@ public: int64_t End (void); /** - * \returns the measured elapsed wall clock time (in milliseconds) since + * \returns the measured elapsed wall clock time (in milliseconds) since * Start() was invoked. * * Returns \c int64_t to avoid dependency on \c clock_t in ns-3 code. diff --git a/src/core/model/test.cc b/src/core/model/test.cc index 9442c9b75..726d7bee8 100644 --- a/src/core/model/test.cc +++ b/src/core/model/test.cc @@ -66,7 +66,7 @@ TestDoubleIsEqual (const double x1, const double x2, const double epsilon) return false; } return true; -} +} /** * \ingroup testingimpl @@ -84,8 +84,8 @@ struct TestCaseFailure * \param [in] _file The source file. * \param [in] _line The source line. */ - TestCaseFailure (std::string _cond, std::string _actual, - std::string _limit, std::string _message, + TestCaseFailure (std::string _cond, std::string _actual, + std::string _limit, std::string _message, std::string _file, int32_t _line); std::string cond; /**< The name of the condition being tested. */ std::string actual; /**< The actual value returned by the test. */ @@ -107,7 +107,7 @@ std::ostream & operator << (std::ostream & os, const TestCaseFailure & failure) << "\" actual=\"" << failure.actual << "\" limit=\"" << failure.limit << "\" in=\"" << failure.file - << ":" << failure.line + << ":" << failure.line << "\" " << failure.message; return os; @@ -140,7 +140,7 @@ class TestRunnerImpl : public Singleton public: /** Constructor. */ TestRunnerImpl (); - + /** * Add a new top-level TestSuite. * \param [in] testSuite The new TestSuite. @@ -184,7 +184,7 @@ private: * Clean up characters not allowed in XML. * * XML files have restrictions on certain characters that may be present in - * data. We need to replace these characters with their alternate + * data. We need to replace these characters with their alternate * representation on the way into the XML file. * * Specifically, we make these replacements: @@ -216,7 +216,7 @@ private: * \param [in] end Iterator to the end of the list. * \param [in] printTestType Preprend the test type label if \c true. */ - void PrintTestNameList (std::list::const_iterator begin, + void PrintTestNameList (std::list::const_iterator begin, std::list::const_iterator end, bool printTestType) const; /** Print the list of test types. */ @@ -255,8 +255,8 @@ private: -TestCaseFailure::TestCaseFailure (std::string _cond, std::string _actual, - std::string _limit, std::string _message, +TestCaseFailure::TestCaseFailure (std::string _cond, std::string _actual, + std::string _limit, std::string _message, std::string _file, int32_t _line) : cond (_cond), actual (_actual), limit (_limit), message (_message), file (_file), line (_line) @@ -310,7 +310,7 @@ TestCase::AddTestCase (TestCase *testCase, enum TestCase::TestDuration duration) // // The Windows list is too restrictive: we like to label // tests with "val = v1 * v2" or "v1 < 3" or "case: foo --> bar" - // So we allow ':<>*" + // So we allow ':<>*" std::string badchars = "\"/\\|?"; // Badchar Class Regex Count of failing test names @@ -328,7 +328,7 @@ TestCase::AddTestCase (TestCase *testCase, enum TestCase::TestDuration duration) $ ./waf --run "test-runner --list" 2>&1 | grep "^Invalid" | wc */ NS_LOG_UNCOND ("Invalid test name: cannot contain any of '" - << badchars << "': " << testCase->m_name); + << badchars << "': " << testCase->m_name); } testCase->m_duration = duration; @@ -343,7 +343,7 @@ TestCase::IsFailed (void) const return m_result->childrenFailed || !m_result->failure.empty (); } -void +void TestCase::Run (TestRunnerImpl *runner) { NS_LOG_FUNCTION (this << runner); @@ -361,12 +361,12 @@ TestCase::Run (TestRunnerImpl *runner) } } DoRun (); - out: +out: m_result->clock.End (); DoTeardown (); m_runner = 0; } -std::string +std::string TestCase::GetName (void) const { NS_LOG_FUNCTION (this); @@ -379,8 +379,8 @@ TestCase::GetParent () const } void -TestCase::ReportTestFailure (std::string cond, std::string actual, - std::string limit, std::string message, +TestCase::ReportTestFailure (std::string cond, std::string actual, + std::string limit, std::string message, std::string file, int32_t line) { NS_LOG_FUNCTION (this << cond << actual << limit << message << file << line); @@ -395,20 +395,20 @@ TestCase::ReportTestFailure (std::string cond, std::string actual, } } -bool +bool TestCase::MustAssertOnFailure (void) const { NS_LOG_FUNCTION (this); return m_runner->MustAssertOnFailure (); } -bool +bool TestCase::MustContinueOnFailure (void) const { NS_LOG_FUNCTION (this); return m_runner->MustContinueOnFailure (); } -std::string +std::string TestCase::CreateDataDirFilename (std::string filename) { NS_LOG_FUNCTION (this << filename); @@ -426,7 +426,7 @@ TestCase::CreateDataDirFilename (std::string filename) std::string b = SystemPath::Append (a, filename); return b; } -std::string +std::string TestCase::CreateTempDirFilename (std::string filename) { NS_LOG_FUNCTION (this << filename); @@ -448,32 +448,32 @@ TestCase::CreateTempDirFilename (std::string filename) return SystemPath::Append (tempDir, filename); } } -bool +bool TestCase::IsStatusFailure (void) const { NS_LOG_FUNCTION (this); return !IsStatusSuccess (); } -bool +bool TestCase::IsStatusSuccess (void) const { NS_LOG_FUNCTION (this); return m_result->failure.empty (); } -void +void TestCase::SetDataDir (std::string directory) { NS_LOG_FUNCTION (this << directory); m_dataDir = directory; } -void +void TestCase::DoSetup (void) { NS_LOG_FUNCTION (this); } -void +void TestCase::DoTeardown (void) { NS_LOG_FUNCTION (this); @@ -481,31 +481,31 @@ TestCase::DoTeardown (void) TestSuite::TestSuite (std::string name, TestSuite::Type type) - : TestCase (name), + : TestCase (name), m_type (type) { NS_LOG_FUNCTION (this << name << type); TestRunnerImpl::Get ()->AddTestSuite (this); } -TestSuite::Type +TestSuite::Type TestSuite::GetTestType (void) { NS_LOG_FUNCTION (this); return m_type; } -void +void TestSuite::DoRun (void) { NS_LOG_FUNCTION (this); } TestRunnerImpl::TestRunnerImpl () - : m_tempDir (""), - m_assertOnFailure (false), - m_continueOnFailure (true), - m_updateData (false) + : m_tempDir (""), + m_assertOnFailure (false), + m_continueOnFailure (true), + m_updateData (false) { NS_LOG_FUNCTION (this); } @@ -518,20 +518,20 @@ TestRunnerImpl::AddTestSuite (TestSuite *testSuite) } -bool +bool TestRunnerImpl::MustAssertOnFailure (void) const { NS_LOG_FUNCTION (this); return m_assertOnFailure; } -bool +bool TestRunnerImpl::MustContinueOnFailure (void) const { NS_LOG_FUNCTION (this); return m_continueOnFailure; } -bool +bool TestRunnerImpl::MustUpdateData (void) const { NS_LOG_FUNCTION (this); @@ -549,7 +549,7 @@ TestRunnerImpl::IsTopLevelSourceDir (std::string path) const NS_LOG_FUNCTION (this << path); bool haveVersion = false; bool haveLicense = false; - + // // If there's a file named VERSION and a file named LICENSE in this // directory, we assume it's our top level source directory. @@ -567,11 +567,11 @@ TestRunnerImpl::IsTopLevelSourceDir (std::string path) const haveLicense = true; } } - + return haveVersion && haveLicense; } -std::string +std::string TestRunnerImpl::GetTopLevelSourceDir (void) const { NS_LOG_FUNCTION (this); @@ -591,7 +591,7 @@ TestRunnerImpl::GetTopLevelSourceDir (void) const // // XML files have restrictions on certain characters that may be present in -// data. We need to replace these characters with their alternate +// data. We need to replace these characters with their alternate // representation on the way into the XML file. // std::string @@ -676,31 +676,31 @@ TestRunnerImpl::PrintReport (TestCase *test, std::ostream *os, bool xml, int lev std::streamsize oldPrecision = (*os).precision (3); *os << std::fixed; - std::string statusString = test->IsFailed ()?"FAIL":"PASS"; + std::string statusString = test->IsFailed () ? "FAIL" : "PASS"; if (xml) { *os << Indent (level) << "" << std::endl; - *os << Indent (level+1) << "" << ReplaceXmlSpecialCharacters (test->m_name) + *os << Indent (level + 1) << "" << ReplaceXmlSpecialCharacters (test->m_name) << "" << std::endl; - *os << Indent (level+1) << "" << statusString << "" << std::endl; - *os << Indent (level+1) << "