CreatureLib/src/Library/SpeciesLibrary.hpp

26 lines
865 B
C++
Raw Normal View History

2019-10-06 11:50:52 +00:00
#ifndef CREATURELIB_SPECIESLIBRARY_HPP
#define CREATURELIB_SPECIESLIBRARY_HPP
#include <Arbutils/Collections/Dictionary.hpp>
#include "BaseLibrary.hpp"
2019-10-06 11:50:52 +00:00
#include "CreatureData/CreatureSpecies.hpp"
namespace CreatureLib::Library {
class SpeciesLibrary : public BaseLibrary<CreatureSpecies> {
2019-10-06 11:50:52 +00:00
private:
ArbUt::Dictionary<u16, ArbUt::BorrowedPtr<const CreatureSpecies>> _valuesById;
2019-10-06 11:50:52 +00:00
public:
SpeciesLibrary(size_t initialCapacity = 32) : BaseLibrary(initialCapacity){};
void Insert(const ArbUt::StringView& key, const CreatureSpecies* non_null value) override {
BaseLibrary::Insert(key, value);
_valuesById.Insert(value->GetId(), value);
}
const ArbUt::BorrowedPtr<const CreatureSpecies>& GetById(u16 id) const { return _valuesById[id]; }
2019-10-06 11:50:52 +00:00
};
}
#endif // CREATURELIB_SPECIESLIBRARY_HPP