title: How to create an easily customizable Manager for multiple Resource Types
body: <p>I'm very new in C++, but I'm working on a little framework of mine.</p>
  <p>For this framework, I need to load various types of <code>Resources</code> and I would love to write it such it would be very easy to add new <code>Resources</code> without having to create managers for every one of them.</p>
  <p>So I was thinking like this:</p>
  <p>I need base <code>BaseResource</code> class from which I can then inherit other resource types</p>
  <pre><code>class BaseResource {
      uint32_t resource_id;
      std::string name;
      std::string path;
  
  public:
      uint32_t get_id() {
          return resource_id;
      }
  
      const std::string&amp; get_name() {
          return name;
      }
  
      const std::string&amp; get_path() {
          return path;
      }
  };
  </code></pre>
  <p>Then what I need is some kind of base <code>BaseResourceManager</code> templated for <code>Resource</code></p>
  <pre><code>template&lt;class T&gt;
  class BaseResourceManager{
  
      // path = name
      std::vector&lt;T&gt; _resources;
      std::map&lt;std::string, uint32_t&gt; _path_map; // 
  
  public:
      void load(std::string path) {
           // load from file and call T with name
           _path_map.insert();
      }
  
      T&amp; get(uint32_t idx) {
          return _resources[idx];
      }
  
      T&amp; get_by_name(std::string name) {
          return _resources[_path_map[name]];
      }
  
       void delete(uint32_t idx) {
           std::string name = resources[idx].get_name();
          _resources[idx] = null_ptr;
          
          _path_map[name] = nullptr; // ERASE ??
      }
  
  
  };
  </code></pre>
  <p>But now I'm kind of stuck while making something, what could glue multiple <code>BaseResourceManager&lt;T1&gt;</code>, <code>BaseResourceManager&lt;T2&gt;</code> together.</p>
  <p>All I could do, but it is wrong, is this main <code>ResourceManager</code></p>
  <pre><code>class ResourceManager {
      // managers
      std::vector&lt;BaseManager&gt; managers;
  
  public:
  
      ResourceManager() {
      }
  
      void init() {
          
      }
  
      void register_manager(BaseManager&amp;&amp; man) {
          managers.push_back(man);
      }
  
  template &lt;typename T, size_t i&gt;
      T get() {
          return dynamic_cast&lt;T&gt;(managers[i]);
      }
  };
  </code></pre>
  <p>I think it would be a good idea to store in <code>_managers</code> some kind of pointer to heap-allocated managers,
  and also what I couldn't solve was creating <code>get()</code> function only with one template, somehow automatically create a sequence of numbers for every type as a second template.</p>