Skip to content

Adapter Manager

Singleton registry that manages adapter instances and active CAD type detection.

adapters.adapter_manager

CAD Adapter management and caching.

Handles: - Adapter resolution (which CAD to use) - Adapter caching and reuse - Active CAD type tracking - Lazy connection on first use

AdapterRegistry

Singleton registry for managing CAD adapter instances.

Encapsulates global state for adapter caching and active CAD tracking. Thread-safe with locks for concurrent access.

get_instance classmethod

get_instance() -> AdapterRegistry

Return the singleton AdapterRegistry instance, creating it if necessary.

Thread-safe via double-checked locking.

RETURNS DESCRIPTION
AdapterRegistry

The singleton AdapterRegistry instance.

reset classmethod

reset() -> None

Destroy the singleton instance, forcing re-creation on next access.

Primarily used in tests to reset state between test cases.

get_cad_type

get_cad_type() -> str

Get the currently active CAD type name, or 'None' if disconnected.

get_adapter

get_adapter(only_if_running: bool = False) -> Any

Get the active CAD adapter instance. Auto-detects if none exists.

PARAMETER DESCRIPTION
only_if_running

If True, fails if CAD is not already open.

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
Any

CAD adapter instance

RAISES DESCRIPTION
CADConnectionError

If adapter cannot be created or connected

get_cad_instances

get_cad_instances() -> Dict[str, Any]

Get the dictionary of all CAD adapter instances.

RETURNS DESCRIPTION
Dict[str, Any]

Dictionary mapping CAD type to adapter instance

auto_detect_cad

auto_detect_cad(only_if_running: bool = False) -> None

Auto-detect and connect to available CAD applications on startup (thread-safe).

shutdown_all

shutdown_all() -> None

Disconnect and cleanup all CAD adapter instances (thread-safe).

get_active_cad_type

get_active_cad_type() -> str

Return the currently active CAD type.

set_active_cad_type

set_active_cad_type(cad_type: Optional[str]) -> None

Convenience function - stubbed out for backwards compatibility.

get_adapter

get_adapter(
    cad_type: Optional[str] = None,
    only_if_running: bool = False,
) -> Any

Convenience function - delegates to singleton registry.

get_cad_instances

get_cad_instances() -> Dict[str, Any]

Convenience function - delegates to singleton registry.

auto_detect_cad

auto_detect_cad(only_if_running: bool = False) -> None

Convenience function - delegates to singleton registry.

shutdown_all

shutdown_all() -> None

Convenience function - delegates to singleton registry.