fw: add override specifier to Strategy triggers

refs #2281

Change-Id: I5357ac6a93260492900d24c8955fdd7397ef2d27
diff --git a/.waf-tools/compiler-features.py b/.waf-tools/compiler-features.py
new file mode 100644
index 0000000..5344939
--- /dev/null
+++ b/.waf-tools/compiler-features.py
@@ -0,0 +1,27 @@
+# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
+
+from waflib.Configure import conf
+
+OVERRIDE = '''
+class Base
+{
+  virtual void
+  f(int a);
+};
+
+class Derived : public Base
+{
+  virtual void
+  f(int a) override;
+};
+'''
+
+@conf
+def check_override(self):
+    if self.check_cxx(msg='Checking for override specifier',
+                      fragment=OVERRIDE,
+                      features='cxx', mandatory=False):
+        self.define('HAVE_CXX_OVERRIDE', 1)
+
+def configure(conf):
+    conf.check_override()
diff --git a/common.hpp b/common.hpp
index 17edcc5..94171c7 100644
--- a/common.hpp
+++ b/common.hpp
@@ -40,6 +40,15 @@
 #define PROTECTED_WITH_TESTS_ELSE_PRIVATE private
 #endif
 
+/** \def DECL_OVERRIDE
+ *  \brief expands to 'override' if compiler supports this feature, otherwise expands to nothing
+ */
+#ifdef HAVE_CXX_OVERRIDE
+#define DECL_OVERRIDE override
+#else
+#define DECL_OVERRIDE
+#endif
+
 #include <cstddef>
 #include <list>
 #include <set>
diff --git a/daemon/fw/best-route-strategy.hpp b/daemon/fw/best-route-strategy.hpp
index aa11567..7ec64ff 100644
--- a/daemon/fw/best-route-strategy.hpp
+++ b/daemon/fw/best-route-strategy.hpp
@@ -54,7 +54,7 @@
   afterReceiveInterest(const Face& inFace,
                        const Interest& interest,
                        shared_ptr<fib::Entry> fibEntry,
-                       shared_ptr<pit::Entry> pitEntry);
+                       shared_ptr<pit::Entry> pitEntry) DECL_OVERRIDE;
 
 public:
   static const Name STRATEGY_NAME;
diff --git a/daemon/fw/best-route-strategy2.hpp b/daemon/fw/best-route-strategy2.hpp
index 72df544..bb259d0 100644
--- a/daemon/fw/best-route-strategy2.hpp
+++ b/daemon/fw/best-route-strategy2.hpp
@@ -48,7 +48,7 @@
   afterReceiveInterest(const Face& inFace,
                        const Interest& interest,
                        shared_ptr<fib::Entry> fibEntry,
-                       shared_ptr<pit::Entry> pitEntry);
+                       shared_ptr<pit::Entry> pitEntry) DECL_OVERRIDE;
 
 public:
   static const Name STRATEGY_NAME;
diff --git a/daemon/fw/broadcast-strategy.hpp b/daemon/fw/broadcast-strategy.hpp
index b468895..0807bde 100644
--- a/daemon/fw/broadcast-strategy.hpp
+++ b/daemon/fw/broadcast-strategy.hpp
@@ -1,11 +1,12 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2014  Regents of the University of California,
- *                     Arizona Board of Regents,
- *                     Colorado State University,
- *                     University Pierre & Marie Curie, Sorbonne University,
- *                     Washington University in St. Louis,
- *                     Beijing Institute of Technology
+ * Copyright (c) 2014,  Regents of the University of California,
+ *                      Arizona Board of Regents,
+ *                      Colorado State University,
+ *                      University Pierre & Marie Curie, Sorbonne University,
+ *                      Washington University in St. Louis,
+ *                      Beijing Institute of Technology,
+ *                      The University of Memphis
  *
  * This file is part of NFD (Named Data Networking Forwarding Daemon).
  * See AUTHORS.md for complete list of NFD authors and contributors.
@@ -20,7 +21,7 @@
  *
  * You should have received a copy of the GNU General Public License along with
  * NFD, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
- **/
+ */
 
 #ifndef NFD_DAEMON_FW_BROADCAST_STRATEGY_HPP
 #define NFD_DAEMON_FW_BROADCAST_STRATEGY_HPP
