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 #ifndef KML_DOM_STYLE_H__ 27 #define KML_DOM_STYLE_H__ 28 29 #include "kml/dom/balloonstyle.h" 30 #include "kml/dom/iconstyle.h" 31 #include "kml/dom/kml22.h" 32 #include "kml/dom/kml_ptr.h" 33 #include "kml/dom/labelstyle.h" 34 #include "kml/dom/liststyle.h" 35 #include "kml/dom/linestyle.h" 36 #include "kml/dom/polystyle.h" 37 #include "kml/dom/styleselector.h" 38 39 namespace kmldom { 40 41 class Serializer; 42 class Visitor; 43 class VisitorDriver; 44 45 class Style : public StyleSelector { 46 public: 47 virtual ~Style(); Type()48 virtual KmlDomType Type() const { return Type_Style; } IsA(KmlDomType type)49 virtual bool IsA(KmlDomType type) const { 50 return type == Type_Style || StyleSelector::IsA(type); 51 } 52 53 // <IconStyle> get_iconstyle()54 const IconStylePtr& get_iconstyle() const { return iconstyle_; } has_iconstyle()55 bool has_iconstyle() const { return iconstyle_ != NULL; } set_iconstyle(const IconStylePtr & iconstyle)56 void set_iconstyle(const IconStylePtr& iconstyle) { 57 SetComplexChild(iconstyle, &iconstyle_); 58 } clear_iconstyle()59 void clear_iconstyle() { 60 set_iconstyle(NULL); 61 } 62 63 // <LabelStyle> get_labelstyle()64 const LabelStylePtr& get_labelstyle() const { return labelstyle_; } has_labelstyle()65 bool has_labelstyle() const { return labelstyle_ != NULL; } set_labelstyle(const LabelStylePtr & labelstyle)66 void set_labelstyle(const LabelStylePtr& labelstyle) { 67 SetComplexChild(labelstyle, &labelstyle_); 68 } clear_labelstyle()69 void clear_labelstyle() { 70 set_labelstyle(NULL); 71 } 72 73 // <LineStyle> get_linestyle()74 const LineStylePtr& get_linestyle() const { return linestyle_; } has_linestyle()75 bool has_linestyle() const { return linestyle_ != NULL; } set_linestyle(const LineStylePtr & linestyle)76 void set_linestyle(const LineStylePtr& linestyle) { 77 SetComplexChild(linestyle, &linestyle_); 78 } clear_linestyle()79 void clear_linestyle() { 80 set_linestyle(NULL); 81 } 82 83 // <PolyStyle> get_polystyle()84 const PolyStylePtr& get_polystyle() const { return polystyle_; } has_polystyle()85 bool has_polystyle() const { return polystyle_ != NULL; } set_polystyle(const PolyStylePtr & polystyle)86 void set_polystyle(const PolyStylePtr& polystyle) { 87 SetComplexChild(polystyle, &polystyle_); 88 } clear_polystyle()89 void clear_polystyle() { 90 set_polystyle(NULL); 91 } 92 93 // <BalloonStyle> get_balloonstyle()94 const BalloonStylePtr& get_balloonstyle() const { return balloonstyle_; } has_balloonstyle()95 bool has_balloonstyle() const { return balloonstyle_ != NULL; } set_balloonstyle(const BalloonStylePtr & balloonstyle)96 void set_balloonstyle(const BalloonStylePtr& balloonstyle) { 97 SetComplexChild(balloonstyle, &balloonstyle_); 98 } clear_balloonstyle()99 void clear_balloonstyle() { 100 set_balloonstyle(NULL); 101 } 102 103 // <ListStyle> get_liststyle()104 const ListStylePtr& get_liststyle() const { return liststyle_; } has_liststyle()105 bool has_liststyle() const { return liststyle_ != NULL; } set_liststyle(const ListStylePtr & liststyle)106 void set_liststyle(const ListStylePtr& liststyle) { 107 SetComplexChild(liststyle, &liststyle_); 108 } clear_liststyle()109 void clear_liststyle() { 110 set_liststyle(NULL); 111 } 112 113 // Visitor API methods, see visitor.h. 114 virtual void Accept(Visitor* visitor); 115 virtual void AcceptChildren(VisitorDriver* driver); 116 117 private: 118 friend class KmlFactory; 119 Style (); 120 friend class KmlHandler; 121 virtual void AddElement(const ElementPtr& element); 122 friend class Serializer; 123 virtual void Serialize(Serializer& serializer) const; 124 IconStylePtr iconstyle_; 125 LabelStylePtr labelstyle_; 126 LineStylePtr linestyle_; 127 PolyStylePtr polystyle_; 128 BalloonStylePtr balloonstyle_; 129 ListStylePtr liststyle_; 130 LIBKML_DISALLOW_EVIL_CONSTRUCTORS(Style); 131 }; 132 133 } // end namespace kmldom 134 135 #endif // KML_DOM_STYLE_H__ 136