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