@@ -46,7 +47,7 @@
   afterReceiveInterest(const Face& inFace,
                        const Interest& interest,
                        shared_ptr<fib::Entry> fibEntry,
-                       shared_ptr<pit::Entry> pitEntry);
+                       shared_ptr<pit::Entry> pitEntry) DECL_OVERRIDE;
 
 public:
   static const Name STRATEGY_NAME;
diff --git a/daemon/fw/client-control-strategy.hpp b/daemon/fw/client-control-strategy.hpp
index d4810b5..a0ddbf2 100644
--- a/daemon/fw/client-control-strategy.hpp
+++ b/daemon/fw/client-control-strategy.hpp
@@ -1,11 +1,12 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2014  Regents of the University of California,
- *                     Arizona Board of Regents,
- *                     Colorado State University,
- *                     University Pierre & Marie Curie, Sorbonne University,
- *                     Washington University in St. Louis,
- *                     Beijing Institute of Technology
+ * Copyright (c) 2014,  Regents of the University of California,
+ *                      Arizona Board of Regents,
+ *                      Colorado State University,
+ *                      University Pierre & Marie Curie, Sorbonne University,
+ *                      Washington University in St. Louis,
+ *                      Beijing Institute of Technology,
+ *                      The University of Memphis
  *
  * This file is part of NFD (Named Data Networking Forwarding Daemon).
  * See AUTHORS.md for complete list of NFD authors and contributors.
@@ -20,7 +21,7 @@
  *
  * You should have received a copy of the GNU General Public License along with
  * NFD, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
- **/
+ */
 
 #ifndef NFD_DAEMON_FW_CLIENT_CONTROL_STRATEGY_HPP
 #define NFD_DAEMON_FW_CLIENT_CONTROL_STRATEGY_HPP
@@ -45,7 +46,7 @@
   afterReceiveInterest(const Face& inFace,
                        const Interest& interest,
                        shared_ptr<fib::Entry> fibEntry,
-                       shared_ptr<pit::Entry> pitEntry);
+                       shared_ptr<pit::Entry> pitEntry) DECL_OVERRIDE;
 
 public:
   static const Name STRATEGY_NAME;
diff --git a/daemon/fw/ncc-strategy.hpp b/daemon/fw/ncc-strategy.hpp
index fa27cd9..72f39e4 100644
--- a/daemon/fw/ncc-strategy.hpp
+++ b/daemon/fw/ncc-strategy.hpp
@@ -45,11 +45,11 @@
   afterReceiveInterest(const Face& inFace,
                        const Interest& interest,
                        shared_ptr<fib::Entry> fibEntry,
-                       shared_ptr<pit::Entry> pitEntry);
+                       shared_ptr<pit::Entry> pitEntry) DECL_OVERRIDE;
 
   virtual void
   beforeSatisfyInterest(shared_ptr<pit::Entry> pitEntry,
-                        const Face& inFace, const Data& data);
+                        const Face& inFace, const Data& data) DECL_OVERRIDE;
 
 protected:
   /// StrategyInfo on measurements::Entry
diff --git a/tests/daemon/fw/dummy-strategy.hpp b/tests/daemon/fw/dummy-strategy.hpp
index 83af2fa..50de93e 100644
--- a/tests/daemon/fw/dummy-strategy.hpp
+++ b/tests/daemon/fw/dummy-strategy.hpp
@@ -47,7 +47,7 @@
   afterReceiveInterest(const Face& inFace,
                        const Interest& interest,
                        shared_ptr<fib::Entry> fibEntry,
-                       shared_ptr<pit::Entry> pitEntry)
+                       shared_ptr<pit::Entry> pitEntry) DECL_OVERRIDE
   {
     ++m_afterReceiveInterest_count;
 
@@ -61,13 +61,13 @@
 
   virtual void
   beforeSatisfyInterest(shared_ptr<pit::Entry> pitEntry,
-                        const Face& inFace, const Data& data)
+                        const Face& inFace, const Data& data) DECL_OVERRIDE
   {
     ++m_beforeSatisfyInterest_count;
   }
 
   virtual void
