1 package cz.cuni.amis.pogamut.ut3.communication.messages.gbinfomessages;
2
3
4 import java.util.*;import javax.vecmath.*;import cz.cuni.amis.pogamut.base.communication.messages.*;import cz.cuni.amis.pogamut.base.communication.worldview.*;import cz.cuni.amis.pogamut.base.communication.worldview.event.*;import cz.cuni.amis.pogamut.base.communication.worldview.object.*;import cz.cuni.amis.pogamut.multi.communication.worldview.object.*;import cz.cuni.amis.pogamut.base.communication.translator.event.*;import cz.cuni.amis.pogamut.multi.communication.translator.event.*;import cz.cuni.amis.pogamut.base3d.worldview.object.*;import cz.cuni.amis.pogamut.base3d.worldview.object.event.*;import cz.cuni.amis.pogamut.ut2004.communication.messages.*;import cz.cuni.amis.pogamut.ut2004.communication.worldview.objects.*;import cz.cuni.amis.pogamut.ut2004multi.communication.worldview.objects.*;import cz.cuni.amis.pogamut.ut2004.communication.translator.itemdescriptor.*;import cz.cuni.amis.pogamut.ut2004.communication.messages.ItemType.Category;import cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId;import cz.cuni.amis.utils.exception.*;import cz.cuni.amis.pogamut.base.communication.translator.event.IWorldObjectUpdateResult.Result;import cz.cuni.amis.utils.SafeEquals;import cz.cuni.amis.pogamut.base.agent.*;import cz.cuni.amis.pogamut.multi.agent.*;import cz.cuni.amis.pogamut.multi.communication.worldview.property.*;import cz.cuni.amis.pogamut.ut2004multi.communication.worldview.property.*;import cz.cuni.amis.utils.token.*;import cz.cuni.amis.utils.*;
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 public class EmptySharedImpl
26 extends
27 EmptyShared
28 {
29
30
31
32 public EmptySharedImpl(EmptySharedImpl source) {
33
34 }
35
36 public EmptySharedImpl(WorldObjectId objectId, Collection<ISharedProperty> properties) {
37 this.Id = (UnrealId)objectId;
38 NullCheck.check(this.Id, "objectId");
39
40 if (properties.size() != 0) {
41 throw new PogamutException("Not enough properties passed to the constructor.", EmptySharedImpl.class);
42 }
43
44
45 for ( ISharedProperty property : properties ) {
46 PropertyId pId = property.getPropertyId();
47 if ( !objectId.equals( property.getObjectId() )) {
48
49 throw new PogamutException("Trying to create a EmptySharedImpl with different WorldObjectId properties : " +
50 this.Id.getStringId() + " / " + property.getObjectId().getStringId() , this);
51 }
52 if (!EmptyShared.SharedPropertyTokens.contains(pId.getPropertyToken())) {
53
54 throw new PogamutException("Trying to create a EmptySharedImpl with invalid property (invalid property token): " +
55 this.Id.getStringId() + " / " + property.getPropertyId().getPropertyToken().getToken() , this);
56 }
57 propertyMap.put(property.getPropertyId(), property);
58
59
60 }
61 }
62
63
64 private UnrealId Id = cz.cuni.amis.pogamut.ut3.communication.messages.gbinfomessages.Empty.EmptyId;
65
66 public UnrealId getId() {
67 return Id;
68 }
69
70
71 @Override
72 public void setSimTime(long SimTime) {
73 super.setSimTime(SimTime);
74 }
75
76 @Override
77 public
78 EmptySharedImpl clone() {
79 return new
80 EmptySharedImpl(this);
81 }
82
83
84
85
86
87 protected HashMap<PropertyId, ISharedProperty> propertyMap = new HashMap<PropertyId, ISharedProperty>(
88 0
89 );
90
91 @Override
92 public ISharedProperty getProperty(PropertyId id) {
93 return propertyMap.get(id);
94 }
95
96 @Override
97 public Map<PropertyId, ISharedProperty> getProperties() {
98 return propertyMap;
99 }
100
101
102
103
104
105 public static class EmptySharedUpdate
106 implements ISharedWorldObjectUpdatedEvent
107 {
108
109 private EmptyShared object;
110 private long time;
111 private ITeamId teamId;
112
113 public EmptySharedUpdate
114 (EmptyShared data, long time, ITeamId teamId)
115 {
116 this.object = data;
117 this.time = time;
118 this.teamId = teamId;
119 }
120
121
122
123
124 @Override
125 public long getSimTime() {
126 return this.time;
127 }
128
129 @Override
130 public WorldObjectId getId() {
131 return object.getId();
132 }
133
134 @Override
135 public ITeamId getTeamId() {
136 return teamId;
137 }
138
139 @Override
140 public Class getCompositeObjectClass()
141 {
142 return object.getCompositeClass();
143 }
144
145 @Override
146 public Collection<ISharedPropertyUpdatedEvent> getPropertyEvents() {
147 LinkedList<ISharedPropertyUpdatedEvent> events = new LinkedList<ISharedPropertyUpdatedEvent>();
148
149 for ( ISharedProperty property : object.getProperties().values() )
150 {
151 if ( property != null)
152 {
153 events.push( property.createUpdateEvent(time, teamId) );
154 }
155 }
156 return events;
157 }
158
159 }
160
161
162
163 public String toString() {
164 return
165 super.toString() + "[" +
166
167 "]";
168 }
169
170
171 public String toHtmlString() {
172 return super.toString() + "[<br/>" +
173
174 "<br/>]";
175 }
176
177
178
179
180
181
182
183
184
185
186 }
187