Fixes DataLibrary not having correct const definitions.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2020-05-26 15:02:41 +02:00
parent ecf1c47a53
commit e46117ea06
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
4 changed files with 28 additions and 24 deletions

View File

@ -24,25 +24,25 @@ BattleLibrary::~BattleLibrary() {
delete _miscLibrary; delete _miscLibrary;
} }
const std::unique_ptr<CreatureLib::Library::LibrarySettings>& BattleLibrary::GetSettings() const noexcept { const std::unique_ptr<const CreatureLib::Library::LibrarySettings>& BattleLibrary::GetSettings() const noexcept {
return _staticLib->GetSettings(); return _staticLib->GetSettings();
} }
const BattleStatCalculator* BattleLibrary::GetStatCalculator() const noexcept { return _statCalculator; } const BattleStatCalculator* BattleLibrary::GetStatCalculator() const noexcept { return _statCalculator; }
const std::unique_ptr<CreatureLib::Library::SpeciesLibrary>& BattleLibrary::GetSpeciesLibrary() const noexcept { const std::unique_ptr<const CreatureLib::Library::SpeciesLibrary>& BattleLibrary::GetSpeciesLibrary() const noexcept {
return _staticLib->GetSpeciesLibrary(); return _staticLib->GetSpeciesLibrary();
} }
const std::unique_ptr<CreatureLib::Library::ItemLibrary>& BattleLibrary::GetItemLibrary() const noexcept { const std::unique_ptr<const CreatureLib::Library::ItemLibrary>& BattleLibrary::GetItemLibrary() const noexcept {
return _staticLib->GetItemLibrary(); return _staticLib->GetItemLibrary();
} }
const std::unique_ptr<CreatureLib::Library::AttackLibrary>& BattleLibrary::GetAttackLibrary() const noexcept { const std::unique_ptr<const CreatureLib::Library::AttackLibrary>& BattleLibrary::GetAttackLibrary() const noexcept {
return _staticLib->GetAttackLibrary(); return _staticLib->GetAttackLibrary();
} }
const std::unique_ptr<CreatureLib::Library::TypeLibrary>& BattleLibrary::GetTypeLibrary() const noexcept { const std::unique_ptr<const CreatureLib::Library::TypeLibrary>& BattleLibrary::GetTypeLibrary() const noexcept {
return _staticLib->GetTypeLibrary(); return _staticLib->GetTypeLibrary();
} }

View File

