1 | /************************************************************************************ |
---|
2 | * Copyright (C) 2008 by Politehnica University of Bucharest and Rutgers University |
---|
3 | * All rights reserved. |
---|
4 | * Refer to LICENSE for terms and conditions of use. |
---|
5 | ***********************************************************************************/ |
---|
6 | package vnsim.vehicular.scenarios; |
---|
7 | |
---|
8 | |
---|
9 | |
---|
10 | |
---|
11 | import java.util.ArrayList; |
---|
12 | |
---|
13 | import vnsim.map.object.*; |
---|
14 | import vnsim.vehicular.simulator.Location; |
---|
15 | import vnsim.vehicular.simulator.RouteSegment; |
---|
16 | |
---|
17 | |
---|
18 | public class Scenario implements java.io.Serializable { |
---|
19 | |
---|
20 | /** <code>serialVersionUID</code> */ |
---|
21 | private static final long serialVersionUID = -5883719321862303634L; |
---|
22 | |
---|
23 | public String name; |
---|
24 | // public Map theMap; |
---|
25 | |
---|
26 | public String mapFileName; |
---|
27 | |
---|
28 | public ArrayList<Route> allRoutes; |
---|
29 | public ArrayList<String> driverTypes; |
---|
30 | |
---|
31 | public ArrayList<Location> entries; |
---|
32 | |
---|
33 | public ArrayList<Location> exits; |
---|
34 | |
---|
35 | public ArrayList<EntryScenario> entryScenarios; |
---|
36 | |
---|
37 | |
---|
38 | public Scenario(String mapFileName, ArrayList<Location> entries, ArrayList<Location> exits, |
---|
39 | ArrayList<String> driverTypes,ArrayList<Route> allRoutes,String name) |
---|
40 | { |
---|
41 | //this.theMap = map; |
---|
42 | |
---|
43 | this.mapFileName=mapFileName; |
---|
44 | |
---|
45 | this.driverTypes = driverTypes; |
---|
46 | this.entries = entries; |
---|
47 | this.exits = exits; |
---|
48 | this.entryScenarios=new ArrayList<EntryScenario>(); |
---|
49 | this.allRoutes=allRoutes; |
---|
50 | this.name=name; |
---|
51 | |
---|
52 | } |
---|
53 | |
---|
54 | public int contains(Location entry) { |
---|
55 | if (entryScenarios == null) { |
---|
56 | return -1; |
---|
57 | } else { |
---|
58 | int i; |
---|
59 | for (i = 0; i < entryScenarios.size(); i++) { |
---|
60 | if (entryScenarios.get(i).entry.equals(entry)) { |
---|
61 | return i; |
---|
62 | } |
---|
63 | } |
---|
64 | return -1; |
---|
65 | } |
---|
66 | } |
---|
67 | |
---|
68 | public EntryScenario getEntryScenario(int id) { |
---|
69 | if (entryScenarios == null) { |
---|
70 | return null; |
---|
71 | } else { |
---|
72 | if (entryScenarios.size() < id) { |
---|
73 | return null; |
---|
74 | } else { |
---|
75 | return entryScenarios.get(id); |
---|
76 | } |
---|
77 | } |
---|
78 | } |
---|
79 | |
---|
80 | } |
---|