26 #ifndef NFD_DAEMON_TABLE_STRATEGY_INFO_HOST_HPP
27 #define NFD_DAEMON_TABLE_STRATEGY_INFO_HOST_HPP
31 #include <unordered_map>
48 static_assert(std::is_base_of_v<fw::StrategyInfo, T>);
50 auto it = m_items.find(T::getTypeId());
51 if (it == m_items.end()) {
54 return static_cast<T*
>(it->second.get());
62 template<
typename T,
typename ...A>
66 static_assert(std::is_base_of_v<fw::StrategyInfo, T>);
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_v<fw::StrategyInfo, T>);
86 return m_items.erase(T::getTypeId());
98 std::unordered_map<int, unique_ptr<fw::StrategyInfo>> m_items;
Base class for an entity onto which StrategyInfo items may be placed.
size_t eraseStrategyInfo()
Erase a StrategyInfo item.
T * getStrategyInfo() const
Get a StrategyInfo item.
void clearStrategyInfo()
Clear all StrategyInfo items.
std::pair< T *, bool > insertStrategyInfo(A &&... args)
Insert a StrategyInfo item.