26 #ifndef NFD_DAEMON_TABLE_STRATEGY_INFO_HOST_HPP 27 #define NFD_DAEMON_TABLE_STRATEGY_INFO_HOST_HPP 46 static_assert(std::is_base_of<fw::StrategyInfo, T>::value,
47 "T must inherit from StrategyInfo");
49 auto it = m_items.find(T::getTypeId());
50 if (it == m_items.end()) {
53 return static_cast<T*
>(it->second.get());
61 template<
typename T,
typename ...A>
65 static_assert(std::is_base_of<fw::StrategyInfo, T>::value,
66 "T must inherit from StrategyInfo");
68 auto& item = m_items[T::getTypeId()];
69 bool isNew = item ==
nullptr;
71 item = make_unique<T>(std::forward<A>(args)...);
73 return {
static_cast<T*
>(item.get()), isNew};
84 static_assert(std::is_base_of<fw::StrategyInfo, T>::value,
85 "T must inherit from StrategyInfo");
87 return m_items.erase(T::getTypeId());
99 std::unordered_map<int, unique_ptr<fw::StrategyInfo>> m_items;
104 #endif // NFD_DAEMON_TABLE_STRATEGY_INFO_HOST_HPP std::pair< T *, bool > insertStrategyInfo(A &&... args)
Insert a StrategyInfo item.
Base class for an entity onto which StrategyInfo items may be placed.
void clearStrategyInfo()
Clear all StrategyInfo items.
Copyright (c) 2014-2015, Regents of the University of California, Arizona Board of Regents...
size_t eraseStrategyInfo()
Erase a StrategyInfo item.
T * getStrategyInfo() const
Get a StrategyInfo item.