1 package cz.cuni.amis.pogamut.ut2004.teamcomm.mina.model;
2
3 import java.io.Serializable;
4 import java.util.HashMap;
5 import java.util.HashSet;
6 import java.util.Map;
7 import java.util.Set;
8
9 import cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId;
10 import cz.cuni.amis.pogamut.ut2004.teamcomm.mina.server.TCMinaServer;
11
12 public class TCTeam implements Serializable, Cloneable {
13
14
15
16
17 private static final long serialVersionUID = -6503924718003317176L;
18
19 private int team = 0;
20
21 private Set<UnrealId> connectedBots = new HashSet<UnrealId>();
22
23 private Map<Integer, TCChannel> channels = new HashMap<Integer, TCChannel>();
24
25
26
27
28 private transient int lastChannelId = 0;
29
30 public TCTeam() {
31 }
32
33 public TCTeam clone() {
34 TCTeam result = new TCTeam();
35 synchronized(connectedBots) {
36 result.getConnectedBots().addAll(connectedBots);
37 }
38 synchronized(channels){
39 for (TCChannel channel : channels.values()) {
40 synchronized(channel) {
41 result.getChannels().put(channel.getChannelId(), channel.clone());
42 }
43 }
44 }
45 return result;
46 }
47
48 public TCTeam(Integer team) {
49 this.team = team;
50 }
51
52 public int getTeam() {
53 return team;
54 }
55
56 public void setTeam(int team) {
57 this.team = team;
58 }
59
60 public Set<UnrealId> getConnectedBots() {
61 return connectedBots;
62 }
63
64 public void setConnectedBots(Set<UnrealId> connectedBots) {
65 this.connectedBots = connectedBots;
66 }
67
68 public Map<Integer, TCChannel> getChannels() {
69 return channels;
70 }
71
72 public void setChannels(Map<Integer, TCChannel> channels) {
73 this.channels = channels;
74 }
75
76 public int getNextChannelId() {
77 return ++lastChannelId;
78 }
79
80 }