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 // This file declares the NetworkLink element.
27 
28 #ifndef KML_DOM_NETWORKLINK_H__
29 #define KML_DOM_NETWORKLINK_H__
30 
31 #include "kml/dom/feature.h"
32 #include "kml/dom/link.h"
33 #include "kml/dom/kml22.h"
34 #include "kml/dom/kml_ptr.h"
35 #include "kml/base/util.h"
36 
37 namespace kmldom {
38 
39 class Visitor;
40 class VisitorDriver;
41 
42 // <NetworkLink>
43 class NetworkLink : public Feature {
44  public:
45   virtual ~NetworkLink();
Type()46   virtual KmlDomType Type() const { return Type_NetworkLink; }
IsA(KmlDomType type)47   virtual bool IsA(KmlDomType type) const {
48     return type == Type_NetworkLink || Feature::IsA(type);
49   }
50 
51   // <refreshVisibility>
get_refreshvisibility()52   bool get_refreshvisibility() const { return refreshvisibility_; }
has_refreshvisibility()53   bool has_refreshvisibility() const { return has_refreshvisibility_; }
set_refreshvisibility(bool value)54   void set_refreshvisibility(bool value) {
55     refreshvisibility_ = value;
56     has_refreshvisibility_ = true;
57   }
clear_refreshvisibility()58   void clear_refreshvisibility() {
59     refreshvisibility_ = false;
60     has_refreshvisibility_ = false;
61   }
62 
63   // <flyToView>
get_flytoview()64   bool get_flytoview() const { return flytoview_; }
has_flytoview()65   bool has_flytoview() const { return has_flytoview_; }
set_flytoview(bool value)66   void set_flytoview(bool value) {
67     flytoview_ = value;
68     has_flytoview_ = true;
69   }
clear_flytoview()70   void clear_flytoview() {
71     flytoview_ = false;
72     has_flytoview_ = false;
73   }
74 
75   // <Link>
76   // <Url> is deprecated, no API access
get_link()77   const LinkPtr& get_link() const { return link_; }
has_link()78   bool has_link() const { return link_ != NULL; }
set_link(const LinkPtr & link)79   void set_link(const LinkPtr& link) {
80     SetComplexChild(link, &link_);
81   }
clear_link()82   void clear_link() {
83     set_link(NULL);
84   }
85 
86   // Visitor API methods, see visitor.h.
87   virtual void Accept(Visitor* visitor);
88   virtual void AcceptChildren(VisitorDriver* driver);
89 
90  private:
91   friend class KmlFactory;
92   NetworkLink();
93   friend class KmlHandler;
94   virtual void AddElement(const ElementPtr& element);
95   friend class Serializer;
96   virtual void Serialize(Serializer& serializer) const;
97   bool refreshvisibility_;
98   bool has_refreshvisibility_;
99   bool flytoview_;
100   bool has_flytoview_;
101   LinkPtr link_;
102   LIBKML_DISALLOW_EVIL_CONSTRUCTORS(NetworkLink);
103 };
104 
105 }  // namespace kmldom
106 
107 #endif  // KML_DOM_NETWORKLINK_H__
108