ReUseX  0.0.5
3D Point Cloud Processing for Building Reuse
Loading...
Searching...
No Matches
resources.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 Povl Filip Sonne-Frederiksen
2//
3// SPDX-License-Identifier: GPL-3.0-or-later
4
5#pragma once
6
12
13#include "reusex/core/ProjectDB.hpp"
14#include "reusex/core/resource_keys.hpp"
15
16#include <cstddef>
17#include <cstdint>
18#include <optional>
19#include <stdexcept>
20#include <string>
21#include <string_view>
22#include <vector>
23
24namespace reusex::core {
25
27 std::string key;
28 std::optional<std::string> value;
29};
30struct Resource {
31 std::string code;
32 int64_t type_id = 0;
33 bool manual = false;
34 std::vector<ResourceValue> values;
35};
36
37std::optional<std::string> value_of(const Resource &r, std::string_view key);
38
44std::vector<Resource> list_resources(
45 const ProjectDB &db,
46 const std::optional<std::vector<std::string>> &keys = std::nullopt);
49resource(const ProjectDB &db, std::string_view code,
50 const std::optional<std::vector<std::string>> &keys = std::nullopt);
51
53 std::string key;
54 std::optional<std::string> value;
55};
60 std::vector<Resource> siblings;
61};
62
69 ProjectDB &db, std::string_view code,
70 const std::vector<ResourceWrite> &writes,
71 const std::optional<std::vector<std::string>> &keys = std::nullopt);
72
74inline constexpr std::string_view kDesignationField = "designation";
77Resource create_resource(ProjectDB &db, int64_t type_id,
78 const std::optional<std::string> &name = std::nullopt);
79
87void delete_resource(ProjectDB &db, std::string_view code);
93 std::size_t parts_deleted = 0;
94 std::size_t instances_dismissed = 0;
95};
97
100 std::optional<std::string> name, type;
101 std::optional<std::vector<std::string>> options;
102 std::optional<int> sort_order, width;
103};
104
114void delete_column(ProjectDB &db, const std::string &id);
120update_column(ProjectDB &db, const std::string &id, const ColumnPatch &patch);
121
122} // namespace reusex::core
Wire form of one stored report PDF version — the ReportPdfVersion schema in ruxd's API contract (docs...
std::optional< std::string > value_of(const Resource &r, std::string_view key)
The value stored under key in r, or nullopt (absent or unset).
ResourcePatchResult patch_resource(ProjectDB &db, std::string_view code, const std::vector< ResourceWrite > &writes, const std::optional< std::vector< std::string > > &keys=std::nullopt)
Validate every write (normalise_value), then apply them in one transaction: type-scoped keys to the s...
SurveyTypeDeletion delete_survey_type(ProjectDB &db, int64_t type_id)
constexpr std::string_view kDesignationField
The leksikon field a hand-added resource's name is stored under.
Definition resources.hpp:74
void delete_column(ProjectDB &db, const std::string &id)
Delete a user column and, in the same transaction, every value stored under its name (logged at warn ...
Resource create_resource(ProjectDB &db, int64_t type_id, const std::optional< std::string > &name=std::nullopt)
A manual part with the next RX code; name becomes its designation.
ProjectDB::PropertyDefinition create_column(ProjectDB &db, ProjectDB::PropertyDefinition def)
Add a user column (def.id is ignored and returned filled in).
std::vector< Resource > list_resources(const ProjectDB &db, const std::optional< std::vector< std::string > > &keys=std::nullopt)
One per survey part, by code.
void delete_resource(ProjectDB &db, std::string_view code)
Delete a part — manual or instance-backed — in one transaction.
ProjectDB::PropertyDefinition update_column(ProjectDB &db, const std::string &id, const ColumnPatch &patch)
A rename moves the stored values in the same transaction.
Resource resource(const ProjectDB &db, std::string_view code, const std::optional< std::vector< std::string > > &keys=std::nullopt)
A user-defined column in the Notion-like material editor.
Sparse update of a user column definition.
Definition resources.hpp:99
std::optional< std::vector< std::string > > options
std::optional< std::string > type
std::optional< int > width
std::optional< std::string > name
std::optional< int > sort_order
std::vector< Resource > siblings
The type's other parts, when a type-scoped key was written (they changed too); empty otherwise.
Definition resources.hpp:60
std::optional< std::string > value
nullopt: not set
Definition resources.hpp:28
std::optional< std::string > value
nullopt clears
Definition resources.hpp:54
bool manual
added by hand: no instance behind it
Definition resources.hpp:33
std::vector< ResourceValue > values
Definition resources.hpp:34
Delete a survey type and every part in it, with delete_resource's rules for each part (tombstones,...
Definition resources.hpp:92
std::size_t instances_dismissed
scan-backed parts, now tombstoned
Definition resources.hpp:94