PACS System 0.1.0
PACS DICOM system library
Loading...
Searching...
No Matches
kcenon::pacs::di Namespace Reference

Namespaces

namespace  test
 

Classes

class  DicomNetworkService
 Default implementation of IDicomNetwork using network_adapter. More...
 
class  IDicomNetwork
 Network service interface for DICOM communication. More...
 
class  ILogger
 Abstract logger interface for dependency injection. More...
 
class  LoggerService
 Default implementation of ILogger using logger_adapter. More...
 
class  NullLogger
 No-op logger implementation for default injection. More...
 
struct  registration_config
 Configuration for service registration. More...
 

Typedefs

using IDicomStorage = storage::storage_interface
 Storage interface for DICOM data persistence.
 
using IDicomCodec = encoding::compression::compression_codec
 Codec interface for image compression/decompression.
 

Functions

std::shared_ptr< ILoggernull_logger ()
 Get a shared null logger instance.
 
kcenon::common::VoidResult register_services (kcenon::common::di::IServiceContainer &container, const registration_config &config={})
 
template<typename TStorage >
requires std::derived_from<TStorage, IDicomStorage>
kcenon::common::VoidResult register_storage (kcenon::common::di::IServiceContainer &container, std::function< std::shared_ptr< TStorage >(kcenon::common::di::IServiceContainer &)> factory, kcenon::common::di::service_lifetime lifetime=kcenon::common::di::service_lifetime::singleton)
 Register storage service with custom implementation.
 
kcenon::common::VoidResult register_storage_instance (kcenon::common::di::IServiceContainer &container, std::shared_ptr< IDicomStorage > instance)
 Register storage service with pre-created instance.
 
template<typename TNetwork >
requires std::derived_from<TNetwork, IDicomNetwork>
kcenon::common::VoidResult register_network (kcenon::common::di::IServiceContainer &container, std::function< std::shared_ptr< TNetwork >(kcenon::common::di::IServiceContainer &)> factory, kcenon::common::di::service_lifetime lifetime=kcenon::common::di::service_lifetime::singleton)
 Register network service with custom implementation.
 
kcenon::common::VoidResult register_network_instance (kcenon::common::di::IServiceContainer &container, std::shared_ptr< IDicomNetwork > instance)
 Register network service with pre-created instance.
 
template<typename TLogger >
requires std::derived_from<TLogger, ILogger>
kcenon::common::VoidResult register_logger (kcenon::common::di::IServiceContainer &container, std::function< std::shared_ptr< TLogger >(kcenon::common::di::IServiceContainer &)> factory, kcenon::common::di::service_lifetime lifetime=kcenon::common::di::service_lifetime::singleton)
 Register logger service with custom implementation.
 
kcenon::common::VoidResult register_logger_instance (kcenon::common::di::IServiceContainer &container, std::shared_ptr< ILogger > instance)
 Register logger service with pre-created instance.
 
std::shared_ptr< kcenon::common::di::service_container > create_container (const registration_config &config={})
 

Typedef Documentation

◆ IDicomCodec

Codec interface for image compression/decompression.

Alias for kcenon::pacs::encoding::compression::compression_codec providing unified access through the DI container.

See also
kcenon::pacs::encoding::compression::compression_codec

Definition at line 58 of file service_interfaces.h.

◆ IDicomStorage

Storage interface for DICOM data persistence.

Alias for kcenon::pacs::storage::storage_interface providing unified access through the DI container.

See also
kcenon::pacs::storage::storage_interface

Definition at line 44 of file service_interfaces.h.

Function Documentation

◆ create_container()

std::shared_ptr< kcenon::common::di::service_container > kcenon::pacs::di::create_container ( const registration_config & config = {})
inlinenodiscard
Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/di/service_registration.h.

Definition at line 297 of file service_registration.h.

297 {}) {
298 auto container = std::make_shared<kcenon::common::di::service_container>();
299 auto result = register_services(*container, config);
300 if (result.is_err()) {
301 return nullptr;
302 }
303 return container;
304}

◆ null_logger()

