PACS System 0.1.0
PACS DICOM system library
Loading...
Searching...
No Matches
prefetch_rule_repository.h
Go to the documentation of this file.
1// BSD 3-Clause License
2// Copyright (c) 2021-2025, 🍀☀🌕🌥 🌊
3// See the LICENSE file in the project root for full license information.
4
14#pragma once
15
18
19#ifdef PACS_WITH_DATABASE_SYSTEM
20
21namespace kcenon::pacs::storage {
22
26class prefetch_rule_repository
27 : public base_repository<client::prefetch_rule, std::string> {
28public:
29 explicit prefetch_rule_repository(
30 std::shared_ptr<pacs_database_adapter> db);
31
32 [[nodiscard]] auto find_by_rule_id(std::string_view rule_id)
33 -> result_type;
34
35 [[nodiscard]] auto find_enabled() -> list_result_type;
36
37 [[nodiscard]] auto find_by_trigger(client::prefetch_trigger trigger)
38 -> list_result_type;
39
40 [[nodiscard]] auto enable(std::string_view rule_id) -> VoidResult;
41
42 [[nodiscard]] auto disable(std::string_view rule_id) -> VoidResult;
43
44 [[nodiscard]] auto increment_triggered(std::string_view rule_id)
45 -> VoidResult;
46
47 [[nodiscard]] auto increment_studies_prefetched(
48 std::string_view rule_id,
49 size_t count = 1) -> VoidResult;
50
51protected:
52 [[nodiscard]] auto map_row_to_entity(const database_row& row) const
53 -> client::prefetch_rule override;
54
55 [[nodiscard]] auto entity_to_row(const client::prefetch_rule& entity) const
56 -> std::map<std::string, database_value> override;
57
58 [[nodiscard]] auto get_pk(const client::prefetch_rule& entity) const
59 -> std::string override;
60
61 [[nodiscard]] auto has_pk(const client::prefetch_rule& entity) const
62 -> bool override;
63
64 [[nodiscard]] auto select_columns() const
65 -> std::vector<std::string> override;
66
67private:
68 [[nodiscard]] auto parse_timestamp(const std::string& str) const
69 -> std::chrono::system_clock::time_point;
70
71 [[nodiscard]] auto format_timestamp(
72 std::chrono::system_clock::time_point tp) const -> std::string;
73
74 [[nodiscard]] static auto serialize_vector(
75 const std::vector<std::string>& vec) -> std::string;
76
77 [[nodiscard]] static auto deserialize_vector(
78 std::string_view json) -> std::vector<std::string>;
79};
80
81} // namespace kcenon::pacs::storage
82
83#endif // PACS_WITH_DATABASE_SYSTEM
Generic base repository for CRUD operations.
Types and structures for prefetch manager.