#######################################################
# 
# ClientInformationQueueController.py
# Python implementation of the Class ClientInformationQueueController
# Generated by Enterprise Architect
# Created on:      21-May-2020 9:46:59 AM
# Original author: Natha Paquette
# 
#######################################################
from FreeTAKServer.model.ClientInformationQueue import ClientInformationQueue
from multiprocessing import Queue

class ClientInformationQueueController:
    def __init__(self):  
        self.ClientInformationQueue = ClientInformationQueue()

    def addClientToQueue(self, clientInformation):
        self.ClientInformationQueue.clientQueue.put(clientInformation)

    def removeClientFromQueue(self, clientInformationToRemove):
        #create instance of old queue
        oldQueue = self.ClientInformationQueue.clientQueue
        #create new queue
        newQueue = Queue()
        #iter through len of old queue
        for _ in len(oldQueue):
            #check if retrieved client information matches information to remove if so it will be ignored
            #otherwis it will be added to the new queue
            clientInformation = oldQueue.get()
            if clientInformation == clientInformationToRemove:
                pass
            else:
                newQueue.put(clientInformation)
        self.ClientInformationQueue.clientQueue = newQueue
