table: rename StrategyInfoHost::getOrCreateStrategyInfo to insertStrategyInfo

refs #3205

Change-Id: Icd3ab9e4fdb5a2ffc39a8d0e0c713e22f13fe28c
diff --git a/daemon/table/strategy-info-host.hpp b/daemon/table/strategy-info-host.hpp
index 7afe50d..23b5fcc 100644
--- a/daemon/table/strategy-info-host.hpp
+++ b/daemon/table/strategy-info-host.hpp
@@ -30,35 +30,65 @@
 
 namespace nfd {
 
-/** \brief base class for an entity onto which StrategyInfo objects may be placed
+/** \brief base class for an entity onto which StrategyInfo items may be placed
  */
 class StrategyInfoHost
 {
 public:
   /** \brief get a StrategyInfo item
-   *  \tparam T type of StrategyInfo, must be a subclass of from nfd::fw::StrategyInfo
-   *  \retval nullptr if no StrategyInfo of type T is stored
+   *  \tparam T type of StrategyInfo, must be a subclass of fw::StrategyInfo
+   *  \return an existing StrategyInfo item of type T, or nullptr if it does not exist
    */
   template<typename T>
   shared_ptr<T>
-  getStrategyInfo() const;
+  getStrategyInfo() const
+  {
+    static_assert(std::is_base_of<fw::StrategyInfo, T>::value,
+                  "T must inherit from StrategyInfo");
+
+    auto it = m_items.find(T::getTypeId());
+    if (it == m_items.end()) {
+      return nullptr;
+    }
+    return static_pointer_cast<T, fw::StrategyInfo>(it->second);
+  }
 
   /** \brief set a StrategyInfo item
-   *  \tparam T type of StrategyInfo, must be a subclass of from nfd::fw::StrategyInfo
+   *  \tparam T type of StrategyInfo, must be a subclass of nfd::fw::StrategyInfo
    */
   template<typename T>
   void
-  setStrategyInfo(shared_ptr<T> strategyInfo);
+  setStrategyInfo(shared_ptr<T> item)
+  {
+    static_assert(std::is_base_of<fw::StrategyInfo, T>::value,
+                  "T must inherit from StrategyInfo");
 
-  /** \brief get or create a StrategyInfo item
-   *  \tparam T type of StrategyInfo, must be a subclass of from nfd::fw::StrategyInfo
-   *
-   *  If no StrategyInfo of type T is stored, it's created with \p args;
-   *  otherwise, the existing item is returned.
+    if (item == nullptr) {
+      m_items.erase(T::getTypeId());
+    }
+    else {
+      m_items[T::getTypeId()] = item;
+    }
+  }
+
+  /** \brief insert a StrategyInfo item
+   *  \tparam T type of StrategyInfo, must be a subclass of fw::StrategyInfo
+   *  \return a new or existing StrategyInfo item of type T
    */
   template<typename T, typename ...A>
   shared_ptr<T>
-  getOrCreateStrategyInfo(A&&... args);
+  insertStrategyInfo(A&&... args)
+  {
+    static_assert(std::is_base_of<fw::StrategyInfo, T>::value,
+                  "T must inherit from StrategyInfo");
+
+    shared_ptr<T> item = this->getStrategyInfo<T>();
+    if (!static_cast<bool>(item)) {
+      item = std::make_shared<T>(std::forward<A>(args)...);
+      this->setStrategyInfo(item);
+    }
+    return item;
+  }
 
   /** \brief clear all StrategyInfo items
    */
@@ -69,51 +99,6 @@
   std::map<int, shared_ptr<fw::StrategyInfo>> m_items;
 };
 
-
-template<typename T>
-shared_ptr<T>
-StrategyInfoHost::getStrategyInfo() const
-{
-  static_assert(std::is_base_of<fw::StrategyInfo, T>::value,
-                "T must inherit from StrategyInfo");
-
-  auto it = m_items.find(T::getTypeId());
-  if (it == m_items.end()) {
-    return nullptr;
-  }
-  return static_pointer_cast<T, fw::StrategyInfo>(it->second);
-}
-
-template<typename T>
-void
-StrategyInfoHost::setStrategyInfo(shared_ptr<T> item)
-{
-  static_assert(std::is_base_of<fw::StrategyInfo, T>::value,
-                "T must inherit from StrategyInfo");
-
-  if (item == nullptr) {
-    m_items.erase(T::getTypeId());
-  }
-  else {
-    m_items[T::getTypeId()] = item;
-  }
-}
-
-template<typename T, typename ...A>
-shared_ptr<T>
-StrategyInfoHost::getOrCreateStrategyInfo(A&&... args)
-{
-  static_assert(std::is_base_of<fw::StrategyInfo, T>::value,
-                "T must inherit from StrategyInfo");
-
-  shared_ptr<T> item = this->getStrategyInfo<T>();
-  if (!static_cast<bool>(item)) {
-    item = std::make_shared<T>(std::forward<A>(args)...);
-    this->setStrategyInfo(item);
-  }
-  return item;
-}
-
 } // namespace nfd
 
 #endif // NFD_DAEMON_TABLE_STRATEGY_INFO_HOST_HPP