MATSIM
QNetwork.java
Go to the documentation of this file.
1 /* *********************************************************************** *
2  * project: org.matsim.*
3  * QueueNetwork.java
4  * *
5  * *********************************************************************** *
6  * *
7  * copyright : (C) 2007, 2009 by the members listed in the COPYING, *
8  * LICENSE and WARRANTY file. *
9  * email : info at matsim dot org *
10  * *
11  * *********************************************************************** *
12  * *
13  * This program is free software; you can redistribute it and/or modify *
14  * it under the terms of the GNU General Public License as published by *
15  * the Free Software Foundation; either version 2 of the License, or *
16  * (at your option) any later version. *
17  * See also COPYING, LICENSE and WARRANTY file *
18  * *
19  * *********************************************************************** */
20 
21 package org.matsim.core.mobsim.qsim.qnetsimengine;
22 
23 import java.util.Collections;
24 import java.util.Map;
25 
26 import org.matsim.api.core.v01.Id;
27 import org.matsim.api.core.v01.IdMap;
36 
44 public class QNetwork implements NetsimNetwork {
45 
46  private final IdMap<Link, QLinkI> links;
47 
48  private final IdMap<Node, QNodeI> nodes;
49 
50  private final Network network;
51 
53 
54  QNetsimEngineI simEngine; // only for tests...
55 
56  QNetwork(final Network network, final QNetworkFactory netsimNetworkFactory ) {
57  this.network = network;
58  this.queueNetworkFactory = netsimNetworkFactory;
59  this.links = new IdMap<>(Link.class);
60  this.nodes = new IdMap<>(Node.class);
61  }
62 
63  public void initialize(QNetsimEngineI simEngine, AgentCounter agentCounter, MobsimTimer simTimer) {
64  this.simEngine = simEngine;
65  this.queueNetworkFactory.initializeFactory( agentCounter, simTimer, simEngine.getNetsimInternalInterface());
66  for (Node n : this.network.getNodes().values()) {
67  this.nodes.put(n.getId(), this.queueNetworkFactory.createNetsimNode(n));
68  }
69  for (Link l : this.network.getLinks().values()) {
70  final QLinkI qlink = this.queueNetworkFactory.createNetsimLink(l, this.nodes.get(l.getToNode().getId()));
71  this.links.put(l.getId(), qlink);
72  }
73  for (QNodeI n : this.nodes.values()) {
74  n.init();
75  }
76  }
77 
78  @Override
79  public Network getNetwork() {
80  return this.network;
81  }
82 
83  @Override
84  public Map<Id<Link>, QLinkI> getNetsimLinks() {
85  return Collections.unmodifiableMap(this.links);
86  }
87 
88  @Override
89  public Map<Id<Link>, ? extends VisLink> getVisLinks() {
90  return Collections.unmodifiableMap(this.links);
91  }
92 
93  @Override
94  public Map<Id<Node>, QNodeI> getNetsimNodes() {
95  return Collections.unmodifiableMap(this.nodes);
96  }
97 
98  @Override
99  public QLinkI getNetsimLink(final Id<Link> id) {
100  return this.links.get(id);
101  }
102 
103  @Override
104  public NetsimNode getNetsimNode(final Id<Node> id) {
105  return this.nodes.get(id);
106  }
107 
108 
109 }
Map< Id< Node >, ? extends Node > getNodes()
Map< Id< Link >, QLinkI > getNetsimLinks()
Definition: QNetwork.java:84
Map< Id< Link >, ? extends VisLink > getVisLinks()
Definition: QNetwork.java:89
Collection< V > values()
Definition: IdMap.java:204
Map< Id< Node >, QNodeI > getNetsimNodes()
Definition: QNetwork.java:94
NetsimNode getNetsimNode(final Id< Node > id)
Definition: QNetwork.java:104
void initializeFactory(AgentCounter agentCounter, MobsimTimer mobsimTimer, NetsimInternalInterface simEngine1)
Map< Id< Link >, ? extends Link > getLinks()
QLinkI createNetsimLink(Link link, QNodeI queueNode)
V put(Id< T > key, V value)
Definition: IdMap.java:141
void initialize(QNetsimEngineI simEngine, AgentCounter agentCounter, MobsimTimer simTimer)
Definition: QNetwork.java:63