Hi, an interface for all SFML-classes providing
loadFromFile() (and similar) would be great. I'd like to store multiple "Loadables" inside a nested std::map: First key: RTTI using
std::type_index(typeid(...)), second key: actual identifier to the resource (e.g.
std::string). Because those resources have no common parent class, the final type (which to embedd in the inner
std::map) needs to be
void* which isn't great for polymorphic stuff.
Btw my map looks currently like this:
std::map<std::type_index,
std::map<std::string, void*>
>
because I store pointers to different resources. The desired map would look like this:
std::map<std::type_index,
std::map<std::string, std::unique_ptr<sf::Loadable>>
>
Also this would allow to
dynamic_cast instead of
static_cast. Casting statically is not helpfull if you're using polymorphism. Else, dynamically casting provides this - but
void is not a base class for any of the used types ^^
Why not using a single std::map per resource type? I wrote a private template-based get/set for this entire map. The public interface calls this methods with a concrete type (e.g. sf::Texture). But I don't want to copy'n'paste the entire mechanisms for each new resource type. A "Loadable" interface would help, because I could derive my own resources (such as file streams) from Loadable and use them (just as sf::Texture if implementing Loadable^^) as polymorphic loadables.
Does anyone like this idea?