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

@ -0,0 +1,57 @@
#include "property.hpp"
#include <cppbase/logger.hpp>
#include <ikarus/objects/properties/property_type.h>
#include <persistence/function_context.hpp>
#include <persistence/project.hpp>
IkarusProperty::IkarusProperty(IkarusProject * project, IkarusId id, Data data):
IkarusObject{project, id},
_data{data} {}
cppbase::Result<IkarusPropertyType, sqlitecpp::SingleQueryError> IkarusProperty::get_property_type(
IkarusProject * project, IkarusId id
) {
LOG_DEBUG("fetching unboxed property type");
LOG_VERBOSE("project={};property={}", project->get_path().c_str(), id);
VTRY(auto const type, project->get_db()->query_one<int>("SELECT `type` FROM `objects` WHERE `id` = ?", id));
return cppbase::ok(static_cast<IkarusPropertyType>(type));
}
IKA_API void ikarus_property_delete(IkarusProperty * property) {
LOG_INFO("deleting property");
LOG_VERBOSE("project={};property={}", property->get_project()->get_path().c_str(), property->get_id());
auto * ctx = property->get_project()->get_function_context();
TRYRV(
,
property->get_project()
->get_db()
->execute("DELETE FROM `objects` WHERE `id` = ?", property->get_id())
.on_error([ctx](auto const& err) {
ctx->set_error(
fmt::format("failed to delete property from objects table: {}", err),
true,
IkarusErrorInfo_Source_SubSystem,
IkarusErrorInfo_Type_SubSystem_Database
);
})
);
LOG_VERBOSE("property was successfully deleted from database, freeing");
property->get_project()->uncache_property(property);
LOG_VERBOSE("successfully deleted property");
}
IkarusPropertyType ikarus_property_get_type(IkarusProperty const * property) {
LOG_DEBUG("fetching property type");
}