std::shared_ptr< ILogger > kcenon::pacs::di::null_logger ( )
inlinenodiscard

Get a shared null logger instance.

Returns a singleton NullLogger instance for use as a default. This avoids repeated allocations when services need a default logger.

Returns
Shared pointer to NullLogger

Definition at line 271 of file ilogger.h.

271 {
272 static auto instance = std::make_shared<NullLogger>();
273 return instance;
274}

Referenced by kcenon::pacs::client::job_manager::job_manager(), kcenon::pacs::client::remote_node_manager::remote_node_manager(), kcenon::pacs::services::scp_service::set_logger(), kcenon::pacs::client::sync_manager::sync_manager(), and kcenon::pacs::client::sync_manager::sync_manager().

Here is the caller graph for this function:

◆ register_logger()

template<typename TLogger >
requires std::derived_from<TLogger, ILogger>
kcenon::common::VoidResult kcenon::pacs::di::register_logger ( kcenon::common::di::IServiceContainer & container,
std::function< std::shared_ptr< TLogger >(kcenon::common::di::IServiceContainer &)> factory,
kcenon::common::di::service_lifetime lifetime = kcenon::common::di::service_lifetime::singleton )
inlinenodiscard

Register logger service with custom implementation.

Template Parameters
TLoggerLogger implementation type (must derive from ILogger)
Parameters
containerThe service container
factoryFactory function for creating logger instances
lifetimeService lifetime (default: singleton)
Returns
VoidResult indicating success or error
Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/di/service_registration.h.

Definition at line 250 of file service_registration.h.

253 {
254
255 return container.register_factory<ILogger>(
256 [f = std::move(factory)](kcenon::common::di::IServiceContainer& c) -> std::shared_ptr<ILogger> {
257 return f(c);
258 },
259 lifetime
260 );
261}
Abstract logger interface for dependency injection.
Definition ilogger.h:45

◆ register_logger_instance()

kcenon::common::VoidResult kcenon::pacs::di::register_logger_instance ( kcenon::common::di::IServiceContainer & container,
std::shared_ptr< ILogger > instance )
inlinenodiscard

Register logger service with pre-created instance.

Parameters
containerThe service container
instanceThe logger instance to register
Returns
VoidResult indicating success or error
Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/di/service_registration.h.

Definition at line 270 of file service_registration.h.

272 {
273
274 return container.register_instance<ILogger>(std::move(instance));
275}

◆ register_network()

template<typename TNetwork >
requires std::derived_from<TNetwork, IDicomNetwork>
kcenon::common::VoidResult kcenon::pacs::di::register_network ( kcenon::common::di::IServiceContainer & container,
std::function< std::shared_ptr< TNetwork >(kcenon::common::di::IServiceContainer &)> factory,
kcenon::common::di::service_lifetime lifetime = kcenon::common::di::service_lifetime::singleton )
inlinenodiscard

Register network service with custom implementation.

Template Parameters
TNetworkNetwork implementation type (must derive from IDicomNetwork)
Parameters
containerThe service container
factoryFactory function for creating network service instances
lifetimeService lifetime (default: singleton)
Returns
VoidResult indicating success or error
Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/di/service_registration.h.

Definition at line 212 of file service_registration.h.

215 {
216
217 return container.register_factory<IDicomNetwork>(
218 [f = std::move(factory)](kcenon::common::di::IServiceContainer& c) -> std::shared_ptr<IDicomNetwork> {
219 return f(c);
220 },
221 lifetime
222 );
223}
Network service interface for DICOM communication.

◆ register_network_instance()

kcenon::common::VoidResult kcenon::pacs::di::register_network_instance ( kcenon::common::di::IServiceContainer & container,
std::shared_ptr< IDicomNetwork > instance )
inlinenodiscard

Register network service with pre-created instance.

Parameters
containerThe service container
instanceThe network service instance to register
Returns
VoidResult indicating success or error
Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/di/service_registration.h.

Definition at line 232 of file service_registration.h.

234 {
235
236 return container.register_instance<IDicomNetwork>(std::move(instance));
237}

◆ register_services()

