next up previous contents
suivant: TwoTasksAnalysis.java monter: Package twoTasksAnalysis précédent: BufferPairExpression.java   Table des matières

TwoTasksCircuit.java


package buffalo.twoTasksAnalysis;

import buffalo.dataStructures.*;
import buffalo.twoTasksAnalysis.TwoTasksCircuit;

/**
   Cette classe permet lorsqu'on a identifier les quatre <CODE>Operations</CODE>
   caract&eacute;ristiques d'un circuit dans lequel deux <CODE>Taches</CODE> 
   (et seulement deux) sont impliqu&eacute;es, de les mettre en ordre et de 
   les passer toutes les quatre encapsul&eacute;es dans le m&ecirc;me objet.
 */

public class TwoTasksCircuit
{

    /*
      Quatre op&eacute;rations du circuit &agrave; deux <CODE>Taches</CODE>, 
      d&eacute;ign&eacute;es comme des points cardinaux.
     */

    private Operation northEast;
    private Operation northWest;
    private Operation southEast;
    private Operation southWest;

    /**
       Le constructeur prend en param&egrave;tre le northBuffer et les 
       quatre <CODE>Operations</CODE> impliqu&eacute;es dans le 
       circuit; on peut passer ces quatre <CODE>Operations</CODE>
       dans n'importe quel ordre.
     */

    public TwoTasksCircuit(Task northTask, Operation operation1, Operation operation2, 
		   Operation operation3, Operation operation4)
    {
	Operation firstNorthOperation = null;
	Operation secondNorthOperation = null;
	Operation firstSouthOperation = null;
	Operation secondSouthOperation = null;
	if(operation1.getActiveTask() == northTask)
	    {
		firstNorthOperation = operation1;
	    }
	else
	    {
		firstSouthOperation = operation1;
	    }
	if (operation2.getActiveTask() == northTask)
	    {
		if (firstNorthOperation == null)
		    {
			firstNorthOperation = operation2;
		    }
		else
		    {
			secondNorthOperation = operation2;
		    }
	    }
	else
	    {
		if (firstSouthOperation == null)
		    {
			firstSouthOperation = operation2;
		    }
		else
		    {
			secondSouthOperation = operation2;
		    }
	    }
	if (operation3.getActiveTask() == northTask)
	    {
		if (firstNorthOperation == null)
		    {
			firstNorthOperation = operation3;
		    }
		else
		    {
			secondNorthOperation = operation3;
		    }
	    }
	else
	    {
		if (firstSouthOperation == null)
		    {
			firstSouthOperation = operation3;
		    }
		else
		    {
			secondSouthOperation = operation3;
		    }
	    }
	if(operation4.getActiveTask() == northTask)
	    {
		secondNorthOperation = operation4;
	    }
	else
	    {
		secondSouthOperation = operation4;
	    }	
	if (firstNorthOperation.getIndex() < 
	    secondNorthOperation.getIndex())
	    {
		this.northWest = firstNorthOperation;
		this.northEast = secondNorthOperation;
	    }
	else
	    {
		this.northWest = secondNorthOperation;
		this.northEast = firstNorthOperation;
	    }
	if (firstSouthOperation.getIndex() < 
	    secondSouthOperation.getIndex())
	    {
		this.southWest = firstSouthOperation;
		this.southEast = secondSouthOperation;
	    }
	else
	    {
		this.southWest = secondSouthOperation;
		this.southEast = firstSouthOperation;
	    }
    }
    
    /*----------------------------------------------------------*/

    /*Accesseurs*/

    /**
       Retourne l'<CODE>Operation</CODE> en haut &agrave; droite
    */

    public Operation getNorthEast()
    {
	return this.northEast;
    }

    /*----------------------------------------------------------*/

    /**
       Retourne l'<CODE>Operation</CODE> en haut &agrave; gauche
    */

    public Operation getNorthWest()
    {
	return this.northWest;
    }

    /*----------------------------------------------------------*/

    /**
       Retourne l'<CODE>Operation</CODE> en bas &agrave; droite
    */

    public Operation getSouthEast()
    {
	return this.southEast;
    }

    /*----------------------------------------------------------*/

    /**
       Retourne l'<CODE>Operation</CODE> en bas &agrave; gauche
    */

    public Operation getSouthWest()
    {
	return this.northWest;
    }

    /*----------------------------------------------------------*/

    /**
       Retourne le circuit au format cha&icirc;ne de caract&egrave;res.
     */

    public String toString()
    {
	String result = "{";
	result += " northTask = " + northEast.getActiveTask().getIndex();
	result += " ; southTask = " + southEast.getActiveTask().getIndex();
	result += " ; northWest = " + northWest.getIndex();
	result += " ; northEast = " + northEast.getIndex();
	result += " ; southWest = " + southWest.getIndex();
	result += " ; southEast = " + southEast.getIndex() + " } ";
	return result;
    }

}



Alexandre 2009-05-14