1 // Copyright 2008, 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 #include "kml/dom/kml_factory.h"
27 #include "kml/dom/kml22.h"
28 #include "kml/dom/kml_ptr.h"
29 #include "kml/dom/kmldom.h"
30 #include "kml/dom/xsd.h"
31
32 namespace kmldom {
33
34 KmlFactory* KmlFactory::factory_ = NULL;
35
36 // static
GetFactory()37 KmlFactory* KmlFactory::GetFactory() {
38 if (factory_ == NULL) {
39 factory_ = new KmlFactory();
40 }
41 return factory_;
42 }
43
CreateElementById(KmlDomType id) const44 ElementPtr KmlFactory::CreateElementById(KmlDomType id) const {
45 switch (id) {
46 case Type_Alias: return CreateAlias();
47 case Type_AtomAuthor: return CreateAtomAuthor();
48 case Type_AtomCategory: return CreateAtomCategory();
49 case Type_AtomContent: return CreateAtomContent();
50 case Type_AtomEntry: return CreateAtomEntry();
51 case Type_AtomFeed: return CreateAtomFeed();
52 case Type_AtomLink: return CreateAtomLink();
53 case Type_BalloonStyle: return CreateBalloonStyle();
54 case Type_Camera: return CreateCamera();
55 case Type_Change: return CreateChange();
56 case Type_Create: return CreateCreate();
57 case Type_Data: return CreateData();
58 case Type_Delete: return CreateDelete();
59 case Type_Document: return CreateDocument();
60 case Type_ExtendedData: return CreateExtendedData();
61 case Type_Folder: return CreateFolder();
62 case Type_GroundOverlay: return CreateGroundOverlay();
63 case Type_Icon: return CreateIcon();
64 case Type_IconStyle: return CreateIconStyle();
65 case Type_IconStyleIcon: return CreateIconStyleIcon();
66 case Type_ImagePyramid: return CreateImagePyramid();
67 case Type_ItemIcon: return CreateItemIcon();
68 case Type_LabelStyle: return CreateLabelStyle();
69 case Type_LatLonBox: return CreateLatLonBox();
70 case Type_LatLonAltBox: return CreateLatLonAltBox();
71 case Type_LinearRing: return CreateLinearRing();
72 case Type_LineString: return CreateLineString();
73 case Type_LineStyle: return CreateLineStyle();
74 case Type_Link: return CreateLink();
75 case Type_ListStyle: return CreateListStyle();
76 case Type_Location: return CreateLocation();
77 case Type_Lod: return CreateLod();
78 case Type_LookAt: return CreateLookAt();
79 case Type_Metadata: return CreateMetadata();
80 case Type_Model: return CreateModel();
81 case Type_MultiGeometry: return CreateMultiGeometry();
82 case Type_NetworkLink: return CreateNetworkLink();
83 case Type_NetworkLinkControl: return CreateNetworkLinkControl();
84 case Type_Orientation: return CreateOrientation();
85 case Type_Pair: return CreatePair();
86 case Type_PhotoOverlay: return CreatePhotoOverlay();
87 case Type_Placemark: return CreatePlacemark();
88 case Type_PolyStyle: return CreatePolyStyle();
89 case Type_Point: return CreatePoint();
90 case Type_Polygon: return CreatePolygon();
91 case Type_Region: return CreateRegion();
92 case Type_ResourceMap: return CreateResourceMap();
93 case Type_Scale: return CreateScale();
94 case Type_Schema: return CreateSchema();
95 case Type_SchemaData: return CreateSchemaData();
96 case Type_ScreenOverlay: return CreateScreenOverlay();
97 case Type_SimpleData: return CreateSimpleData();
98 case Type_SimpleField: return CreateSimpleField();
99 case Type_Snippet: return CreateSnippet();
100 case Type_Style: return CreateStyle();
101 case Type_StyleMap: return CreateStyleMap();
102 case Type_TimeSpan: return CreateTimeSpan();
103 case Type_TimeStamp: return CreateTimeStamp();
104 case Type_ViewVolume: return CreateViewVolume();
105 case Type_Update: return CreateUpdate();
106 case Type_Url: return CreateUrl();
107 case Type_coordinates: return CreateCoordinates();
108 case Type_hotSpot: return CreateHotSpot();
109 case Type_innerBoundaryIs: return CreateInnerBoundaryIs();
110 case Type_kml: return CreateKml();
111 case Type_linkSnippet: return CreateLinkSnippet();
112 case Type_overlayXY: return CreateOverlayXY();
113 case Type_outerBoundaryIs: return CreateOuterBoundaryIs();
114 case Type_rotationXY: return CreateRotationXY();
115 case Type_screenXY: return CreateScreenXY();
116 case Type_size: return CreateSize();
117 case Type_XalAddressDetails: return CreateXalAddressDetails();
118 case Type_XalAdministrativeArea: return CreateXalAdministrativeArea();
119 case Type_XalCountry: return CreateXalCountry();
120 case Type_XalLocality: return CreateXalLocality();
121 case Type_XalPostalCode: return CreateXalPostalCode();
122 case Type_XalSubAdministrativeArea: return CreateXalSubAdministrativeArea();
123 case Type_XalThoroughfare: return CreateXalThoroughfare();
124
125 case Type_GxAnimatedUpdate: return CreateGxAnimatedUpdate();
126 case Type_GxFlyTo: return CreateGxFlyTo();
127 case Type_GxLatLonQuad: return CreateGxLatLonQuad();
128 case Type_GxMultiTrack: return CreateGxMultiTrack();
129 case Type_GxPlaylist: return CreateGxPlaylist();
130 case Type_GxSimpleArrayData: return CreateGxSimpleArrayData();
131 case Type_GxSimpleArrayField: return CreateGxSimpleArrayField();
132 case Type_GxSoundCue: return CreateGxSoundCue();
133 case Type_GxTimeSpan: return CreateGxTimeSpan();
134 case Type_GxTimeStamp: return CreateGxTimeStamp();
135 case Type_GxTour: return CreateGxTour();
136 case Type_GxTourControl: return CreateGxTourControl();
137 case Type_GxTrack: return CreateGxTrack();
138 case Type_GxWait: return CreateGxWait();
139
140 default: return NULL;
141 }
142 }
143
CreateElementFromName(const string & element_name) const144 ElementPtr KmlFactory::CreateElementFromName(const string& element_name) const {
145 return CreateElementById(
146 static_cast<KmlDomType>(Xsd::GetSchema()->ElementId(element_name)));
147 }
148
CreateFieldById(KmlDomType type_id) const149 Field* KmlFactory::CreateFieldById(KmlDomType type_id) const {
150 return new Field(type_id);
151 }
152
CreateAlias() const153 Alias* KmlFactory::CreateAlias() const {
154 return new Alias();
155 }
156
CreateAtomAuthor() const157 AtomAuthor* KmlFactory::CreateAtomAuthor() const {
158 return new AtomAuthor();
159 }
160
CreateAtomCategory() const161 AtomCategory* KmlFactory::CreateAtomCategory() const {
162 return new AtomCategory();
163 }
164
CreateAtomContent() const165 AtomContent* KmlFactory::CreateAtomContent() const {
166 return new AtomContent();
167 }
168
CreateAtomEntry() const169 AtomEntry* KmlFactory::CreateAtomEntry() const {
170 return new AtomEntry();
171 }
172
CreateAtomFeed() const173 AtomFeed* KmlFactory::CreateAtomFeed() const {
174 return new AtomFeed();
175 }
176
CreateAtomLink() const177 AtomLink* KmlFactory::CreateAtomLink() const {
178 return new AtomLink();
179 }
180
CreateBalloonStyle() const181 BalloonStyle* KmlFactory::CreateBalloonStyle() const {
182 return new BalloonStyle();
183 }
184
CreateCamera() const185 Camera* KmlFactory::CreateCamera() const {
186 return new Camera();
187 }
188
CreateChange() const189 Change* KmlFactory::CreateChange() const {
190 return new Change();
191 }
192
CreateCreate() const193 Create* KmlFactory::CreateCreate() const {
194 return new Create();
195 }
196
CreateData() const197 Data* KmlFactory::CreateData() const {
198 return new Data();
199 }
200
CreateDelete() const201 Delete* KmlFactory::CreateDelete() const {
202 return new Delete();
203 }
204
CreateDocument() const205 Document* KmlFactory::CreateDocument() const {
206 return new Document();
207 }
208
CreateExtendedData() const209 ExtendedData* KmlFactory::CreateExtendedData() const {
210 return new ExtendedData();
211 }
212
CreateFolder() const213 Folder* KmlFactory::CreateFolder() const {
214 return new Folder();
215 }
216
CreateGroundOverlay() const217 GroundOverlay* KmlFactory::CreateGroundOverlay() const {
218 return new GroundOverlay();
219 }
220
CreateHotSpot() const221 HotSpot* KmlFactory::CreateHotSpot() const {
222 return new HotSpot();
223 }
224
CreateIcon() const225 Icon* KmlFactory::CreateIcon() const {
226 return new Icon();
227 }
228
CreateIconStyle() const229 IconStyle* KmlFactory::CreateIconStyle() const {
230 return new IconStyle();
231 }
232
CreateIconStyleIcon() const233 IconStyleIcon* KmlFactory::CreateIconStyleIcon() const {
234 return new IconStyleIcon();
235 }
236
CreateImagePyramid() const237 ImagePyramid* KmlFactory::CreateImagePyramid() const {
238 return new ImagePyramid();
239 }
240
CreateInnerBoundaryIs() const241 InnerBoundaryIs* KmlFactory::CreateInnerBoundaryIs() const {
242 return new InnerBoundaryIs();
243 }
244
CreateItemIcon() const245 ItemIcon* KmlFactory::CreateItemIcon() const {
246 return new ItemIcon();
247 }
248
CreateKml() const249 Kml* KmlFactory::CreateKml() const {
250 return new Kml();
251 }
252
CreateLabelStyle() const253 LabelStyle* KmlFactory::CreateLabelStyle() const {
254 return new LabelStyle();
255 }
256
CreateLatLonBox() const257 LatLonBox* KmlFactory::CreateLatLonBox() const {
258 return new LatLonBox();
259 }
260
CreateLatLonAltBox() const261 LatLonAltBox* KmlFactory::CreateLatLonAltBox() const {
262 return new LatLonAltBox();
263 }
264
CreateLinearRing() const265 LinearRing* KmlFactory::CreateLinearRing() const {
266 return new LinearRing();
267 }
268
CreateLineString() const269 LineString* KmlFactory::CreateLineString() const {
270 return new LineString();
271 }
272
CreateLineStyle() const273 LineStyle* KmlFactory::CreateLineStyle() const {
274 return new LineStyle();
275 }
276
CreateLink() const277 Link* KmlFactory::CreateLink() const {
278 return new Link();
279 }
280
CreateLinkSnippet() const281 LinkSnippet* KmlFactory::CreateLinkSnippet() const {
282 return new LinkSnippet();
283 }
284
CreateListStyle() const285 ListStyle* KmlFactory::CreateListStyle() const {
286 return new ListStyle();
287 }
288
CreateLocation() const289 Location* KmlFactory::CreateLocation() const {
290 return new Location();
291 }
292
CreateLod() const293 Lod* KmlFactory::CreateLod() const {
294 return new Lod();
295 }
296
CreateLookAt() const297 LookAt* KmlFactory::CreateLookAt() const {
298 return new LookAt();
299 }
300
CreateMetadata() const301 Metadata* KmlFactory::CreateMetadata() const {
302 return new Metadata();
303 }
304
CreateModel() const305 Model* KmlFactory::CreateModel() const {
306 return new Model();
307 }
308
CreateMultiGeometry() const309 MultiGeometry* KmlFactory::CreateMultiGeometry() const {
310 return new MultiGeometry();
311 }
312
CreateNetworkLink() const313 NetworkLink* KmlFactory::CreateNetworkLink() const {
314 return new NetworkLink();
315 }
316
CreateNetworkLinkControl() const317 NetworkLinkControl* KmlFactory::CreateNetworkLinkControl() const {
318 return new NetworkLinkControl();
319 }
320
CreateOrientation() const321 Orientation* KmlFactory::CreateOrientation() const {
322 return new Orientation();
323 }
324
CreateOuterBoundaryIs() const325 OuterBoundaryIs* KmlFactory::CreateOuterBoundaryIs() const {
326 return new OuterBoundaryIs();
327 }
328
CreateOverlayXY() const329 OverlayXY* KmlFactory::CreateOverlayXY() const {
330 return new OverlayXY();
331 }
332
CreatePair() const333 Pair* KmlFactory::CreatePair() const {
334 return new Pair();
335 }
336
CreatePhotoOverlay() const337 PhotoOverlay* KmlFactory::CreatePhotoOverlay() const {
338 return new PhotoOverlay();
339 }
340
CreatePlacemark() const341 Placemark* KmlFactory::CreatePlacemark() const {
342 return new Placemark();
343 }
344
CreatePoint() const345 Point* KmlFactory::CreatePoint() const {
346 return new Point();
347 }
348
CreatePolygon() const349 Polygon* KmlFactory::CreatePolygon() const {
350 return new Polygon();
351 }
352
CreatePolyStyle() const353 PolyStyle* KmlFactory::CreatePolyStyle() const {
354 return new PolyStyle();
355 }
356
CreateRegion() const357 Region* KmlFactory::CreateRegion() const {
358 return new Region();
359 }
360
CreateResourceMap() const361 ResourceMap* KmlFactory::CreateResourceMap() const {
362 return new ResourceMap();
363 }
364
CreateRotationXY() const365 RotationXY* KmlFactory::CreateRotationXY() const {
366 return new RotationXY();
367 }
368
CreateScale() const369 Scale* KmlFactory::CreateScale() const {
370 return new Scale();
371 }
372
CreateScreenOverlay() const373 ScreenOverlay* KmlFactory::CreateScreenOverlay() const {
374 return new ScreenOverlay();
375 }
376
CreateCoordinates() const377 Coordinates* KmlFactory::CreateCoordinates() const {
378 return new Coordinates();
379 }
380
CreateScreenXY() const381 ScreenXY* KmlFactory::CreateScreenXY() const {
382 return new ScreenXY();
383 }
384
CreateSchema() const385 Schema* KmlFactory::CreateSchema() const {
386 return new Schema();
387 }
388
CreateSchemaData() const389 SchemaData* KmlFactory::CreateSchemaData() const {
390 return new SchemaData();
391 }
392
CreateUpdate() const393 Update* KmlFactory::CreateUpdate() const {
394 return new Update();
395 }
396
CreateUrl() const397 Url* KmlFactory::CreateUrl() const {
398 return new Url();
399 }
400
CreateSimpleData() const401 SimpleData* KmlFactory::CreateSimpleData() const {
402 return new SimpleData();
403 }
404
CreateSimpleField() const405 SimpleField* KmlFactory::CreateSimpleField() const {
406 return new SimpleField();
407 }
408
CreateSize() const409 Size* KmlFactory::CreateSize() const {
410 return new Size();
411 }
412
CreateSnippet() const413 Snippet* KmlFactory::CreateSnippet() const {
414 return new Snippet();
415 }
416
CreateStyle() const417 Style* KmlFactory::CreateStyle() const {
418 return new Style();
419 }
420
CreateStyleMap() const421 StyleMap* KmlFactory::CreateStyleMap() const {
422 return new StyleMap();
423 }
424
CreateTimeSpan() const425 TimeSpan* KmlFactory::CreateTimeSpan() const {
426 return new TimeSpan();
427 }
428
CreateTimeStamp() const429 TimeStamp* KmlFactory::CreateTimeStamp() const {
430 return new TimeStamp();
431 }
432
CreateViewVolume() const433 ViewVolume* KmlFactory::CreateViewVolume() const {
434 return new ViewVolume();
435 }
436
CreateXalAddressDetails() const437 XalAddressDetails* KmlFactory::CreateXalAddressDetails() const {
438 return new XalAddressDetails();
439 }
440
CreateXalAdministrativeArea() const441 XalAdministrativeArea* KmlFactory::CreateXalAdministrativeArea() const {
442 return new XalAdministrativeArea();
443 }
444
CreateXalCountry() const445 XalCountry* KmlFactory::CreateXalCountry() const {
446 return new XalCountry();
447 }
448
CreateXalLocality() const449 XalLocality* KmlFactory::CreateXalLocality() const {
450 return new XalLocality();
451 }
452
CreateXalPostalCode() const453 XalPostalCode* KmlFactory::CreateXalPostalCode() const {
454 return new XalPostalCode();
455 }
456
CreateXalSubAdministrativeArea() const457 XalSubAdministrativeArea* KmlFactory::CreateXalSubAdministrativeArea() const {
458 return new XalSubAdministrativeArea();
459 }
460
CreateXalThoroughfare() const461 XalThoroughfare* KmlFactory::CreateXalThoroughfare() const {
462 return new XalThoroughfare();
463 }
464
CreateGxAnimatedUpdate() const465 GxAnimatedUpdate* KmlFactory::CreateGxAnimatedUpdate() const {
466 return new GxAnimatedUpdate();
467 }
468
CreateGxFlyTo() const469 GxFlyTo* KmlFactory::CreateGxFlyTo() const {
470 return new GxFlyTo();
471 }
472
CreateGxLatLonQuad() const473 GxLatLonQuad* KmlFactory::CreateGxLatLonQuad() const {
474 return new GxLatLonQuad();
475 }
476
CreateGxMultiTrack() const477 GxMultiTrack* KmlFactory::CreateGxMultiTrack() const {
478 return new GxMultiTrack();
479 }
480
CreateGxPlaylist() const481 GxPlaylist* KmlFactory::CreateGxPlaylist() const {
482 return new GxPlaylist();
483 }
484
CreateGxSimpleArrayData() const485 GxSimpleArrayData* KmlFactory::CreateGxSimpleArrayData() const {
486 return new GxSimpleArrayData();
487 }
488
CreateGxSimpleArrayField() const489 GxSimpleArrayField* KmlFactory::CreateGxSimpleArrayField() const {
490 return new GxSimpleArrayField();
491 }
492
CreateGxSoundCue() const493 GxSoundCue* KmlFactory::CreateGxSoundCue() const {
494 return new GxSoundCue();
495 }
496
CreateGxTimeSpan() const497 GxTimeSpan* KmlFactory::CreateGxTimeSpan() const {
498 return new GxTimeSpan();
499 }
500
CreateGxTimeStamp() const501 GxTimeStamp* KmlFactory::CreateGxTimeStamp() const {
502 return new GxTimeStamp();
503 }
504
CreateGxTour() const505 GxTour* KmlFactory::CreateGxTour() const {
506 return new GxTour();
507 }
508
CreateGxTourControl() const509 GxTourControl* KmlFactory::CreateGxTourControl() const {
510 return new GxTourControl();
511 }
512
CreateGxTrack() const513 GxTrack* KmlFactory::CreateGxTrack() const {
514 return new GxTrack();
515 }
516
CreateGxWait() const517 GxWait* KmlFactory::CreateGxWait() const {
518 return new GxWait();
519 }
520
521 } // namespace kmldom
522