|
PACS System 0.1.0
PACS DICOM system library
|
Thumbnail generation and caching service. More...
#include <thumbnail_service.h>
Classes | |
| struct | cache_key |
| Cache key for lookups. More... | |
| struct | cache_key_hash |
| Hash function for cache key. More... | |
Public Member Functions | |
| thumbnail_service (std::shared_ptr< storage::index_database > database) | |
| Construct thumbnail service with database. | |
| ~thumbnail_service () | |
| Destructor. | |
| thumbnail_service (const thumbnail_service &)=delete | |
| Non-copyable, non-movable (due to shared_mutex member) | |
| thumbnail_service & | operator= (const thumbnail_service &)=delete |
| thumbnail_service (thumbnail_service &&)=delete | |
| thumbnail_service & | operator= (thumbnail_service &&)=delete |
| thumbnail_result | get_thumbnail (std::string_view sop_instance_uid, const thumbnail_params ¶ms) |
| Get or generate thumbnail for a specific instance. | |
| thumbnail_result | get_series_thumbnail (std::string_view series_uid, const thumbnail_params ¶ms) |
| Get thumbnail for a series (representative image) | |
| thumbnail_result | get_study_thumbnail (std::string_view study_uid, const thumbnail_params ¶ms) |
| Get thumbnail for a study (representative image) | |
| void | clear_cache () |
| Clear all cached thumbnails. | |
| void | clear_cache (std::string_view sop_instance_uid) |
| Clear cached thumbnails for a specific instance. | |
| size_t | cache_size () const |
| Get current cache size in bytes. | |
| size_t | cache_entry_count () const |
| Get number of cached entries. | |
| void | set_max_cache_size (size_t max_bytes) |
| Set maximum cache size. | |
| size_t | max_cache_size () const |
| Get maximum cache size. | |
Private Member Functions | |
| std::vector< uint8_t > | generate_thumbnail (std::string_view file_path, const thumbnail_params ¶ms) |
| Generate thumbnail from DICOM file. | |
| std::optional< std::string > | select_representative_instance (std::string_view series_uid) |
| Select representative instance from series. | |
| std::optional< std::string > | select_representative_series (std::string_view study_uid) |
| Select representative series from study. | |
| void | evict_lru () |
| Evict least recently used entries to make room. | |
Static Private Member Functions | |
| static std::string | get_content_type (std::string_view format) |
| Get MIME type for format. | |
Private Attributes | |
| std::shared_ptr< storage::index_database > | database_ |
| Database for instance lookups. | |
| std::unordered_map< cache_key, thumbnail_cache_entry, cache_key_hash > | cache_ |
| Thumbnail cache. | |
| std::shared_mutex | cache_mutex_ |
| Cache mutex. | |
| size_t | current_cache_size_ {0} |
| Current cache size in bytes. | |
| size_t | max_cache_size_ {64 * 1024 * 1024} |
| Maximum cache size (default: 64MB) | |
Thumbnail generation and caching service.
Generates thumbnails from DICOM images with server-side caching. Supports multiple output formats and sizes.
Definition at line 125 of file thumbnail_service.h.
|
explicit |
Construct thumbnail service with database.
| database | Index database for instance lookups |
Definition at line 41 of file thumbnail_service.cpp.
|
default |
Destructor.
|
delete |
Non-copyable, non-movable (due to shared_mutex member)
|
delete |
|
nodiscard |
Get number of cached entries.
Definition at line 179 of file thumbnail_service.cpp.
References cache_, and cache_mutex_.
|
nodiscard |
Get current cache size in bytes.
Definition at line 174 of file thumbnail_service.cpp.
References cache_mutex_, and current_cache_size_.
| void kcenon::pacs::web::thumbnail_service::clear_cache | ( | ) |
Clear all cached thumbnails.
Definition at line 154 of file thumbnail_service.cpp.
References cache_, cache_mutex_, and current_cache_size_.
| void kcenon::pacs::web::thumbnail_service::clear_cache | ( | std::string_view | sop_instance_uid | ) |
Clear cached thumbnails for a specific instance.
| sop_instance_uid | SOP Instance UID to clear |
Definition at line 160 of file thumbnail_service.cpp.
References cache_, cache_mutex_, and current_cache_size_.
|
private |
Evict least recently used entries to make room.
Definition at line 560 of file thumbnail_service.cpp.
References cache_, and current_cache_size_.
Referenced by get_thumbnail(), and set_max_cache_size().
|
nodiscardprivate |
Generate thumbnail from DICOM file.
| file_path | Path to DICOM file |
| params | Thumbnail parameters |
Definition at line 203 of file thumbnail_service.cpp.
References kcenon::pacs::core::tags::columns, kcenon::pacs::web::thumbnail_params::format, kcenon::pacs::web::thumbnail_params::frame, kcenon::pacs::core::tags::photometric_interpretation, kcenon::pacs::core::tags::pixel_data, kcenon::pacs::web::thumbnail_params::quality, kcenon::pacs::core::tags::rows, kcenon::pacs::core::tags::samples_per_pixel, and kcenon::pacs::web::thumbnail_params::size.
Referenced by get_thumbnail().
|
staticnodiscardprivate |
Get MIME type for format.
| format | Format string |
Definition at line 578 of file thumbnail_service.cpp.
Referenced by get_thumbnail().
|
nodiscard |
Get thumbnail for a series (representative image)
| series_uid | Series Instance UID |
| params | Thumbnail parameters |
Selects the middle slice or key image from the series.
Definition at line 130 of file thumbnail_service.cpp.
References kcenon::pacs::web::thumbnail_result::error(), get_thumbnail(), and select_representative_instance().
Referenced by get_study_thumbnail().
|
nodiscard |
Get thumbnail for a study (representative image)
| study_uid | Study Instance UID |
| params | Thumbnail parameters |
Selects the representative image from the primary series.
Definition at line 140 of file thumbnail_service.cpp.
References kcenon::pacs::web::thumbnail_result::error(), get_series_thumbnail(), and select_representative_series().
|
nodiscard |
Get or generate thumbnail for a specific instance.
| sop_instance_uid | SOP Instance UID |
| params | Thumbnail parameters |
Definition at line 51 of file thumbnail_service.cpp.
References cache_, cache_mutex_, kcenon::pacs::web::thumbnail_cache_entry::content_type, kcenon::pacs::web::thumbnail_cache_entry::created_at, current_cache_size_, kcenon::pacs::web::thumbnail_cache_entry::data, database_, kcenon::pacs::web::thumbnail_result::error(), evict_lru(), kcenon::pacs::web::thumbnail_params::format, kcenon::pacs::web::thumbnail_params::frame, generate_thumbnail(), get_content_type(), kcenon::pacs::web::thumbnail_cache_entry::last_accessed, max_cache_size_, kcenon::pacs::web::thumbnail_result::ok(), kcenon::pacs::web::thumbnail_params::quality, and kcenon::pacs::web::thumbnail_params::size.
Referenced by get_series_thumbnail().
|
nodiscard |
Get maximum cache size.
Definition at line 194 of file thumbnail_service.cpp.
References cache_mutex_, and max_cache_size_.
|
delete |
|
delete |
|
nodiscardprivate |
Select representative instance from series.
| series_uid | Series Instance UID |
Definition at line 505 of file thumbnail_service.cpp.
References database_.
Referenced by get_series_thumbnail().
|
nodiscardprivate |
Select representative series from study.
| study_uid | Study Instance UID |
Definition at line 529 of file thumbnail_service.cpp.
References database_, kcenon::pacs::storage::series_record::num_instances, and kcenon::pacs::storage::series_record::series_uid.
Referenced by get_study_thumbnail().
| void kcenon::pacs::web::thumbnail_service::set_max_cache_size | ( | size_t | max_bytes | ) |
Set maximum cache size.
| max_bytes | Maximum cache size in bytes |
Definition at line 184 of file thumbnail_service.cpp.
References cache_, cache_mutex_, current_cache_size_, evict_lru(), and max_cache_size_.
|
private |
Thumbnail cache.
Definition at line 248 of file thumbnail_service.h.
Referenced by cache_entry_count(), clear_cache(), clear_cache(), evict_lru(), get_thumbnail(), and set_max_cache_size().
|
mutableprivate |
Cache mutex.
Definition at line 251 of file thumbnail_service.h.
Referenced by cache_entry_count(), cache_size(), clear_cache(), clear_cache(), get_thumbnail(), max_cache_size(), and set_max_cache_size().
|
private |
Current cache size in bytes.
Definition at line 254 of file thumbnail_service.h.
Referenced by cache_size(), clear_cache(), clear_cache(), evict_lru(), get_thumbnail(), and set_max_cache_size().
|
private |
Database for instance lookups.
Definition at line 245 of file thumbnail_service.h.
Referenced by get_thumbnail(), select_representative_instance(), and select_representative_series().
|
private |
Maximum cache size (default: 64MB)
Definition at line 257 of file thumbnail_service.h.
Referenced by get_thumbnail(), max_cache_size(), and set_max_cache_size().