From: <aca...@us...> - 2008-05-30 16:54:22
|
Revision: 181 http://gridsim.svn.sourceforge.net/gridsim/?rev=181&view=rev Author: acaminero Date: 2008-05-30 09:54:28 -0700 (Fri, 30 May 2008) Log Message: ----------- initial release. this class stores a list of entity IDs and their I/O ports such that their packets are not dropped at the routers. Added Paths: ----------- branches/gridsim4.0-branch2/source/gridsim/net/fnb/FnbWhiteList.java Added: branches/gridsim4.0-branch2/source/gridsim/net/fnb/FnbWhiteList.java =================================================================== --- branches/gridsim4.0-branch2/source/gridsim/net/fnb/FnbWhiteList.java (rev 0) +++ branches/gridsim4.0-branch2/source/gridsim/net/fnb/FnbWhiteList.java 2008-05-30 16:54:28 UTC (rev 181) @@ -0,0 +1,102 @@ + +package gridsim.net.fnb; + +import java.util.*; +import gridsim.*; + + +public class FnbWhiteList +{ + private ArrayList list_; + + public FnbWhiteList() + { + list_ = new ArrayList(); + } + + + /**Returns true if the given id is in the list.*/ + public boolean checkList(int id) + { + + int id_tmp; + for (int i =0; i<list_.size(); i++) + { + id_tmp = ((Integer)list_.get(i)).intValue(); + + if (id == id_tmp) + { + //System.out.println("----- checking : " + GridSim.getEntityName(id) + " TRUE"); + return true; + } + } + + //System.out.println("----- checking : " + GridSim.getEntityName(id) + " FALSE"); + return false; + + } + + + + public boolean addEntityID(Integer id) + { + // We must add not only the entity id, but also the ids of the input/output ports. + + if ( (id == null) || (id.intValue() <= 0) ) + return false; + + if (checkList(id.intValue()) == true) + return false; + + String name = GridSim.getEntityName(id); + + String input = "Input_" + name; + String output = "Output_" + name; + + int input_id = GridSim.getEntityId(input); + int output_id = GridSim.getEntityId(output); + + list_.add(id); + list_.add(new Integer(input_id)); + list_.add(new Integer(output_id)); + + return true; + } + + + + public boolean addEntityID(int id) + { + return addEntityID(new Integer (id)); + } + + /**Removes the given id of the list.*/ + public boolean removeID(int id) + { + int id_tmp; + for (int i =0; i<list_.size(); i++) + { + id_tmp = ((Integer)list_.get(i)).intValue(); + + if (id == id_tmp) + list_.remove(i); + + } + + return false; + + } + + public int size() + { + return list_.size(); + } + + public Integer get(int i) + { + return (Integer) list_.get(i); + } + + //checkListInputPort(int id) + //checkListOutputPort +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |