|
PACS System 0.1.0
PACS DICOM system library
|
#include <file_storage.h>


Public Member Functions | |
| file_storage (const file_storage_config &config) | |
| Construct file storage with configuration. | |
| ~file_storage () override=default | |
| Destructor. | |
| file_storage (const file_storage &)=delete | |
| Non-copyable (contains mutex) | |
| file_storage & | operator= (const file_storage &)=delete |
| file_storage (file_storage &&)=delete | |
| Non-movable (contains mutex) | |
| file_storage & | operator= (file_storage &&)=delete |
| auto | store (const core::dicom_dataset &dataset) -> VoidResult override |
| Store a DICOM dataset to filesystem. | |
| auto | retrieve (std::string_view sop_instance_uid) -> Result< core::dicom_dataset > override |
| Retrieve a DICOM dataset by SOP Instance UID. | |
| auto | remove (std::string_view sop_instance_uid) -> VoidResult override |
| Remove a DICOM file by SOP Instance UID. | |
| auto | exists (std::string_view sop_instance_uid) const -> bool override |
| Check if a DICOM instance exists. | |
| auto | find (const core::dicom_dataset &query) -> Result< std::vector< core::dicom_dataset > > override |
| Find DICOM datasets matching query criteria. | |
| auto | get_statistics () const -> storage_statistics override |
| Get storage statistics. | |
| auto | verify_integrity () -> VoidResult override |
| Verify storage integrity. | |
| auto | get_file_path (std::string_view sop_instance_uid) const -> std::filesystem::path |
| Get the filesystem path for a SOP Instance UID. | |
| auto | import_directory (const std::filesystem::path &source) -> VoidResult |
| Import DICOM files from a directory. | |
| auto | root_path () const -> const std::filesystem::path & |
| Get the root storage path. | |
| auto | rebuild_index () -> VoidResult |
| Rebuild the internal index from filesystem. | |
Public Member Functions inherited from kcenon::pacs::storage::storage_interface | |
| virtual | ~storage_interface ()=default |
| Virtual destructor for proper polymorphic destruction. | |
| virtual auto | store_batch (const std::vector< core::dicom_dataset > &datasets) -> VoidResult |
| Store multiple DICOM datasets in a single operation. | |
| virtual auto | retrieve_batch (const std::vector< std::string > &sop_instance_uids) -> Result< std::vector< core::dicom_dataset > > |
| Retrieve multiple DICOM datasets by their SOP Instance UIDs. | |
Private Member Functions | |
| auto | build_path (std::string_view study_uid, std::string_view series_uid, std::string_view sop_uid) const -> std::filesystem::path |
| Build filesystem path for a dataset. | |
| auto | build_date_path (std::string_view study_date, std::string_view study_uid, std::string_view sop_uid) const -> std::filesystem::path |
| Build filesystem path using date-based hierarchy. | |
| void | update_index (const std::string &sop_uid, const std::filesystem::path &path) |
| Update internal index with new mapping. | |
| void | remove_from_index (const std::string &sop_uid) |
| Remove entry from internal index. | |
Static Private Member Functions | |
| static auto | matches_query (const core::dicom_dataset &dataset, const core::dicom_dataset &query) -> bool |
| Check if dataset matches query criteria. | |
| static auto | sanitize_uid (std::string_view uid) -> std::string |
| Sanitize UID for use in filesystem path. | |
Private Attributes | |
| file_storage_config | config_ |
| Storage configuration. | |
| std::unordered_map< std::string, std::filesystem::path > | index_ |
| Mapping from SOP Instance UID to file path. | |
| std::shared_mutex | mutex_ |
| Mutex for thread-safe access. | |
Additional Inherited Members | |
Protected Member Functions inherited from kcenon::pacs::storage::storage_interface | |
| storage_interface ()=default | |
| Protected default constructor for derived classes. | |
| storage_interface (const storage_interface &)=delete | |
| Non-copyable. | |
| storage_interface & | operator= (const storage_interface &)=delete |
| storage_interface (storage_interface &&)=default | |
| Movable. | |
| storage_interface & | operator= (storage_interface &&)=default |
Definition at line 122 of file file_storage.h.
|
explicit |
Construct file storage with configuration.
| config | Storage configuration |
| std::runtime_error | if root_path is invalid and create_directories is false |
Definition at line 56 of file file_storage.cpp.
References config_, kcenon::pacs::storage::file_storage_config::create_directories, if(), and kcenon::pacs::storage::file_storage_config::root_path.

