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 unique_ptr<fw::StrategyInfo>& item = m_items[T::getTypeId()];
69 bool isNew = (item ==
nullptr);
71 item.reset(
new 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());
96 std::unordered_map<int, unique_ptr<fw::StrategyInfo>> m_items;
101 #endif // NFD_DAEMON_TABLE_STRATEGY_INFO_HOST_HPP base class for an entity onto which StrategyInfo items may be placed
std::pair< T *, bool > insertStrategyInfo(A &&...args)
insert a StrategyInfo item
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