CreatureLib/src/Library/SpeciesLibrary.hpp

29 lines
1016 B
C++
Raw Normal View History

2019-10-06 11:50:52 +00:00
#ifndef CREATURELIB_SPECIESLIBRARY_HPP
#define CREATURELIB_SPECIESLIBRARY_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<uint16_t, 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* value) override {
BaseLibrary::Insert(key, value);
_valuesById.Insert(value->GetId(), value);
}
void Insert(uint32_t hashedKey, const CreatureSpecies* value) override {
BaseLibrary::Insert(hashedKey, value);
_valuesById.Insert(value->GetId(), value);
}
const ArbUt::BorrowedPtr<const CreatureSpecies>& GetById(uint16_t id) const { return _valuesById[id]; }
2019-10-06 11:50:52 +00:00
};
}
#endif // CREATURELIB_SPECIESLIBRARY_HPP