import 'package:fis_common/event/event_type.dart';
import 'package:fis_measure/interfaces/process/modes/mode.dart';
import 'package:fis_measure/interfaces/process/visuals/visual.dart';

/// 模式
class ModeBase implements IMode {
  bool _active = false;
  late final IVisual _visual;
  late final String _name;
  late final ModeTypeEnum _type;

  ModeBase(String name, ModeTypeEnum type, IVisual visual) {
    _name = name;
    _visual = visual;
    _type = type;
  }

  @override
  bool get active => _active;
  @override
  set active(bool value) {
    if (value != _active) {
      _active = value;
      activeChanged.emit(this, value);
    }
  }

  @override
  ModeTypeEnum get modeType => _type;

  @override
  String get name => _name;

  @override
  IVisual get visual => _visual;

  @override
  var activeChanged = FEventHandler<bool>();
}
