/*
 * Copyright (C) 2018 Robert Bosch GmbH Copyright (C) 2018 Robert Bosch Manufacturing Solutions GmbH, Germany. All rights reserved.
 */

import Map from 'ol/Map';
import { InteractionMode } from './interaction-mode';

export class InteractionsManager {
  private activeMode: InteractionMode;

  constructor(private map: Map) {}

  destroy() {
    this.switchMode();
  }

  switchMode(newMode?: InteractionMode) {
    if (!!this.activeMode) {
      this.activeMode.deactivate();
    }
    if (!!newMode) {
      newMode.setMap(this.map);
      newMode.activate();
    }
    this.activeMode = newMode;
  }
}
