from abc import ABC, abstractmethod
import warnings
from .translation import TranslationResult

class Translator(ABC):

    def translate(self, name: str, value):
        method = getattr(self, name, None)
        if callable(method):
            return method(value) or {}
        else:
            # No special translation, keep the argument as is
            return TranslationResult(backend_kwargs={name: value}, wrapper_kwargs={})

    def loss(self, value):
        warnings.warn(
            f"[{self.__class__.__name__}] Argument 'loss' is not supported by this engine and was ignored.",
            category=UserWarning
        )

    def operators(self, argument):
        warnings.warn(
            f"[{self.__class__.__name__}] Argument 'operators' is not supported by this engine and was ignored.",
            category=UserWarning
        )

    def max_complexity(self, argument):
        warnings.warn(
            f"[{self.__class__.__name__}] Argument 'operators' is not supported by this engine and was ignored.",
            category=UserWarning
        )

    def max_params(self, argument):
        warnings.warn(
            f"[{self.__class__.__name__}] Argument 'max_params' is not supported by this engine and was ignored.",
            category=UserWarning
        )

    def max_depth(self, argument):
        warnings.warn(
            f"[{self.__class__.__name__}] Argument 'max_depth' is not supported by this engine and was ignored.",
            category=UserWarning
        )

    def num_iterations(self, argument):
        warnings.warn(
            f"[{self.__class__.__name__}] Argument 'num_iterations' is not supported by this engine and was ignored.",
            category=UserWarning
        )

class DefaultTranslator(Translator):
    def translate(self, name, value):
        return TranslationResult(backend_kwargs={name: value}, wrapper_kwargs={})