SlappedWithSilence / TXEnginePy

A Python port of the original TXEngine project
3 stars 0 forks source link

Update FiniteStateDevice to have a built-in inner abstract class 'States' #32

Closed SlappedWithSilence closed 9 months ago

SlappedWithSilence commented 1 year ago

Right now, FiniteStateDevices require that an Enum class containing all of the states of the device be supplied to it via constructor. It is possible to define an Abstract class called States and force it to be implemented. This way we can eliminate the need to explicitly reference the State inner class in the subclasses of FiniteStateDevice.

class FiniteStateDevice(StateDevice, ABC):
    """
    A subclass of StateDevice that adds support for explicit state ordering and transitions
    """

    class State(enum.Enum):
        raise NotImplementedError