Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Correction of some bugs.
[mapping.git] / src / and / Mapping / Algo.java
index 79a210f..142b8a6 100644 (file)
@@ -16,6 +16,7 @@ public abstract class Algo implements Serializable
        protected Graph gr ;
        protected Grid gl ;
        protected Mapping mp ;
+       protected String ids ;
        
        
        /**
@@ -26,6 +27,7 @@ public abstract class Algo implements Serializable
                gr = new Graph() ;
                gl = new Grid() ;
                mp = new Mapping() ;
+               ids = "" ;
        }
        
        
@@ -39,6 +41,7 @@ public abstract class Algo implements Serializable
                gr =  _gr ;
                gl = _gl ;
                mp = new Mapping() ;
+               ids = "" ;
        }
        
        
@@ -63,7 +66,7 @@ public abstract class Algo implements Serializable
         * in order to bring fault tolerance. 
         * @return Another node which will not compute
         */
-       public abstract GNode getOtherGNode() ;
+       public abstract GNode getOtherGNode( ArrayList<GNode> _ag ) ;
        
        
        /**
@@ -74,6 +77,64 @@ public abstract class Algo implements Serializable
        {
                return mp ;
        }       
+       
+       
+       /**
+        * Return the grid used in the algorithm.
+        * @return The Grid
+        */
+       public Grid getGrid()
+       {
+               return gl ;
+       }
+       
+       
+       /**
+        * Return the graph used in the algorithm.
+        * @return The Graph
+        */
+       public Graph getGraph()
+       {
+               return gr ;
+       }
+       
+       
+       /**
+        * Set the string identifier for the algorithm.
+        * @param _s The algorithm's identifier
+        */
+       public void setIdS( String _s )
+       {
+               ids = _s ;
+       }
+       
+       
+       /**
+        * Return the string identifier of the algorithm.
+        * @return The algorithm's identifier
+        */
+       public String getIdS()
+       {
+               return ids ;
+       }
+       
+       
+       /**
+        * Update the grid status after having done the mapping.
+        */
+       public void updateGrid()
+       {
+               if( mp.getMappedGNodes().size() > 0 )
+               {
+                       ArrayList<GNode> temp = mp.getMappedGNodes() ;
+                       for( int i = 0 ; i < temp.size() ; i++ )
+                       {
+                               gl.getClusterOfNode( temp.get( i ) ).setGNodeStatus( temp.get( i ), true ) ;
+                               
+                               gl.setMappedStatus( temp.get( i ), true ) ;
+                       }
+               }
+       }
 }
 
 /** La programmation est un art, respectons ceux qui la pratiquent !! **/