Encapsulate target-type dispatch via polymorphism (Phase 1)

Replace isinstance checks with polymorphic methods on PictureTarget
hierarchy: register_with_manager, sync_with_manager, update_fields,
and has_picture_source property.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-20 02:20:33 +03:00
parent 3101894ab5
commit 99f47fdbf9
6 changed files with 109 additions and 69 deletions

View File

@@ -16,6 +16,27 @@ class PictureTarget:
updated_at: datetime
description: Optional[str] = None
def register_with_manager(self, manager) -> None:
"""Register this target with the processor manager. Subclasses override."""
pass
def sync_with_manager(self, manager, *, settings_changed: bool, source_changed: bool, device_changed: bool) -> None:
"""Push changed fields to a running processor. Subclasses override."""
pass
def update_fields(self, *, name=None, device_id=None, picture_source_id=None,
settings=None, key_colors_settings=None, description=None) -> None:
"""Apply mutable field updates. Base handles common fields; subclasses handle type-specific ones."""
if name is not None:
self.name = name
if description is not None:
self.description = description
@property
def has_picture_source(self) -> bool:
"""Whether this target type uses a picture source."""
return False
def to_dict(self) -> dict:
"""Convert to dictionary."""
return {