@ -25,12 +25,12 @@ namespace CreatureLib::Battling {
~BattleLibrary(); ~BattleLibrary();
inline const Library::DataLibrary* GetStaticLib() const noexcept { return _staticLib; } inline const Library::DataLibrary* GetStaticLib() const noexcept { return _staticLib; }
[[nodiscard]] const std::unique_ptr<Library::LibrarySettings>& GetSettings() const noexcept; [[nodiscard]] const std::unique_ptr<const Library::LibrarySettings>& GetSettings() const noexcept;
[[nodiscard]] const std::unique_ptr<Library::SpeciesLibrary>& GetSpeciesLibrary() const noexcept; [[nodiscard]] const std::unique_ptr<const Library::SpeciesLibrary>& GetSpeciesLibrary() const noexcept;
[[nodiscard]] const std::unique_ptr<Library::ItemLibrary>& GetItemLibrary() const noexcept; [[nodiscard]] const std::unique_ptr<const Library::ItemLibrary>& GetItemLibrary() const noexcept;
[[nodiscard]] const std::unique_ptr<Library::AttackLibrary>& GetAttackLibrary() const noexcept; [[nodiscard]] const std::unique_ptr<const Library::AttackLibrary>& GetAttackLibrary() const noexcept;
[[nodiscard]] const std::unique_ptr<Library::TypeLibrary>& GetTypeLibrary() const noexcept; [[nodiscard]] const std::unique_ptr<const Library::TypeLibrary>& GetTypeLibrary() const noexcept;
[[nodiscard]] const std::unique_ptr<Library::GrowthRateLibrary>& GetGrowthRateLibrary() const noexcept { [[nodiscard]] const std::unique_ptr<const Library::GrowthRateLibrary>& GetGrowthRateLibrary() const noexcept {
return _staticLib->GetGrowthRates(); return _staticLib->GetGrowthRates();
} }

View File

@ -58,7 +58,7 @@ namespace CreatureLib::Library {
[[nodiscard]] inline borrowed_ptr<const T> Get(const Arbutils::CaseInsensitiveConstString& name) const { [[nodiscard]] inline borrowed_ptr<const T> Get(const Arbutils::CaseInsensitiveConstString& name) const {
return _values.Get(name.GetHash()); return _values.Get(name.GetHash());
} }
[[nodiscard]] inline borrowed_ptr<const T> Get(uint32_t hashedKey) { return _values.Get(hashedKey); } [[nodiscard]] inline borrowed_ptr<const T> Get(uint32_t hashedKey) const { return _values.Get(hashedKey); }
[[nodiscard]] inline borrowed_ptr<const T> operator[](const Arbutils::CaseInsensitiveConstString& name) const { [[nodiscard]] inline borrowed_ptr<const T> operator[](const Arbutils::CaseInsensitiveConstString& name) const {
return Get(name); return Get(name);

View File

@ -14,12 +14,12 @@ namespace CreatureLib::Library {
*/ */
class DataLibrary { class DataLibrary {
private: private:
const std::unique_ptr<LibrarySettings> _settings; std::unique_ptr<const LibrarySettings> _settings;
const std::unique_ptr<SpeciesLibrary> _species; std::unique_ptr<const SpeciesLibrary> _species;
const std::unique_ptr<AttackLibrary> _attacks; std::unique_ptr<const AttackLibrary> _attacks;
const std::unique_ptr<ItemLibrary> _items; std::unique_ptr<const ItemLibrary> _items;
const std::unique_ptr<GrowthRateLibrary> _growthRates; std::unique_ptr<const GrowthRateLibrary> _growthRates;
const std::unique_ptr<TypeLibrary> _typeLibrary; std::unique_ptr<const TypeLibrary> _typeLibrary;
public: public:
DataLibrary(LibrarySettings* settings, CreatureLib::Library::SpeciesLibrary* species, DataLibrary(LibrarySettings* settings, CreatureLib::Library::SpeciesLibrary* species,
@ -28,12 +28,16 @@ namespace CreatureLib::Library {
virtual ~DataLibrary() {} virtual ~DataLibrary() {}
[[nodiscard]] const std::unique_ptr<LibrarySettings>& GetSettings() const noexcept { return _settings; } [[nodiscard]] const std::unique_ptr<const LibrarySettings>& GetSettings() const noexcept { return _settings; }
[[nodiscard]] const std::unique_ptr<SpeciesLibrary>& GetSpeciesLibrary() const noexcept { return _species; } [[nodiscard]] const std::unique_ptr<const SpeciesLibrary>& GetSpeciesLibrary() const noexcept {
[[nodiscard]] const std::unique_ptr<AttackLibrary>& GetAttackLibrary() const noexcept { return _attacks; } return _species;
[[nodiscard]] const std::unique_ptr<ItemLibrary>& GetItemLibrary() const noexcept { return _items; } }
[[nodiscard]] const std::unique_ptr<GrowthRateLibrary>& GetGrowthRates() const noexcept { return _growthRates; } [[nodiscard]] const std::unique_ptr<const AttackLibrary>& GetAttackLibrary() const noexcept { return _attacks; }
[[nodiscard]] const std::unique_ptr<TypeLibrary>& GetTypeLibrary() const noexcept { return _typeLibrary; } [[nodiscard]] const std::unique_ptr<const ItemLibrary>& GetItemLibrary() const noexcept { return _items; }
[[nodiscard]] const std::unique_ptr<const GrowthRateLibrary>& GetGrowthRates() const noexcept {
return _growthRates;
}
[[nodiscard]] const std::unique_ptr<const TypeLibrary>& GetTypeLibrary() const noexcept { return _typeLibrary; }
}; };
} }