-  beforeExpirePendingInterest(shared_ptr<pit::Entry> pitEntry)
+  beforeExpirePendingInterest(shared_ptr<pit::Entry> pitEntry) DECL_OVERRIDE
   {
     ++m_beforeExpirePendingInterest_count;
   }
diff --git a/tests/daemon/fw/strategy-tester.hpp b/tests/daemon/fw/strategy-tester.hpp
index 260a196..a1b920d 100644
--- a/tests/daemon/fw/strategy-tester.hpp
+++ b/tests/daemon/fw/strategy-tester.hpp
@@ -54,16 +54,16 @@
   virtual void
   sendInterest(shared_ptr<pit::Entry> pitEntry,
                shared_ptr<Face> outFace,
-               bool wantNewNonce = false);
+               bool wantNewNonce = false) DECL_OVERRIDE;
 
   virtual void
-  rejectPendingInterest(shared_ptr<pit::Entry> pitEntry);
+  rejectPendingInterest(shared_ptr<pit::Entry> pitEntry) DECL_OVERRIDE;
 
 public:
-  typedef boost::tuple<shared_ptr<pit::Entry>, shared_ptr<Face> > SendInterestArgs;
+  typedef boost::tuple<shared_ptr<pit::Entry>, shared_ptr<Face>> SendInterestArgs;
   std::vector<SendInterestArgs> m_sendInterestHistory;
 
-  typedef boost::tuple<shared_ptr<pit::Entry> > RejectPendingInterestArgs;
+  typedef boost::tuple<shared_ptr<pit::Entry>> RejectPendingInterestArgs;
   std::vector<RejectPendingInterestArgs> m_rejectPendingInterestHistory;
 };
 
diff --git a/tests/daemon/table/measurements-accessor.cpp b/tests/daemon/table/measurements-accessor.cpp
index 8d09ca4..8668368 100644
--- a/tests/daemon/table/measurements-accessor.cpp
+++ b/tests/daemon/table/measurements-accessor.cpp
@@ -27,35 +27,26 @@
 #include "fw/strategy.hpp"
 
 #include "tests/test-common.hpp"
+#include "../fw/dummy-strategy.hpp"
 
 namespace nfd {
 namespace tests {
 
 BOOST_FIXTURE_TEST_SUITE(TableMeasurementsAccessor, BaseFixture)
 
-class MeasurementsAccessorTestStrategy : public fw::Strategy
+class MeasurementsAccessorTestStrategy : public DummyStrategy
 {
 public:
   MeasurementsAccessorTestStrategy(Forwarder& forwarder, const Name& name)
-    : Strategy(forwarder, name)
+    : DummyStrategy(forwarder, name)
   {
   }
 
   virtual
   ~MeasurementsAccessorTestStrategy()
-
   {
   }
 
-  virtual void
-  afterReceiveInterest(const Face& inFace,
-                       const Interest& interest,
-                       shared_ptr<fib::Entry> fibEntry,
-                       shared_ptr<pit::Entry> pitEntry)
-  {
-    BOOST_ASSERT(false);
-  }
-
 public: // accessors
   MeasurementsAccessor&
   getMeasurements_accessor()
diff --git a/wscript b/wscript
index 548fad3..65c249a 100644
--- a/wscript
+++ b/wscript
@@ -36,7 +36,7 @@
     opt.load(['compiler_cxx', 'gnu_dirs'])
     opt.load(['boost', 'unix-socket', 'dependency-checker', 'websocket',
               'default-compiler-flags', 'coverage', 'pch', 'boost-kqueue',
-              'doxygen', 'sphinx_build', 'type_traits'],
+              'doxygen', 'sphinx_build', 'type_traits', 'compiler-features'],
              tooldir=['.waf-tools'])
 
     nfdopt = opt.add_option_group('NFD Options')
@@ -59,7 +59,7 @@
     conf.load(['compiler_cxx', 'gnu_dirs',
                'default-compiler-flags', 'pch', 'boost-kqueue',
                'boost', 'dependency-checker', 'websocket',
-               'doxygen', 'sphinx_build', 'type_traits'])
+               'doxygen', 'sphinx_build', 'type_traits', 'compiler-features'])
 
     conf.find_program('bash', var='BASH')