1 // Copyright 2009, Google Inc. All rights reserved.
2 //
3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions are met:
5 //
6 // 1. Redistributions of source code must retain the above copyright notice,
7 // this list of conditions and the following disclaimer.
8 // 2. Redistributions in binary form must reproduce the above copyright notice,
9 // this list of conditions and the following disclaimer in the documentation
10 // and/or other materials provided with the distribution.
11 // 3. Neither the name of Google Inc. nor the names of its contributors may be
12 // used to endorse or promote products derived from this software without
13 // specific prior written permission.
14 //
15 // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
16 // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
17 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
18 // EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
19 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
21 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
22 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
23 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
24 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
26 // WARNING: THE VISITOR API IMPLEMENTED IN THIS CLASS IS EXPERIMENTAL AND
27 // SUBJECT TO CHANGE WITHOUT WARNING.
28
29 #include "kml/dom/visitor.h"
30
31 #include "kml/dom/kmldom.h"
32 #include "kml/dom/kml_cast.h"
33
34 namespace kmldom {
35
Visitor()36 Visitor::Visitor() { }
37
~Visitor()38 Visitor::~Visitor() { }
39
VisitElement(const ElementPtr & element)40 void Visitor::VisitElement(const ElementPtr& element) {
41 /* Top of element class hierarchy: Do nothing. */
42 }
43
VisitAbstractLatLonBox(const AbstractLatLonBoxPtr & element)44 void Visitor::VisitAbstractLatLonBox(
45 const AbstractLatLonBoxPtr& element) {
46 VisitObject(element);
47 }
48
VisitAbstractLink(const AbstractLinkPtr & element)49 void Visitor::VisitAbstractLink(
50 const AbstractLinkPtr& element) {
51 VisitBasicLink(element);
52 }
53
VisitAbstractView(const AbstractViewPtr & element)54 void Visitor::VisitAbstractView(
55 const AbstractViewPtr& element) {
56 VisitObject(element);
57 }
58
VisitAlias(const AliasPtr & element)59 void Visitor::VisitAlias(
60 const AliasPtr& element) {
61 VisitObject(element);
62 }
63
VisitBalloonStyle(const BalloonStylePtr & element)64 void Visitor::VisitBalloonStyle(
65 const BalloonStylePtr& element) {
66 VisitSubStyle(element);
67 }
68
VisitBasicLink(const BasicLinkPtr & element)69 void Visitor::VisitBasicLink(
70 const BasicLinkPtr& element) {
71 VisitObject(element);
72 }
73
VisitCamera(const CameraPtr & element)74 void Visitor::VisitCamera(
75 const CameraPtr& element) {
76 VisitAbstractView(element);
77 }
78
VisitChange(const ChangePtr & element)79 void Visitor::VisitChange(
80 const ChangePtr& element) {
81 VisitUpdateOperation(element);
82 }
83
VisitColorStyle(const ColorStylePtr & element)84 void Visitor::VisitColorStyle(
85 const ColorStylePtr& element) {
86 VisitSubStyle(element);
87 }
88
VisitContainer(const ContainerPtr & element)89 void Visitor::VisitContainer(
90 const ContainerPtr& element) {
91 VisitFeature(element);
92 }
93
VisitCoordinates(const CoordinatesPtr & element)94 void Visitor::VisitCoordinates(
95 const CoordinatesPtr& element) {
96 VisitElement(element);
97 }
98
VisitCreate(const CreatePtr & element)99 void Visitor::VisitCreate(
100 const CreatePtr& element) {
101 VisitUpdateOperation(element);
102 }
103
VisitData(const DataPtr & element)104 void Visitor::VisitData(
105 const DataPtr& element) {
106 VisitObject(element);
107 }
108
VisitDelete(const DeletePtr & element)109 void Visitor::VisitDelete(
110 const DeletePtr& element) {
111 VisitUpdateOperation(element);
112 }
113
VisitDocument(const DocumentPtr & element)114 void Visitor::VisitDocument(
115 const DocumentPtr& element) {
116 VisitContainer(element);
117 }
118
VisitExtendedData(const ExtendedDataPtr & element)119 void Visitor::VisitExtendedData(
120 const ExtendedDataPtr& element) {
121 VisitElement(element);
122 }
123
VisitFeature(const FeaturePtr & element)124 void Visitor::VisitFeature(
125 const FeaturePtr& element) {
126 VisitObject(element);
127 }
128
VisitField(const FieldPtr & element)129 void Visitor::VisitField(
130 const FieldPtr& element) {
131 VisitElement(element);
132 }
133
VisitFolder(const FolderPtr & element)134 void Visitor::VisitFolder(
135 const FolderPtr& element) {
136 VisitContainer(element);
137 }
138
VisitGeometry(const GeometryPtr & element)139 void Visitor::VisitGeometry(
140 const GeometryPtr& element) {
141 VisitObject(element);
142 }
143
VisitGroundOverlay(const GroundOverlayPtr & element)144 void Visitor::VisitGroundOverlay(
145 const GroundOverlayPtr& element) {
146 VisitOverlay(element);
147 }
148
VisitGxAnimatedUpdate(const GxAnimatedUpdatePtr & element)149 void Visitor::VisitGxAnimatedUpdate(
150 const GxAnimatedUpdatePtr& element) {
151 VisitGxTourPrimitive(element);
152 }
153
VisitGxFlyTo(const GxFlyToPtr & element)154 void Visitor::VisitGxFlyTo(
155 const GxFlyToPtr& element) {
156 VisitGxTourPrimitive(element);
157 }
158
VisitGxLatLonQuad(const GxLatLonQuadPtr & element)159 void Visitor::VisitGxLatLonQuad(
160 const GxLatLonQuadPtr& element) {
161 VisitObject(element);
162 }
163
VisitGxMultiTrack(const GxMultiTrackPtr & element)164 void Visitor::VisitGxMultiTrack(
165 const GxMultiTrackPtr& element) {
166 VisitGeometry(element);
167 }
168
VisitGxPlaylist(const GxPlaylistPtr & element)169 void Visitor::VisitGxPlaylist(
170 const GxPlaylistPtr& element) {
171 VisitObject(element);
172 }
173
VisitGxSimpleArrayData(const GxSimpleArrayDataPtr & element)174 void Visitor::VisitGxSimpleArrayData(
175 const GxSimpleArrayDataPtr& element) {
176 VisitElement(element);
177 }
178
VisitGxSimpleArrayField(const GxSimpleArrayFieldPtr & element)179 void Visitor::VisitGxSimpleArrayField(
180 const GxSimpleArrayFieldPtr& element) {
181 VisitSimpleField(element);
182 }
183
VisitGxSoundCue(const GxSoundCuePtr & element)184 void Visitor::VisitGxSoundCue(
185 const GxSoundCuePtr& element) {
186 VisitGxTourPrimitive(element);
187 }
188
VisitGxTimeSpan(const GxTimeSpanPtr & element)189 void Visitor::VisitGxTimeSpan(
190 const GxTimeSpanPtr& element) {
191 VisitTimeSpan(element);
192 }
193
VisitGxTimeStamp(const GxTimeStampPtr & element)194 void Visitor::VisitGxTimeStamp(
195 const GxTimeStampPtr& element) {
196 VisitTimeStamp(element);
197 }
198
VisitGxTour(const GxTourPtr & element)199 void Visitor::VisitGxTour(
200 const GxTourPtr& element) {
201 VisitFeature(element);
202 }
203
VisitGxTourControl(const GxTourControlPtr & element)204 void Visitor::VisitGxTourControl(
205 const GxTourControlPtr& element) {
206 VisitGxTourPrimitive(element);
207 }
208
VisitGxTourPrimitive(const GxTourPrimitivePtr & element)209 void Visitor::VisitGxTourPrimitive(
210 const GxTourPrimitivePtr& element) {
211 VisitObject(element);
212 }
213
VisitGxTrack(const GxTrackPtr & element)214 void Visitor::VisitGxTrack(
215 const GxTrackPtr& element) {
216 VisitGeometry(element);
217 }
218
VisitGxWait(const GxWaitPtr & element)219 void Visitor::VisitGxWait(
220 const GxWaitPtr& element) {
221 VisitGxTourPrimitive(element);
222 }
223
VisitHotSpot(const HotSpotPtr & element)224 void Visitor::VisitHotSpot(
225 const HotSpotPtr& element) {
226 VisitVec2(element);
227 }
228
VisitIcon(const IconPtr & element)229 void Visitor::VisitIcon(
230 const IconPtr& element) {
231 VisitAbstractLink(element);
232 }
233
VisitIconStyle(const IconStylePtr & element)234 void Visitor::VisitIconStyle(
235 const IconStylePtr& element) {
236 VisitColorStyle(element);
237 }
238
VisitIconStyleIcon(const IconStyleIconPtr & element)239 void Visitor::VisitIconStyleIcon(
240 const IconStyleIconPtr& element) {
241 VisitBasicLink(element);
242 }
243
VisitImagePyramid(const ImagePyramidPtr & element)244 void Visitor::VisitImagePyramid(
245 const ImagePyramidPtr& element) {
246 VisitObject(element);
247 }
248
VisitInnerBoundaryIs(const InnerBoundaryIsPtr & element)249 void Visitor::VisitInnerBoundaryIs(
250 const InnerBoundaryIsPtr& element) {
251 VisitElement(element);
252 }
253
VisitItemIcon(const ItemIconPtr & element)254 void Visitor::VisitItemIcon(
255 const ItemIconPtr& element) {
256 VisitObject(element);
257 }
258
VisitKml(const KmlPtr & element)259 void Visitor::VisitKml(
260 const KmlPtr& element) {
261 VisitElement(element);
262 }
263
VisitLabelStyle(const LabelStylePtr & element)264 void Visitor::VisitLabelStyle(
265 const LabelStylePtr& element) {
266 VisitColorStyle(element);
267 }
268
VisitLatLonAltBox(const LatLonAltBoxPtr & element)269 void Visitor::VisitLatLonAltBox(
270 const LatLonAltBoxPtr& element) {
271 VisitAbstractLatLonBox(element);
272 }
273
VisitLatLonBox(const LatLonBoxPtr & element)274 void Visitor::VisitLatLonBox(
275 const LatLonBoxPtr& element) {
276 VisitAbstractLatLonBox(element);
277 }
278
VisitLineString(const LineStringPtr & element)279 void Visitor::VisitLineString(
280 const LineStringPtr& element) {
281 VisitGeometry(element);
282 }
283
VisitLineStyle(const LineStylePtr & element)284 void Visitor::VisitLineStyle(
285 const LineStylePtr& element) {
286 VisitColorStyle(element);
287 }
288
VisitLinearRing(const LinearRingPtr & element)289 void Visitor::VisitLinearRing(
290 const LinearRingPtr& element) {
291 VisitGeometry(element);
292 }
293
VisitLink(const LinkPtr & element)294 void Visitor::VisitLink(
295 const LinkPtr& element) {
296 VisitAbstractLink(element);
297 }
298
VisitLinkSnippet(const LinkSnippetPtr & element)299 void Visitor::VisitLinkSnippet(
300 const LinkSnippetPtr& element) {
301 VisitElement(element);
302 }
303
VisitListStyle(const ListStylePtr & element)304 void Visitor::VisitListStyle(
305 const ListStylePtr& element) {
306 VisitSubStyle(element);
307 }
308
VisitLocation(const LocationPtr & element)309 void Visitor::VisitLocation(
310 const LocationPtr& element) {
311 VisitObject(element);
312 }
313
VisitLod(const LodPtr & element)314 void Visitor::VisitLod(
315 const LodPtr& element) {
316 VisitObject(element);
317 }
318
VisitLookAt(const LookAtPtr & element)319 void Visitor::VisitLookAt(
320 const LookAtPtr& element) {
321 VisitAbstractView(element);
322 }
323
VisitMetadata(const MetadataPtr & element)324 void Visitor::VisitMetadata(
325 const MetadataPtr& element) {
326 VisitElement(element);
327 }
328
VisitModel(const ModelPtr & element)329 void Visitor::VisitModel(
330 const ModelPtr& element) {
331 VisitGeometry(element);
332 }
333
VisitMultiGeometry(const MultiGeometryPtr & element)334 void Visitor::VisitMultiGeometry(
335 const MultiGeometryPtr& element) {
336 VisitGeometry(element);
337 }
338
VisitNetworkLink(const NetworkLinkPtr & element)339 void Visitor::VisitNetworkLink(
340 const NetworkLinkPtr& element) {
341 VisitFeature(element);
342 }
343
VisitNetworkLinkControl(const NetworkLinkControlPtr & element)344 void Visitor::VisitNetworkLinkControl(
345 const NetworkLinkControlPtr& element) {
346 VisitElement(element);
347 }
348
VisitObject(const ObjectPtr & element)349 void Visitor::VisitObject(
350 const ObjectPtr& element) {
351 VisitElement(element);
352 }
353
VisitOrientation(const OrientationPtr & element)354 void Visitor::VisitOrientation(
355 const OrientationPtr& element) {
356 VisitObject(element);
357 }
358
VisitOuterBoundaryIs(const OuterBoundaryIsPtr & element)359 void Visitor::VisitOuterBoundaryIs(
360 const OuterBoundaryIsPtr& element) {
361 VisitElement(element);
362 }
363
VisitOverlay(const OverlayPtr & element)364 void Visitor::VisitOverlay(
365 const OverlayPtr& element) {
366 VisitFeature(element);
367 }
368
VisitOverlayXY(const OverlayXYPtr & element)369 void Visitor::VisitOverlayXY(
370 const OverlayXYPtr& element) {
371 VisitVec2(element);
372 }
373
VisitPair(const PairPtr & element)374 void Visitor::VisitPair(
375 const PairPtr& element) {
376 VisitObject(element);
377 }
378
VisitPhotoOverlay(const PhotoOverlayPtr & element)379 void Visitor::VisitPhotoOverlay(
380 const PhotoOverlayPtr& element) {
381 VisitOverlay(element);
382 }
383
VisitPlacemark(const PlacemarkPtr & element)384 void Visitor::VisitPlacemark(
385 const PlacemarkPtr& element) {
386 VisitFeature(element);
387 }
388
VisitPoint(const PointPtr & element)389 void Visitor::VisitPoint(
390 const PointPtr& element) {
391 VisitGeometry(element);
392 }
393
VisitPolyStyle(const PolyStylePtr & element)394 void Visitor::VisitPolyStyle(
395 const PolyStylePtr& element) {
396 VisitColorStyle(element);
397 }
398
VisitPolygon(const PolygonPtr & element)399 void Visitor::VisitPolygon(
400 const PolygonPtr& element) {
401 VisitGeometry(element);
402 }
403
VisitRegion(const RegionPtr & element)404 void Visitor::VisitRegion(
405 const RegionPtr& element) {
406 VisitObject(element);
407 }
408
VisitResourceMap(const ResourceMapPtr & element)409 void Visitor::VisitResourceMap(
410 const ResourceMapPtr& element) {
411 VisitObject(element);
412 }
413
VisitRotationXY(const RotationXYPtr & element)414 void Visitor::VisitRotationXY(
415 const RotationXYPtr& element) {
416 VisitVec2(element);
417 }
418
VisitScale(const ScalePtr & element)419 void Visitor::VisitScale(
420 const ScalePtr& element) {
421 VisitObject(element);
422 }
423
VisitSchema(const SchemaPtr & element)424 void Visitor::VisitSchema(
425 const SchemaPtr& element) {
426 VisitObject(element);
427 }
428
VisitSchemaData(const SchemaDataPtr & element)429 void Visitor::VisitSchemaData(
430 const SchemaDataPtr& element) {
431 VisitObject(element);
432 }
433
VisitScreenOverlay(const ScreenOverlayPtr & element)434 void Visitor::VisitScreenOverlay(
435 const ScreenOverlayPtr& element) {
436 VisitOverlay(element);
437 }
438
VisitScreenXY(const ScreenXYPtr & element)439 void Visitor::VisitScreenXY(
440 const ScreenXYPtr& element) {
441 VisitVec2(element);
442 }
443
VisitSimpleData(const SimpleDataPtr & element)444 void Visitor::VisitSimpleData(
445 const SimpleDataPtr& element) {
446 VisitElement(element);
447 }
448
VisitSimpleField(const SimpleFieldPtr & element)449 void Visitor::VisitSimpleField(
450 const SimpleFieldPtr& element) {
451 VisitElement(element);
452 }
453
VisitSize(const SizePtr & element)454 void Visitor::VisitSize(
455 const SizePtr& element) {
456 VisitVec2(element);
457 }
458
VisitSnippet(const SnippetPtr & element)459 void Visitor::VisitSnippet(
460 const SnippetPtr& element) {
461 VisitElement(element);
462 }
463
VisitStyle(const StylePtr & element)464 void Visitor::VisitStyle(
465 const StylePtr& element) {
466 VisitStyleSelector(element);
467 }
468
VisitStyleMap(const StyleMapPtr & element)469 void Visitor::VisitStyleMap(
470 const StyleMapPtr& element) {
471 VisitStyleSelector(element);
472 }
473
VisitStyleSelector(const StyleSelectorPtr & element)474 void Visitor::VisitStyleSelector(
475 const StyleSelectorPtr& element) {
476 VisitObject(element);
477 }
478
VisitSubStyle(const SubStylePtr & element)479 void Visitor::VisitSubStyle(
480 const SubStylePtr& element) {
481 VisitObject(element);
482 }
483
VisitTimePrimitive(const TimePrimitivePtr & element)484 void Visitor::VisitTimePrimitive(
485 const TimePrimitivePtr& element) {
486 VisitObject(element);
487 }
488
VisitTimeSpan(const TimeSpanPtr & element)489 void Visitor::VisitTimeSpan(
490 const TimeSpanPtr& element) {
491 VisitTimePrimitive(element);
492 }
493
VisitTimeStamp(const TimeStampPtr & element)494 void Visitor::VisitTimeStamp(
495 const TimeStampPtr& element) {
496 VisitTimePrimitive(element);
497 }
498
VisitUpdate(const UpdatePtr & element)499 void Visitor::VisitUpdate(
500 const UpdatePtr& element) {
501 VisitElement(element);
502 }
503
VisitUpdateOperation(const UpdateOperationPtr & element)504 void Visitor::VisitUpdateOperation(
505 const UpdateOperationPtr& element) {
506 VisitElement(element);
507 }
508
VisitUrl(const UrlPtr & element)509 void Visitor::VisitUrl(
510 const UrlPtr& element) {
511 VisitAbstractLink(element);
512 }
513
VisitVec2(const Vec2Ptr & element)514 void Visitor::VisitVec2(
515 const Vec2Ptr& element) {
516 VisitElement(element);
517 }
518
VisitViewVolume(const ViewVolumePtr & element)519 void Visitor::VisitViewVolume(
520 const ViewVolumePtr& element) {
521 VisitObject(element);
522 }
523
524 } // end namespace kmldom
525