PACS System 0.1.0
PACS DICOM system library
Loading...
Searching...
No Matches
factory_result.h
Go to the documentation of this file.
1// BSD 3-Clause License
2// Copyright (c) 2026, kcenon
3// See the LICENSE file in the project root for full license information.
4
5#pragma once
6
7#include <kcenon/common/error/error_codes.h>
8#include <kcenon/common/patterns/result.h>
9#include <utility>
10
12
13// Released dependencies return smart pointers; current factories return Result.
14// Preserve structured errors while keeping both dependency generations usable.
15template <typename T>
16[[nodiscard]] auto factory_result(kcenon::common::Result<T> result)
18 return result;
19}
20
21template <typename Pointer>
22 requires requires { typename Pointer::element_type; }
23[[nodiscard]] auto factory_result(Pointer pointer)
25 if (!pointer) {
26 return kcenon::common::make_error<Pointer>(
27 kcenon::common::error::codes::common_errors::internal_error,
28 "Dependency factory returned null", "pacs");
29 }
30 return kcenon::common::Result<Pointer>(std::move(pointer));
31}
32
33} // namespace kcenon::pacs::compat
auto factory_result(kcenon::common::Result< T > result) -> kcenon::common::Result< T >