#!/usr/bin/env python

from aman.types.Inbound import Inbound

class RecedingHorizonWindow:
    def __init__(self, startTime, endTime):
        self.StartTime = startTime
        self.EndTime = endTime
        self.Inbounds = []

    def isInWindow(self, inbound : Inbound):
        for report in self.Inbounds:
            if report.Report.aircraft.callsign == inbound.Report.aircraft.callsign:
                return True
        return False

    def inbound(self, callsign : str):
        for report in self.Inbounds:
            if report.Report.aircraft.callsign == callsign:
                return report
        return None

    def insert(self, inbound : Inbound):
        for i in range(0, len(self.Inbounds)):
            if self.Inbounds[i].Report.aircraft.callsign == inbound.Report.aircraft.callsign:
                return
        self.Inbounds.append(inbound)

    def remove(self, callsign : str):
        for i in range(0, len(self.Inbounds)):
            if self.Inbounds[i].Report.aircraft.callsign == callsign:
                self.Inbounds.pop(i)
                return