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 is the declaration of the abstract element Object.
27 
28 #ifndef KML_DOM_OBJECT_H__
29 #define KML_DOM_OBJECT_H__
30 
31 #include "kml/dom/element.h"
32 #include "kml/dom/kml22.h"
33 #include "kml/base/util.h"
34 
35 namespace kmlbase {
36 class Attributes;
37 }
38 
39 namespace kmldom {
40 
41 // OGC KML 2.2 Standard: 8.1 kml:AbstractObjectGroup
42 // OGC KML 2.2 XSD: <element name="AbstractObjectGroup"...
43 class Object : public Element {
44  public:
45   virtual ~Object();
Type()46   KmlDomType Type() const { return Type_Object; }
IsA(KmlDomType type)47   bool IsA(KmlDomType type) const {
48     return type == Type_Object;
49   }
50 
get_id()51   const string& get_id() const { return id_; }
has_id()52   bool has_id() const { return has_id_; }
set_id(const string & value)53   void set_id(const string& value) {
54     id_ = value;
55     has_id_ = true;
56   }
clear_id()57   void clear_id() {
58     id_.clear();
59     has_id_ = false;
60   }
61 
get_targetid()62   const string& get_targetid() const { return targetid_; }
has_targetid()63   bool has_targetid() const { return has_targetid_; }
set_targetid(const string & targetid)64   void set_targetid(const string& targetid) {
65     targetid_ = targetid;
66     has_targetid_ = true;
67   }
clear_targetid()68   void clear_targetid() {
69     targetid_.clear();
70     has_targetid_ = false;
71   }
72 
73  protected:
74   // Object is abstract, derived class access only.
75   Object();
76   virtual void AddElement(const ElementPtr& element);
77   virtual void ParseAttributes(kmlbase::Attributes* attributes);
78   virtual void SerializeAttributes(kmlbase::Attributes* attributes) const;
79 
80  private:
81   string id_;
82   bool has_id_;
83   string targetid_;
84   bool has_targetid_;
85   LIBKML_DISALLOW_EVIL_CONSTRUCTORS(Object);
86 };
87 
88 }  // namespace kmldom
89 
90 #endif  // KML_DOM_OBJECT_H__
91