return -1;
}
+ if (items_by_id.size() < parent_id) {
+ msg_err_cache("parent id %d is out of bounds for virtual symbol %s", parent_id, name.data());
+ return -1;
+ }
+
auto id = items_by_id.size();
auto item = cache_item::create_with_virtual(static_pool,
id,
std::string{name},
parent_id, real_type_pair.first, real_type_pair.second);
+ auto &parent = items_by_id[parent_id];
+ parent->add_child(item);
items_by_symbol[item->get_name()] = item;
get_item_specific_vector(*item).push_back(item);
items_by_id.push_back(item);
private:
symbol_func_t func;
void *user_data;
+ std::vector<cache_item_ptr> virtual_children;
std::vector<item_condition> conditions;
public:
explicit normal_item(symbol_func_t _func, void *_user_data) : func(_func), user_data(_user_data)
auto get_cbdata() const -> auto {
return user_data;
}
+
+ auto add_child(const cache_item_ptr &ptr) -> void {
+ virtual_children.push_back(ptr);
+ }
};
class virtual_item {
*/
auto get_augmentation_weight() const -> int;
+ /**
+ * Add a virtual symbol as a child of some normal symbol
+ * @param ptr
+ */
+ auto add_child(const cache_item_ptr &ptr) -> void {
+ if (std::holds_alternative<normal_item>(specific)) {
+ auto &filter_data = std::get<normal_item>(specific);
+
+ filter_data.add_child(ptr);
+ }
+ else {
+ g_assert("add child is called for a virtual symbol!");
+ }
+ }
+
private:
/**
* Constructor for a normal symbols with callback
static void resort_cb(EV_P_ ev_timer *w, int _revents) {
auto *cbdata = (struct cache_refresh_cbdata *)w->data;
- static const double decay_rate = 0.25;
auto log_tag = [&]() { return cbdata->cache->log_tag(); };