26#include <shared_mutex>
37class routing_repository;
107 std::shared_ptr<storage::routing_repository> repo,
109 std::shared_ptr<di::ILogger> logger =
nullptr);
121 std::shared_ptr<storage::routing_repository> repo,
123 std::shared_ptr<di::ILogger> logger =
nullptr);
162 [[nodiscard]]
auto remove_rule(std::string_view rule_id) -> kcenon::pacs::VoidResult;
170 [[nodiscard]]
auto get_rule(std::string_view rule_id)
const
171 -> std::optional<routing_rule>;
207 [[nodiscard]] auto
reorder_rules(const std::vector<std::
string>& rule_ids)
222 [[nodiscard]] auto
evaluate(const core::dicom_dataset& dataset)
232 -> std::vector<std::pair<std::
string, std::vector<
routing_action>>>;
245 void route(const core::dicom_dataset& dataset);
252 void route(std::string_view sop_instance_uid);
273 [[nodiscard]] auto
is_enabled() const noexcept ->
bool;
316 [[nodiscard]] auto
test_rules(const core::dicom_dataset& dataset) const
364 const core::dicom_dataset& dataset) const
371 std::string_view value,
372 bool case_sensitive) const ->
bool;
378 const core::dicom_dataset& dataset) const
397 std::shared_ptr<storage::routing_repository>
repo_;
void attach_to_storage_scp(services::storage_scp &scp)
Attach to a Storage SCP for automatic routing.
void set_routing_callback(routing_event_callback callback)
Set callback for routing events.
std::atomic< size_t > total_forwarded_
~routing_manager()
Destructor.
std::atomic< size_t > total_failed_
auto test_rules(const core::dicom_dataset &dataset) const -> routing_test_result
Test rules against a dataset without executing actions.
routing_manager(const routing_manager &)=delete
auto get_field_value(routing_field field, const core::dicom_dataset &dataset) const -> std::string
Get DICOM field value from dataset.
auto get_statistics() const -> routing_statistics
Get overall routing statistics.
auto get_rule(std::string_view rule_id) const -> std::optional< routing_rule >
Get a routing rule by ID.
auto remove_rule(std::string_view rule_id) -> kcenon::pacs::VoidResult
Remove a routing rule.
std::shared_mutex rules_mutex_
auto match_pattern(std::string_view pattern, std::string_view value, bool case_sensitive) const -> bool
Match a wildcard pattern against a value.
void enable()
Enable routing globally.
auto get_rule_statistics(std::string_view rule_id) const -> routing_statistics
Get statistics for a specific rule.
routing_manager(std::shared_ptr< storage::routing_repository > repo, std::shared_ptr< job_manager > job_manager, std::shared_ptr< di::ILogger > logger=nullptr)
Construct a routing manager with default configuration.
auto evaluate(const core::dicom_dataset &dataset) -> std::vector< routing_action >
Evaluate rules against a dataset.
auto set_rule_priority(std::string_view rule_id, int priority) -> kcenon::pacs::VoidResult
Set the priority of a rule.
routing_event_callback routing_callback_
auto config() const noexcept -> const routing_manager_config &
Get current configuration.
void route(const core::dicom_dataset &dataset)
Route a DICOM dataset based on matching rules.
std::shared_ptr< storage::routing_repository > repo_
auto reorder_rules(const std::vector< std::string > &rule_ids) -> kcenon::pacs::VoidResult
Reorder rules by specifying the desired order.
void load_rules()
Load rules from repository into cache.
std::shared_ptr< di::ILogger > logger_
std::atomic< bool > enabled_
services::storage_scp * attached_scp_
std::shared_ptr< job_manager > job_manager_
void reset_statistics()
Reset all statistics.
auto match_condition(const routing_condition &condition, const core::dicom_dataset &dataset) const -> bool
Check if a condition matches a dataset.
auto is_enabled() const noexcept -> bool
Check if routing is enabled.
std::atomic< size_t > total_matched_
void disable()
Disable routing globally.
auto list_rules() const -> std::vector< routing_rule >
List all routing rules.
routing_manager_config config_
std::atomic< size_t > total_evaluated_
auto add_rule(const routing_rule &rule) -> kcenon::pacs::VoidResult
Add a new routing rule.
auto operator=(routing_manager &&) -> routing_manager &=delete
void detach_from_storage_scp()
Detach from the currently attached Storage SCP.
auto operator=(const routing_manager &) -> routing_manager &=delete
auto evaluate_with_rule_ids(const core::dicom_dataset &dataset) -> std::vector< std::pair< std::string, std::vector< routing_action > > >
Evaluate rules and return with matched rule IDs.
auto update_rule(const routing_rule &rule) -> kcenon::pacs::VoidResult
Update an existing routing rule.
auto list_enabled_rules() const -> std::vector< routing_rule >
List only enabled routing rules.
std::vector< routing_rule > rules_
routing_manager(routing_manager &&)=delete
void execute_actions(const std::string &sop_instance_uid, const std::vector< routing_action > &actions)
Execute routing actions.
Logger interface for dependency injection.
routing_field
DICOM field to match in routing conditions.
std::function< void( const std::string &rule_id, const std::string &instance_uid, const std::vector< routing_action > &triggered_actions)> routing_event_callback
Callback type for routing events.
Result<T> type aliases and helpers for PACS system.
Routing types and structures for auto-forwarding DICOM images.
Action to perform when a routing rule matches.
A single condition for routing rule evaluation.
Configuration for the routing manager.
A complete routing rule with conditions and actions.
Statistics for routing operations.
Result of testing rules against a dataset (dry run)