fixup compile errors and allow fetching property properly from cache

Signed-off-by: Folling <mail@folling.io>
This commit is contained in:
folling 2023-11-27 13:13:54 +01:00 committed by Folling
parent aa6f711251
commit f9de016dfe
Signed by: folling
SSH key fingerprint: SHA256:S9qEx5WCFFLK49tE/LKnKuJYM5sw+++Dn6qJbbyxnCY
21 changed files with 213 additions and 122 deletions

View file

@ -2,6 +2,9 @@
#include "ikarus/persistence/project.h"
#include <objects/properties/number_property.hpp>
#include <objects/properties/text_property.hpp>
#include <objects/properties/toggle_property.hpp>
#include <persistence/function_context.hpp>
auto IkarusProject::get_name() const -> std::string_view {
@ -21,11 +24,11 @@ auto IkarusProject::get_db() const -> sqlitecpp::Connection const * {
}
auto IkarusProject::get_function_context() -> FunctionContext * {
return &_function_contexts.emplace(this);
return &_function_contexts.emplace_back(this);
}
IkarusBlueprint * IkarusProject::get_blueprint(IkarusId id) {
return get_cached_object(id, this->_blueprints);
return get_cached_object<IkarusBlueprint>(id, this->_blueprints);
}
auto IkarusProject::uncache_blueprint(IkarusBlueprint * blueprint) -> void {
@ -33,15 +36,28 @@ auto IkarusProject::uncache_blueprint(IkarusBlueprint * blueprint) -> void {
}
auto IkarusProject::get_entity(IkarusId id) -> IkarusEntity * {
return get_cached_object(id, this->_entities);
return get_cached_object<IkarusEntity>(id, this->_entities);
}
auto IkarusProject::uncache_entity(IkarusEntity * entity) -> void {
remove_cached_object(entity, _entities);
}
auto IkarusProject::get_property(IkarusId id) -> IkarusProperty * {
return get_cached_object(id, this->_properties);
auto IkarusProject::get_property(IkarusId id, IkarusPropertyType type) -> IkarusProperty * {
auto const iter = _properties.find(id);
if (iter == _properties.cend()) {
switch (type) {
case IkarusPropertyType_Toggle:
return _properties.emplace(id, std::make_unique<IkarusToggleProperty>(this, id)).first->second.get();
case IkarusPropertyType_Number:
return _properties.emplace(id, std::make_unique<IkarusNumberProperty>(this, id)).first->second.get();
case IkarusPropertyType_Text:
return _properties.emplace(id, std::make_unique<IkarusTextProperty>(this, id)).first->second.get();
}
}
return iter->second.get();
}
auto IkarusProject::uncache_property(IkarusProperty * property) -> void {