44 lines
1.3 KiB
Python
44 lines
1.3 KiB
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
|
|
from typing import Self, Callable, Optional
|
|
from Interfaces.Application.AnPInterface import AnPInterface
|
|
|
|
class BaseAbstract:
|
|
|
|
def _build(self:Self) -> None:
|
|
pass
|
|
|
|
def __init__(self:Self, anp:AnPInterface, key:str) -> None:
|
|
self.anp:AnPInterface = anp
|
|
self.key:str = key
|
|
self._built:bool = False
|
|
self._started:bool = False
|
|
self._stopped:bool = False
|
|
|
|
self._build()
|
|
self._built = True
|
|
|
|
def _start(self:Self, callback:Optional[Callable[[bool], bool]] = None) -> bool:
|
|
pass
|
|
|
|
def start(self:Self, callback:Optional[Callable[[bool], bool]] = None) -> bool:
|
|
if self._started:
|
|
return False if callback is None else callback(False)
|
|
self._started = True
|
|
|
|
self._stopped = False
|
|
return True if callback is None else callback(True)
|
|
|
|
def _close(self:Self, callback:Optional[Callable[[bool], bool]] = None) -> bool:
|
|
pass
|
|
|
|
def close(self:Self, callback:Optional[Callable[[bool], bool]] = None) -> bool:
|
|
if self._stopped:
|
|
return False if callback is None else callback(False)
|
|
self._started = False
|
|
|
|
self._close(callback)
|
|
|
|
self._stopped = True
|
|
return True if callback is None else callback(True) |