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
11
namespace
kcenon::pacs::compat
{
12
13
// Released dependencies return smart pointers; current factories return Result.
14
// Preserve structured errors while keeping both dependency generations usable.
15
template
<
typename
T>
16
[[nodiscard]]
auto
factory_result
(
kcenon::common::Result<T>
result)
17
->
kcenon::common::Result<T>
{
18
return
result;
19
}
20
21
template
<
typename
Po
int
er>
22
requires
requires
{
typename
Pointer::element_type; }
23
[[nodiscard]]
auto
factory_result
(Pointer pointer)
24
->
kcenon::common::Result<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
kcenon::common::Result
Definition
study_lock_manager.h:36
kcenon::pacs::compat
Definition
factory_result.h:11
kcenon::pacs::compat::factory_result
auto factory_result(kcenon::common::Result< T > result) -> kcenon::common::Result< T >
Definition
factory_result.h:16
include
kcenon
pacs
compat
factory_result.h
Generated by
1.12.0