kcenon::common::VoidResult kcenon::pacs::di::register_services ( kcenon::common::di::IServiceContainer & container,
const registration_config & config = {} )
inlinenodiscard
Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/di/service_registration.h.

Definition at line 94 of file service_registration.h.

96 {}) {
97
98 using namespace kcenon::common::di;
99
100 const auto lifetime = config.use_singletons
101 ? service_lifetime::singleton
102 : service_lifetime::transient;
103
104 // -------------------------------------------------------------------------
105 // Register IDicomStorage
106 // -------------------------------------------------------------------------
107 {
108 auto storage_path = config.storage_path;
109 if (storage_path.empty()) {
110 storage_path = std::filesystem::temp_directory_path() / "pacs_storage";
111 }
112
113 auto result = container.register_factory<IDicomStorage>(
114 [path = storage_path](IServiceContainer&) -> std::shared_ptr<IDicomStorage> {
115 storage::file_storage_config storage_config;
116 storage_config.root_path = path;
117 storage_config.create_directories = true;
118 return std::make_shared<storage::file_storage>(storage_config);
119 },
120 lifetime
121 );
122
123 if (result.is_err()) {
124 return result;
125 }
126 }
127
128 // -------------------------------------------------------------------------
129 // Register IDicomNetwork
130 // -------------------------------------------------------------------------
131 if (config.enable_network) {
132 auto result = container.register_factory<IDicomNetwork>(
133 [](IServiceContainer&) -> std::shared_ptr<IDicomNetwork> {
134 return std::make_shared<DicomNetworkService>();
135 },
136 lifetime
137 );
138
139 if (result.is_err()) {
140 return result;
141 }
142 }
143
144 // -------------------------------------------------------------------------
145 // Register ILogger
146 // -------------------------------------------------------------------------
147 if (config.enable_logger) {
148 auto result = container.register_factory<ILogger>(
149 [](IServiceContainer&) -> std::shared_ptr<ILogger> {
150 return std::make_shared<LoggerService>();
151 },
152 lifetime
153 );
154
155 if (result.is_err()) {
156 return result;
157 }
158 }
159
160 return kcenon::common::VoidResult::ok({});
161}
@ container
CONTAINER - Container for other items.
bool use_singletons
Use singleton lifetime for services (default: true)
bool enable_network
Enable network services (default: true)
std::filesystem::path storage_path
Default storage path for file_storage (empty = use temp directory)
bool enable_logger
Enable logger services (default: true)

◆ register_storage()

template<typename TStorage >
requires std::derived_from<TStorage, IDicomStorage>
kcenon::common::VoidResult kcenon::pacs::di::register_storage ( kcenon::common::di::IServiceContainer & container,
std::function< std::shared_ptr< TStorage >(kcenon::common::di::IServiceContainer &)> factory,
kcenon::common::di::service_lifetime lifetime = kcenon::common::di::service_lifetime::singleton )
inlinenodiscard

Register storage service with custom implementation.

Template Parameters
TStorageStorage implementation type (must derive from IDicomStorage)
Parameters
containerThe service container
factoryFactory function for creating storage instances
lifetimeService lifetime (default: singleton)
Returns
VoidResult indicating success or error
Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/di/service_registration.h.

Definition at line 174 of file service_registration.h.

177 {
178
179 return container.register_factory<IDicomStorage>(
180 [f = std::move(factory)](kcenon::common::di::IServiceContainer& c) -> std::shared_ptr<IDicomStorage> {
181 return f(c);
182 },
183 lifetime
184 );
185}

◆ register_storage_instance()

kcenon::common::VoidResult kcenon::pacs::di::register_storage_instance ( kcenon::common::di::IServiceContainer & container,
std::shared_ptr< IDicomStorage > instance )
inlinenodiscard

Register storage service with pre-created instance.

Parameters
containerThe service container
instanceThe storage instance to register
Returns
VoidResult indicating success or error
Examples
/home/runner/work/pacs_system/pacs_system/include/kcenon/pacs/di/service_registration.h.

Definition at line 194 of file service_registration.h.

196 {
197
198 return container.register_instance<IDicomStorage>(std::move(instance));
199}