|
overridedefault |
Destructor.
|
delete |
Non-copyable (contains mutex)
|
delete |
Non-movable (contains mutex)
|
nodiscardprivate |
Build filesystem path using date-based hierarchy.
| study_date | Study date (YYYYMMDD format) |
| study_uid | Study Instance UID |
| sop_uid | SOP Instance UID |
Definition at line 472 of file file_storage.cpp.
|
nodiscardprivate |
Build filesystem path for a dataset.
| study_uid | Study Instance UID |
| series_uid | Series Instance UID |
| sop_uid | SOP Instance UID |
Definition at line 463 of file file_storage.cpp.
|
nodiscardoverridevirtual |
Check if a DICOM instance exists.
| sop_instance_uid | The unique identifier to check |
Implements kcenon::pacs::storage::storage_interface.
Definition at line 247 of file file_storage.cpp.
|
nodiscardoverridevirtual |
Find DICOM datasets matching query criteria.
Scans the storage directory and matches datasets against query.
| query | The query dataset containing search criteria |
Implements kcenon::pacs::storage::storage_interface.
Definition at line 252 of file file_storage.cpp.
References kcenon::pacs::core::dicom_file::open(), and uid.

|
nodiscard |
Get the filesystem path for a SOP Instance UID.
| sop_instance_uid | The SOP Instance UID |
Definition at line 375 of file file_storage.cpp.
|
nodiscardoverridevirtual |
Get storage statistics.
Implements kcenon::pacs::storage::storage_interface.
Definition at line 280 of file file_storage.cpp.
References index_, mutex_, kcenon::pacs::core::dicom_file::open(), kcenon::pacs::core::tags::patient_id, kcenon::pacs::core::tags::series_instance_uid, kcenon::pacs::core::tags::study_instance_uid, and uid.

|
nodiscard |
Import DICOM files from a directory.
Recursively scans the source directory for DICOM files and imports them.
| source | Source directory to import from |
Definition at line 385 of file file_storage.cpp.
References kcenon::pacs::core::dicom_file::open().

|
staticnodiscardprivate |
Check if dataset matches query criteria.
| dataset | The dataset to check |
| query | The query criteria |
Definition at line 502 of file file_storage.cpp.
|
delete |
|
delete |
|
nodiscard |
Rebuild the internal index from filesystem.
Scans the storage directory and rebuilds the SOP UID to path mapping.
Definition at line 422 of file file_storage.cpp.
References kcenon::pacs::core::dicom_file::open(), and kcenon::pacs::core::tags::sop_instance_uid.

|
nodiscardoverridevirtual |
Remove a DICOM file by SOP Instance UID.
| sop_instance_uid | The unique identifier for the instance to remove |
Implements kcenon::pacs::storage::storage_interface.
Definition at line 214 of file file_storage.cpp.
|
private |
Remove entry from internal index.
| sop_uid | SOP Instance UID |
Definition at line 497 of file file_storage.cpp.
|
nodiscardoverridevirtual |
Retrieve a DICOM dataset by SOP Instance UID.
| sop_instance_uid | The unique identifier for the instance |
Implements kcenon::pacs::storage::storage_interface.
Definition at line 186 of file file_storage.cpp.
References kcenon::pacs::core::dicom_file::open().

|
nodiscard |
Get the root storage path.
Definition at line 418 of file file_storage.cpp.
References config_, and kcenon::pacs::storage::file_storage_config::root_path.
|
staticnodiscardprivate |
Sanitize UID for use in filesystem path.
| uid | The UID to sanitize |
Definition at line 575 of file file_storage.cpp.
References uid.
|
nodiscardoverridevirtual |
Store a DICOM dataset to filesystem.
Extracts UIDs from the dataset and stores as a Part 10 file. Uses atomic write pattern: writes to temp file, then renames.
| dataset | The DICOM dataset to store |
Implements kcenon::pacs::storage::storage_interface.
Definition at line 75 of file file_storage.cpp.
References kcenon::pacs::core::dicom_file::create(), kcenon::pacs::storage::date_hierarchical, kcenon::pacs::encoding::transfer_syntax::explicit_vr_little_endian, kcenon::pacs::storage::flat, kcenon::pacs::storage::ignore, kcenon::pacs::storage::reject, kcenon::pacs::storage::replace, kcenon::pacs::core::tags::series_instance_uid, kcenon::pacs::core::tags::sop_instance_uid, kcenon::pacs::core::tags::study_date, kcenon::pacs::core::tags::study_instance_uid, and kcenon::pacs::storage::uid_hierarchical.

|
private |
Update internal index with new mapping.
| sop_uid | SOP Instance UID |
| path | File path |
Definition at line 491 of file file_storage.cpp.
|
nodiscardoverridevirtual |
Verify storage integrity.
Checks that all indexed files exist and are valid DICOM files.
Implements kcenon::pacs::storage::storage_interface.
Definition at line 328 of file file_storage.cpp.
References kcenon::pacs::core::dicom_file::open(), kcenon::pacs::core::tags::sop_instance_uid, and uid.

|
private |
Storage configuration.
Definition at line 327 of file file_storage.h.
Referenced by file_storage(), and root_path().
|
private |
Mapping from SOP Instance UID to file path.
Definition at line 330 of file file_storage.h.
Referenced by get_statistics(), remove_from_index(), and update_index().
|
mutableprivate |
Mutex for thread-safe access.
Definition at line 333 of file file_storage.h.
Referenced by get_statistics(), remove_from_index(), and update_index().