Dicom.Codec.Registry (Dicom v0.9.2)

Copy Markdown View Source

Registry for DICOM pixel data codecs.

Maps Transfer Syntax UIDs to codec modules implementing Dicom.Codec.

Built-in codecs (e.g., Dicom.Codec.RLE) are registered automatically on first access. Additional codecs can be registered at runtime:

Dicom.Codec.Registry.register(MyApp.JPEGCodec)

Uses :persistent_term for O(1) lookup with no process overhead.

Summary

Functions

Removes the codec registration for a given Transfer Syntax UID.

Looks up a codec module for the given Transfer Syntax UID.

Registers a codec module for all Transfer Syntax UIDs it declares.

Returns all registered {uid, module} pairs.

Resets the registry to only built-in codecs.

Functions

deregister(transfer_syntax_uid)

@spec deregister(String.t()) :: :ok

Removes the codec registration for a given Transfer Syntax UID.

Returns :ok.

lookup(transfer_syntax_uid)

@spec lookup(String.t()) :: {:ok, module()} | :error

Looks up a codec module for the given Transfer Syntax UID.

Returns {:ok, module} or :error.

Examples

iex> Dicom.Codec.Registry.lookup("1.2.840.10008.1.2.5")
{:ok, Dicom.Codec.RLE}

register(module)

@spec register(module()) :: :ok

Registers a codec module for all Transfer Syntax UIDs it declares.

The module must implement the Dicom.Codec behaviour, specifically transfer_syntax_uids/0.

Returns :ok.

Examples

iex> Dicom.Codec.Registry.register(Dicom.Codec.RLE)
:ok

registered()

@spec registered() :: [{String.t(), module()}]

Returns all registered {uid, module} pairs.

Examples

iex> Dicom.Codec.Registry.registered() |> Enum.member?({"1.2.840.10008.1.2.5", Dicom.Codec.RLE})
true

reset()

@spec reset() :: :ok

Resets the registry to only built-in codecs.

Useful in tests to restore a clean state.