001/** 002 * This file is part of the Kompics P2P Framework. 003 * 004 * Copyright (C) 2009 Swedish Institute of Computer Science (SICS) Copyright (C) 005 * 2009 Royal Institute of Technology (KTH) 006 * 007 * Kompics is free software; you can redistribute it and/or modify it under the 008 * terms of the GNU General Public License as published by the Free Software 009 * Foundation; either version 2 of the License, or (at your option) any later 010 * version. 011 * 012 * This program is distributed in the hope that it will be useful, but WITHOUT 013 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 014 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 015 * details. 016 * 017 * You should have received a copy of the GNU General Public License along with 018 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple 019 * Place - Suite 330, Boston, MA 02111-1307, USA. 020 */ 021package se.sics.kompics.simulator.stochastic.events; 022 023import java.util.LinkedList; 024 025/** 026 * The <code>StochasticProcessStartEvent</code> class. 027 * 028 * @author Cosmin Arad {@literal <[email protected]>} 029 * @version $Id: StochasticProcessStartEvent.java 750 2009-04-02 09:55:01Z Cosmin $ 030 */ 031public final class StochasticProcessStartEvent extends StochasticSimulatorEvent { 032 033 private static final long serialVersionUID = 4299863622116185513L; 034 035 private final LinkedList<StochasticProcessStartEvent> startEvents; 036 private final StochasticProcessEvent stochasticEvent; 037 private int waitFor; 038 private final String processName; 039 private final long delay; 040 041 public StochasticProcessStartEvent(long time, LinkedList<StochasticProcessStartEvent> startEvents, 042 StochasticProcessEvent stochasticEvent, int waitFor, String name) { 043 super(time); 044 this.delay = time; 045 this.startEvents = startEvents; 046 this.stochasticEvent = stochasticEvent; 047 this.waitFor = waitFor; 048 this.processName = name; 049 } 050 051 public final boolean shouldHandleNow() { 052 waitFor--; 053 return waitFor <= 0 ? true : false; 054 } 055 056 @Override 057 public final void setTime(long time) { 058 time += delay; 059 if (time > getTime()) { 060 // only move time forward 061 super.setTime(time); 062 } 063 } 064 065 public final long getDelay() { 066 return delay; 067 } 068 069 public final LinkedList<StochasticProcessStartEvent> getStartEvents() { 070 return startEvents; 071 } 072 073 public final StochasticProcessEvent getStochasticEvent() { 074 return stochasticEvent; 075 } 076 077 public String getProcessName() { 078 return processName; 079 } 080}