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 // This file contains the declaration of <gx:Tour>, <gx:Playlist>, 27 // <gx:AnimatedUpdate>, <gx:Wait>, <gx:FlyTo>, <gx:SoundCue>, and 28 // <gx:TourControl>. 29 30 #ifndef KML_GX_DOM_TOUR_H__ 31 #define KML_GX_DOM_TOUR_H__ 32 33 #include "kml/dom/element.h" 34 #include "kml/dom/feature.h" 35 #include "kml/dom/kml22.h" 36 #include "kml/dom/kml_ptr.h" 37 #include "kml/dom/networklinkcontrol.h" 38 39 namespace kmlbase { 40 class Attributes; 41 } 42 43 namespace kmldom { 44 45 class Serializer; 46 class Visitor; 47 class VisitorDriver; 48 49 // <gx:Tour> 50 class GxTour : public Feature { 51 public: 52 virtual ~GxTour(); ElementType()53 static KmlDomType ElementType() { 54 return Type_GxTour; 55 } Type()56 virtual KmlDomType Type() const { return ElementType(); } IsA(KmlDomType type)57 virtual bool IsA(KmlDomType type) const { 58 return type == ElementType() || Feature::IsA(type); 59 } 60 61 // <gx:Playlist> get_gx_playlist()62 const GxPlaylistPtr& get_gx_playlist() const { return gx_playlist_; } has_gx_playlist()63 bool has_gx_playlist() const { return gx_playlist_ != NULL; } set_gx_playlist(const GxPlaylistPtr & gx_playlist)64 void set_gx_playlist(const GxPlaylistPtr& gx_playlist) { 65 SetComplexChild(gx_playlist, &gx_playlist_); 66 } clear_gx_playlist()67 void clear_gx_playlist() { 68 set_gx_playlist(NULL); 69 } 70 71 // Visitor API methods, see visitor.h. 72 virtual void Accept(Visitor* visitor); 73 virtual void AcceptChildren(VisitorDriver* driver); 74 75 private: 76 friend class KmlFactory; 77 GxTour(); 78 friend class KmlHandler; 79 virtual void AddElement(const ElementPtr& element); 80 friend class Serializer; 81 virtual void Serialize(Serializer& serializer) const; 82 GxPlaylistPtr gx_playlist_; 83 LIBKML_DISALLOW_EVIL_CONSTRUCTORS(GxTour); 84 }; 85 86 // <gx:Playlist> 87 class GxPlaylist : public Object { 88 public: 89 virtual ~GxPlaylist(); ElementType()90 static KmlDomType ElementType() { 91 return Type_GxPlaylist; 92 } Type()93 virtual KmlDomType Type() const { return ElementType(); } IsA(KmlDomType type)94 virtual bool IsA(KmlDomType type) const { 95 return type == ElementType() || Object::IsA(type); 96 } 97 98 // GxTourPrimitive... 99 void add_gx_tourprimitive(const GxTourPrimitivePtr& tourprimitive); 100 size_t get_gx_tourprimitive_array_size() const; 101 const GxTourPrimitivePtr& get_gx_tourprimitive_array_at(size_t index) const; 102 103 // Visitor API methods, see visitor.h. 104 virtual void Accept(Visitor* visitor); 105 virtual void AcceptChildren(VisitorDriver* driver); 106 107 private: 108 friend class KmlFactory; 109 GxPlaylist(); 110 friend class KmlHandler; 111 virtual void AddElement(const ElementPtr& element); 112 friend class Serializer; 113 virtual void Serialize(Serializer& serializer) const; 114 std::vector<GxTourPrimitivePtr> gx_tourprimitive_array_; 115 LIBKML_DISALLOW_EVIL_CONSTRUCTORS(GxPlaylist); 116 }; 117 118 // GxTourPrimitive is an abstract base type. This corresponds to 119 // gx:AbstractGxTourPrimitiveType/Group in KML 2.2 gx. 120 class GxTourPrimitive : public Object { 121 public: ElementType()122 static KmlDomType ElementType() { 123 return static_cast<KmlDomType>(Type_GxTourPrimitive); 124 } Type()125 virtual KmlDomType Type() const { return ElementType(); } IsA(KmlDomType type)126 bool IsA(KmlDomType type) const { 127 return type == ElementType() || Object::IsA(type); 128 } 129 130 protected: GxTourPrimitive()131 GxTourPrimitive() {} 132 133 private: 134 LIBKML_DISALLOW_EVIL_CONSTRUCTORS(GxTourPrimitive); 135 }; 136 137 // Intermediate common class for GxTourPrimitive with gx_duration. 138 class GxTourPrimitiveCommon : public GxTourPrimitive { 139 public: 140 // <gx:duration> get_gx_duration()141 double get_gx_duration() const { 142 return gx_duration_; 143 } has_gx_duration()144 bool has_gx_duration() const { 145 return has_gx_duration_; 146 } set_gx_duration(double gx_duration)147 void set_gx_duration(double gx_duration) { 148 gx_duration_ = gx_duration; 149 has_gx_duration_ = true; 150 } clear_gx_duration()151 void clear_gx_duration() { 152 gx_duration_ = 0.0; 153 has_gx_duration_ = false; 154 } 155 156 protected: 157 // This is an internal abstract element and is inherited only and never 158 // instantiated directly. GxTourPrimitiveCommon()159 GxTourPrimitiveCommon() 160 : has_gx_duration_(false), gx_duration_(0.0) { 161 } 162 163 virtual void AddElement(const ElementPtr& element); 164 virtual void Serialize(Serializer& serializer) const; 165 166 private: 167 bool has_gx_duration_; 168 double gx_duration_; 169 LIBKML_DISALLOW_EVIL_CONSTRUCTORS(GxTourPrimitiveCommon); 170 }; 171 172 // <gx:AnimatedUpdate> 173 class GxAnimatedUpdate : public GxTourPrimitiveCommon { 174 public: 175 virtual ~GxAnimatedUpdate(); ElementType()176 static KmlDomType ElementType() { 177 return Type_GxAnimatedUpdate; 178 } Type()179 virtual KmlDomType Type() const { return ElementType(); } IsA(KmlDomType type)180 virtual bool IsA(KmlDomType type) const { 181 return type == ElementType() || GxTourPrimitive::IsA(type); 182 } 183 184 // <Update> get_update()185 const UpdatePtr& get_update() const { return update_; } has_update()186 bool has_update() const { return update_ != NULL; } set_update(const UpdatePtr & update)187 void set_update(const UpdatePtr& update) { 188 SetComplexChild(update, &update_); 189 } clear_update()190 void clear_update() { 191 set_update(NULL); 192 } 193 194 // Visitor API methods, see visitor.h. 195 virtual void Accept(Visitor* visitor); 196 virtual void AcceptChildren(VisitorDriver* driver); 197 198 private: 199 friend class KmlFactory; 200 GxAnimatedUpdate(); 201 friend class KmlHandler; 202 virtual void AddElement(const ElementPtr& element); 203 friend class Serializer; 204 virtual void Serialize(Serializer& serializer) const; 205 UpdatePtr update_; 206 LIBKML_DISALLOW_EVIL_CONSTRUCTORS(GxAnimatedUpdate); 207 }; 208 209 // <gx:FlyTo> 210 class GxFlyTo : public GxTourPrimitiveCommon { 211 public: 212 virtual ~GxFlyTo(); ElementType()213 static KmlDomType ElementType() { 214 return Type_GxFlyTo; 215 } Type()216 virtual KmlDomType Type() const { return ElementType(); } IsA(KmlDomType type)217 virtual bool IsA(KmlDomType type) const { 218 return type == ElementType() || GxTourPrimitive::IsA(type); 219 } 220 221 // <gx:flyToMode>. get_gx_flytomode()222 int get_gx_flytomode() const { return gx_flytomode_; } has_gx_flytomode()223 bool has_gx_flytomode() const { return has_gx_flytomode_; } set_gx_flytomode(int value)224 void set_gx_flytomode(int value) { 225 gx_flytomode_ = value; 226 has_gx_flytomode_ = true; 227 } clear_gx_flytomode()228 void clear_gx_flytomode() { 229 gx_flytomode_ = kmldom::GX_FLYTOMODE_BOUNCE; 230 has_gx_flytomode_ = false; 231 } 232 233 // AbstractView get_abstractview()234 const AbstractViewPtr& get_abstractview() const { return abstractview_; } has_abstractview()235 bool has_abstractview() const { return abstractview_ != NULL; } set_abstractview(const AbstractViewPtr & abstractview)236 void set_abstractview(const AbstractViewPtr& abstractview) { 237 SetComplexChild(abstractview, &abstractview_); 238 } clear_abstractview()239 void clear_abstractview() { 240 set_abstractview(NULL); 241 } 242 243 // Visitor API methods, see visitor.h. 244 virtual void Accept(Visitor* visitor); 245 virtual void AcceptChildren(VisitorDriver* driver); 246 247 private: 248 int gx_flytomode_; 249 bool has_gx_flytomode_; 250 friend class KmlFactory; 251 GxFlyTo(); 252 friend class KmlHandler; 253 virtual void AddElement(const ElementPtr& element); 254 friend class Serializer; 255 virtual void Serialize(Serializer& serializer) const; 256 AbstractViewPtr abstractview_; 257 LIBKML_DISALLOW_EVIL_CONSTRUCTORS(GxFlyTo); 258 }; 259 260 // <gx:Wait> 261 class GxWait : public GxTourPrimitiveCommon { 262 public: 263 virtual ~GxWait(); ElementType()264 static KmlDomType ElementType() { 265 return Type_GxWait; 266 } Type()267 virtual KmlDomType Type() const { return ElementType(); } IsA(KmlDomType type)268 virtual bool IsA(KmlDomType type) const { 269 return type == ElementType() || GxTourPrimitive::IsA(type); 270 } 271 272 // Visitor API methods, see visitor.h. 273 virtual void Accept(Visitor* visitor); 274 275 private: 276 friend class KmlFactory; 277 GxWait(); 278 friend class Serializer; 279 virtual void Serialize(Serializer& serializer) const; 280 LIBKML_DISALLOW_EVIL_CONSTRUCTORS(GxWait); 281 }; 282 283 // <gx:SoundCue> 284 class GxSoundCue : public GxTourPrimitive { 285 public: 286 virtual ~GxSoundCue(); ElementType()287 static KmlDomType ElementType() { 288 return Type_GxSoundCue; 289 } Type()290 virtual KmlDomType Type() const { return ElementType(); } IsA(KmlDomType type)291 virtual bool IsA(KmlDomType type) const { 292 return type == ElementType() || GxTourPrimitive::IsA(type); 293 } 294 295 // <href> get_href()296 const string& get_href() const { 297 return href_; 298 } has_href()299 bool has_href() const { 300 return has_href_; 301 } set_href(const string & href)302 void set_href(const string& href) { 303 href_ = href; 304 has_href_ = true; 305 } clear_href()306 void clear_href() { 307 href_.clear(); 308 has_href_ = false; 309 } 310 311 // Visitor API methods, see visitor.h. 312 virtual void Accept(Visitor* visitor); 313 314 private: 315 string href_; 316 bool has_href_; 317 friend class KmlFactory; 318 GxSoundCue(); 319 friend class KmlHandler; 320 virtual void AddElement(const ElementPtr& element); 321 friend class Serializer; 322 virtual void Serialize(Serializer& serializer) const; 323 LIBKML_DISALLOW_EVIL_CONSTRUCTORS(GxSoundCue); 324 }; 325 326 // <gx:TourControl> 327 class GxTourControl : public GxTourPrimitive { 328 public: 329 virtual ~GxTourControl(); ElementType()330 static KmlDomType ElementType() { 331 return Type_GxTourControl; 332 } Type()333 virtual KmlDomType Type() const { return ElementType(); } IsA(KmlDomType type)334 virtual bool IsA(KmlDomType type) const { 335 return type == ElementType() || GxTourPrimitive::IsA(type); 336 } 337 338 // <gx:playMode> get_gx_playmode()339 int get_gx_playmode() const { 340 return gx_playmode_; 341 } has_gx_playmode()342 bool has_gx_playmode() const { 343 return has_gx_playmode_; 344 } set_gx_playmode(int value)345 void set_gx_playmode(int value) { 346 gx_playmode_ = value; 347 has_gx_playmode_ = true; 348 } clear_gx_playmode()349 void clear_gx_playmode() { 350 gx_playmode_ = GX_PLAYMODE_PAUSE; 351 has_gx_playmode_ = false; 352 } 353 354 // Visitor API methods, see visitor.h. 355 virtual void Accept(Visitor* visitor); 356 357 private: 358 int gx_playmode_; 359 bool has_gx_playmode_; 360 friend class KmlFactory; 361 GxTourControl(); 362 friend class KmlHandler; 363 virtual void AddElement(const ElementPtr& element); 364 friend class Serializer; 365 virtual void Serialize(Serializer& serializer) const; 366 LIBKML_DISALLOW_EVIL_CONSTRUCTORS(GxTourControl); 367 }; 368 369 370 } // end namespace kmldom 371 372 #endif // KML_GX_DOM_TOUR_H__ 373