1 package cz.cuni.amis.pogamut.ut2004.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
26
27
28
29
30 public class AutoTraceRaySharedImpl
31 extends
32 AutoTraceRayShared
33 {
34
35
36
37 public AutoTraceRaySharedImpl(AutoTraceRaySharedImpl source) {
38
39 this.Id = source.
40 getId()
41 ;
42
43 }
44
45 public AutoTraceRaySharedImpl(WorldObjectId objectId, Collection<ISharedProperty> properties) {
46 this.Id = (UnrealId)objectId;
47 NullCheck.check(this.Id, "objectId");
48
49 if (properties.size() != 0) {
50 throw new PogamutException("Not enough properties passed to the constructor.", AutoTraceRaySharedImpl.class);
51 }
52
53
54 for ( ISharedProperty property : properties ) {
55 PropertyId pId = property.getPropertyId();
56 if ( !objectId.equals( property.getObjectId() )) {
57
58 throw new PogamutException("Trying to create a AutoTraceRaySharedImpl with different WorldObjectId properties : " +
59 this.Id.getStringId() + " / " + property.getObjectId().getStringId() , this);
60 }
61 if (!AutoTraceRayShared.SharedPropertyTokens.contains(pId.getPropertyToken())) {
62
63 throw new PogamutException("Trying to create a AutoTraceRaySharedImpl with invalid property (invalid property token): " +
64 this.Id.getStringId() + " / " + property.getPropertyId().getPropertyToken().getToken() , this);
65 }
66 propertyMap.put(property.getPropertyId(), property);
67
68
69 }
70 }
71
72
73 @Override
74 public void setSimTime(long SimTime) {
75 super.setSimTime(SimTime);
76 }
77
78 @Override
79 public
80 AutoTraceRaySharedImpl clone() {
81 return new
82 AutoTraceRaySharedImpl(this);
83 }
84
85
86
87
88
89 protected HashMap<PropertyId, ISharedProperty> propertyMap = new HashMap<PropertyId, ISharedProperty>(
90 0
91 );
92
93 @Override
94 public ISharedProperty getProperty(PropertyId id) {
95 return propertyMap.get(id);
96 }
97
98 @Override
99 public Map<PropertyId, ISharedProperty> getProperties() {
100 return propertyMap;
101 }
102
103
104
105
106
107
108
109
110
111
112 protected
113 UnrealId Id =
114 null;
115
116
117
118
119
120
121
122 public UnrealId getId()
123 {
124 return Id;
125 }
126
127
128
129 public static class AutoTraceRaySharedUpdate
130 implements ISharedWorldObjectUpdatedEvent
131 {
132
133 private AutoTraceRayShared object;
134 private long time;
135 private ITeamId teamId;
136
137 public AutoTraceRaySharedUpdate
138 (AutoTraceRayShared data, long time, ITeamId teamId)
139 {
140 this.object = data;
141 this.time = time;
142 this.teamId = teamId;
143 }
144
145
146
147
148 @Override
149 public long getSimTime() {
150 return this.time;
151 }
152
153 @Override
154 public WorldObjectId getId() {
155 return object.getId();
156 }
157
158 @Override
159 public ITeamId getTeamId() {
160 return teamId;
161 }
162
163 @Override
164 public Class getCompositeObjectClass()
165 {
166 return object.getCompositeClass();
167 }
168
169 @Override
170 public Collection<ISharedPropertyUpdatedEvent> getPropertyEvents() {
171 LinkedList<ISharedPropertyUpdatedEvent> events = new LinkedList<ISharedPropertyUpdatedEvent>();
172
173 for ( ISharedProperty property : object.getProperties().values() )
174 {
175 if ( property != null)
176 {
177 events.push( property.createUpdateEvent(time, teamId) );
178 }
179 }
180 return events;
181 }
182
183 }
184
185
186
187 public String toString() {
188 return
189 super.toString() + "[" +
190
191 "Id = " + String.valueOf(getId()
192 ) + " | " +
193
194 "]";
195 }
196
197
198 public String toHtmlString() {
199 return super.toString() + "[<br/>" +
200
201 "<b>Id</b> = " + String.valueOf(getId()
202 ) + " <br/> " +
203
204 "<br/>]";
205 }
206
207
208
209
210
211
212
213
214
215
216 }
217