CreatureLib/src/Library/SpeciesLibrary.hpp

32 lines
982 B
C++
Raw Normal View History

2019-10-06 11:50:52 +00:00
#ifndef CREATURELIB_SPECIESLIBRARY_HPP
#define CREATURELIB_SPECIESLIBRARY_HPP
#include <string>
#include <unordered_map>
#include "CreatureData/CreatureSpecies.hpp"
namespace CreatureLib::Library {
class SpeciesLibrary {
private:
std::unordered_map<std::string, const CreatureSpecies*> _species;
2019-10-06 11:50:52 +00:00
public:
SpeciesLibrary(size_t initialCapacity = 32)
: _species(std::unordered_map<std::string, const CreatureSpecies*>(initialCapacity)){};
2019-10-06 11:50:52 +00:00
~SpeciesLibrary() {
for (auto s : _species)
2019-10-06 12:06:17 +00:00
delete s.second;
2019-10-06 11:50:52 +00:00
_species.clear();
}
[[nodiscard]] const CreatureSpecies* GetSpecies(const std::string& name) const;
[[nodiscard]] const CreatureSpecies* operator[](const std::string& name) const;
2019-10-06 11:50:52 +00:00
void LoadSpecies(const std::string& name, const CreatureSpecies* species);
void DeleteSpecies(const std::string& name);
};
}
#endif // CREATURELIB_SPECIESLIBRARY_HPP