From c8f2bf250e2be1d8001b2b14ea53092b806dfa12 Mon Sep 17 00:00:00 2001 From: Jared Dulmage Date: Tue, 25 Aug 2020 13:03:03 -0600 Subject: [PATCH] Addressed comments for nsnam/ns-3-dev MR 91 - Removed unnecessary files src/core/model/{attribute-container,pair}.cc - Removed 'explicit' modifier to PairChecker - Modified output stream operator for PairValue; update PairValueTestCase - Updated src/core/wscript to latest master - Added Pair and AttributeContainer to utils/print-introspected-doxygen.cc --- src/core/model/attribute-container.cc | 27 ----------- src/core/model/pair.cc | 27 ----------- src/core/model/pair.h | 37 ++++++--------- src/core/test/pair-value-test-suite.cc | 2 +- src/core/wscript | 66 +++++++++++++++++++------- utils/print-introspected-doxygen.cc | 7 +++ 6 files changed, 71 insertions(+), 95 deletions(-) delete mode 100644 src/core/model/attribute-container.cc delete mode 100644 src/core/model/pair.cc diff --git a/src/core/model/attribute-container.cc b/src/core/model/attribute-container.cc deleted file mode 100644 index 214f2ba59..000000000 --- a/src/core/model/attribute-container.cc +++ /dev/null @@ -1,27 +0,0 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ -/* - * Copyright (c) 2018 Caliola Engineering, LLC. - * - * 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 - * published by the Free Software Foundation; - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Author: Jared Dulmage - * Note: Need this file for library to be built - */ - -#include "attribute-container.h" - -namespace ns3 { - - -} // namespace ns3 diff --git a/src/core/model/pair.cc b/src/core/model/pair.cc deleted file mode 100644 index 202e91190..000000000 --- a/src/core/model/pair.cc +++ /dev/null @@ -1,27 +0,0 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ -/* - * Copyright (c) 2018 Caliola Engineering, LLC. - * - * 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 - * published by the Free Software Foundation; - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Author: Jared Dulmage - * Note: Need this file for library to be built - */ - -#include "pair.h" - -namespace ns3 { - - -} // namespace ns3 diff --git a/src/core/model/pair.h b/src/core/model/pair.h index 268e2046d..309e6f20d 100644 --- a/src/core/model/pair.h +++ b/src/core/model/pair.h @@ -26,7 +26,7 @@ #include #include -#include +#include // typeid #include #include @@ -34,13 +34,12 @@ namespace ns3 { class AttributeChecker; -// TODO(jared): useful to maybe define global to be the pair separator -// for serialization / deserialization? +// TODO: useful to maybe define some kind of configurable formatter? template std::ostream & operator << (std::ostream &os, const std::pair &p) { - os << p.first << " " << p.second; + os << "(" << p.first << "," << p.second << ")"; return os; } @@ -112,7 +111,7 @@ class PairChecker : public ns3::PairChecker { public: PairChecker (void); - explicit PairChecker (Ptr firstchecker, Ptr secondchecker); + PairChecker (Ptr firstchecker, Ptr secondchecker); void SetCheckers (Ptr firstchecker, Ptr secondchecker); typename ns3::PairChecker::checker_pair_type GetCheckers (void) const; @@ -123,19 +122,15 @@ private: template PairChecker::PairChecker (void) - : m_firstchecker (0) - , m_secondchecker (0) -{ - -} + : m_firstchecker (0), + m_secondchecker (0) +{} template PairChecker::PairChecker (Ptr firstchecker, Ptr secondchecker) - : m_firstchecker (firstchecker) - , m_secondchecker (secondchecker) -{ - -} + : m_firstchecker (firstchecker), + m_secondchecker (secondchecker) +{} template void @@ -174,14 +169,14 @@ template Ptr > MakePairChecker (void) { - std::string typeName, underlyingType; + std::string pairName, underlyingType; typedef PairValue T; std::string first_type_name = typeid (typename T::value_type::first_type).name (); std::string second_type_name = typeid (typename T::value_type::second_type).name (); { std::ostringstream oss; oss << "ns3::PairValue<" << first_type_name << ", " << second_type_name << ">"; - typeName = oss.str (); + pairName = oss.str (); } { @@ -191,16 +186,14 @@ MakePairChecker (void) } return DynamicCast > ( - MakeSimpleAttributeChecker > (typeName, underlyingType) - ); + MakeSimpleAttributeChecker > (pairName, underlyingType) + ); } template PairValue::PairValue () : m_value (std::make_pair (Create (), Create ())) -{ - -} +{} template PairValue::PairValue (const typename PairValue::result_type &value) diff --git a/src/core/test/pair-value-test-suite.cc b/src/core/test/pair-value-test-suite.cc index 95956c515..4993db727 100644 --- a/src/core/test/pair-value-test-suite.cc +++ b/src/core/test/pair-value-test-suite.cc @@ -158,7 +158,7 @@ PairValueSettingsTestCase::DoRun () std::ostringstream oss, ref; oss << *p; - ref << "StringPair = { hello world } AddressPair = { " << addr << " 31 }"; + ref << "StringPair = { (hello,world) } AddressPair = { (" << addr << ",31) }"; NS_TEST_ASSERT_MSG_EQ ((oss.str ()), (ref.str ()), "Pairs not correctly set"); } diff --git a/src/core/wscript b/src/core/wscript index 3d9cbe747..580d6cb2a 100644 --- a/src/core/wscript +++ b/src/core/wscript @@ -36,7 +36,7 @@ def options(opt): % ", ".join([repr(p) for p in list(int64x64.keys())])), choices=list(int64x64.keys()), dest='int64x64_impl') - + opt.add_option('--disable-pthread', help=('Whether to enable the use of POSIX threads'), action="store_true", default=False, @@ -101,10 +101,6 @@ def configure(conf): conf.check_nonfatal(header_name='sys/stat.h', define_name='HAVE_SYS_STAT_H') conf.check_nonfatal(header_name='dirent.h', define_name='HAVE_DIRENT_H') - if conf.check_nonfatal(header_name='stdlib.h'): - conf.define('HAVE_STDLIB_H', 1) - conf.define('HAVE_GETENV', 1) - conf.check_nonfatal(header_name='signal.h', define_name='HAVE_SIGNAL_H') # Check for POSIX threads @@ -239,15 +235,11 @@ def build(bld): 'model/hash.cc', 'model/des-metrics.cc', 'model/ascii-file.cc', - 'model/attribute-container.cc', - 'model/pair.cc', 'model/node-printer.cc', 'model/time-printer.cc', 'model/show-progress.cc', 'model/system-wall-clock-timestamp.cc', 'model/version.cc', - 'model/attribute-container.cc', - 'model/pair.cc', ] if (bld.env['ENABLE_EXAMPLES']): @@ -256,6 +248,7 @@ def build(bld): core_test = bld.create_ns3_module_test_library('core') core_test.source = [ 'test/attribute-test-suite.cc', + 'test/attribute-container-test-suite.cc', 'test/build-profile-test-suite.cc', 'test/callback-test-suite.cc', 'test/command-line-test-suite.cc', @@ -268,6 +261,7 @@ def build(bld): 'test/event-garbage-collector-test-suite.cc', 'test/many-uniform-random-variables-one-get-value-call-test-suite.cc', 'test/one-uniform-random-variable-many-get-value-calls-test-suite.cc', + 'test/pair-value-test-suite.cc', 'test/sample-test-suite.cc', 'test/simulator-test-suite.cc', 'test/time-test-suite.cc', @@ -277,10 +271,13 @@ def build(bld): 'test/watchdog-test-suite.cc', 'test/hash-test-suite.cc', 'test/type-id-test-suite.cc', - 'test/pair-value-test-suite.cc', - 'test/attribute-container-test-suite.cc', ] + if (bld.env['ENABLE_EXAMPLES']): + core_test.source.extend([ + 'test/examples-as-tests-test-suite.cc', + ]) + headers = bld(features='ns3header') headers.module = 'core' headers.source = [ @@ -295,6 +292,7 @@ def build(bld): 'model/map-scheduler.h', 'model/heap-scheduler.h', 'model/calendar-scheduler.h', + 'model/priority-queue-scheduler.h', 'model/simulation-singleton.h', 'model/singleton.h', 'model/timer.h', @@ -303,6 +301,7 @@ def build(bld): 'model/synchronizer.h', 'model/make-event.h', 'model/system-wall-clock-ms.h', + 'model/system-wall-clock-timestamp.h', 'model/empty.h', 'model/callback.h', 'model/object-base.h', @@ -339,6 +338,7 @@ def build(bld): 'model/pointer.h', 'model/object-factory.h', 'model/attribute-helper.h', + 'model/attribute-container.h', 'model/global-value.h', 'model/traced-callback.h', 'model/traced-value.h', @@ -347,6 +347,7 @@ def build(bld): 'model/object-ptr-container.h', 'model/object-vector.h', 'model/object-map.h', + 'model/pair.h', 'model/deprecated.h', 'model/abort.h', 'model/names.h', @@ -372,13 +373,6 @@ def build(bld): 'model/time-printer.h', 'model/show-progress.h', 'model/version.h', - 'model/pair.h', - 'model/attribute-container-accessor-helper.h', - 'model/attribute-container.h', - 'model/extended-attribute-helper.h', - 'model/node-printer.h', - 'model/time-printer.h', - 'model/show-progress.h', ] if (bld.env['ENABLE_EXAMPLES']): @@ -452,3 +446,39 @@ def build(bld): pymod = bld.ns3_python_bindings() if pymod is not None: pymod.source += ['bindings/module_helpers.cc'] + +def print_version(bld, tg): + tg.post() + + for task in tg.tasks: + if task.__class__.__name__ == 'git_ns3_version_info': + #manually run task + task.run() + break + + handlers = { + 'VERSION_TAG': lambda s: s.strip('"'), + 'CLOSEST_TAG': lambda s: s.strip('"'), + 'VERSION_TAG_DISTANCE': lambda s: '' if s == '0' else "+" + s, + 'VERSION_COMMIT_HASH': lambda s: "@" + s.strip('"'), + 'VERSION_DIRTY_FLAG': lambda s: '' if s == '0' else '-dirty', + 'BUILD_PROFILE': lambda s: "-" + s + } + + fields=('VERSION_TAG', 'CLOSEST_TAG', 'VERSION_TAG_DISTANCE', + 'VERSION_COMMIT_HASH', 'VERSION_DIRTY_FLAG', 'BUILD_PROFILE') + + parts = dict() + + for field in fields: + if field in bld.env: + parts[field] = handlers[field](bld.env[field]) + else: + parts[field] = '' + + if parts['CLOSEST_TAG'] != parts['VERSION_TAG']: + parts['CLOSEST_TAG'] = "+" + parts['CLOSEST_TAG'] + else: + parts['CLOSEST_TAG'] = "" + + print(''.join([parts[f] for f in fields])) diff --git a/utils/print-introspected-doxygen.cc b/utils/print-introspected-doxygen.cc index a27d77cb2..795561c51 100644 --- a/utils/print-introspected-doxygen.cc +++ b/utils/print-introspected-doxygen.cc @@ -1570,7 +1570,14 @@ PrintAttributeImplementations (std::ostream & os) PrintAttributeValueSection (os, "ObjectMap", false); PrintMakeAccessors (os, "ObjectMap"); PrintMakeChecker (os, "ObjectMap", "object-map.h"); + + PrintAttributeValueSection (os, "Pair", false); + PrintAttributeValueWithName (os, "Pair", "Pair", "pair.h"); + PrintMakeChecker (os, "Pair", "pair.h"); + PrintAttributeValueSection (os, "AttributeContainer", false); + PrintAttributeValueWithName (os, "AttributeContainer", "AttributeContainer", "attribute-container.h"); + PrintMakeChecker (os, "AttributeContainer", "attribute-container.h"); } // PrintAttributeImplementations ()