Lecrapouille / Highway

[Application][WIP] Open-source simulator for autonomous driving research.
GNU General Public License v3.0
2 stars 1 forks source link

Pass arguments to existing gui #2

Open Lecrapouille opened 1 year ago

Lecrapouille commented 1 year ago

Application.hpp:

Currently

    template<class GUI, typename ...ArgsT>
    GUI& gui(std::string const& name, ArgsT&&... args)
    {
        auto const& it = m_guis.find(name); // TBD: use typeid(T).hash_code() instead of name
        if (it != m_guis.end())
        {
            // FIXME: if we do not remove existing GUI the arguments are not be passed
            // and therefore they are not used.
            //return *dynamic_cast<GUI*>(it->second.get());
            m_guis.erase(it);
        }
        m_guis[name] = std::make_unique<GUI>(*this, name, std::forward<ArgsT>(args)...);
         return *reinterpret_cast<GUI*>(m_guis[name].get());
    }

How to prevent doing .erase() to force passing args in the constructor ?