]>
Commit | Line | Data |
---|---|---|
09a36623 AS |
1 | <?php |
2 | /** | |
3 | * datatype.php | |
4 | * | |
5 | * Copyright 2018 Andy Street <andy@street.me.uk> | |
6 | * | |
7 | * This program is free software; you can redistribute it and/or modify | |
8 | * it under the terms of the GNU General Public License as published by | |
9 | * the Free Software Foundation; either version 2 of the License, or | |
10 | * (at your option) any later version. | |
11 | * | |
12 | * This program is distributed in the hope that it will be useful, | |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | * GNU General Public License for more details. | |
16 | * | |
17 | * You should have received a copy of the GNU General Public License | |
18 | * along with this program; if not, write to the Free Software | |
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | |
20 | * MA 02110-1301, USA. | |
21 | * | |
22 | * | |
23 | */ | |
24 | ||
25 | namespace libgpx; | |
26 | ||
27 | /** | |
28 | * A GPX data type. | |
29 | * | |
30 | * @author Andy Street <andy@street.me.uk> | |
31 | */ | |
32 | abstract class DataType | |
33 | { | |
34 | ||
35 | /** | |
36 | * A name. | |
37 | * | |
38 | * @var string | |
39 | */ | |
40 | protected $name; | |
41 | ||
42 | /** | |
43 | * A comment. | |
44 | * | |
45 | * Sent to GPS as comment. | |
46 | * | |
47 | * @var string | |
48 | */ | |
49 | protected $comment; | |
50 | ||
51 | /** | |
52 | * A text description. | |
53 | * | |
54 | * Holds additional information about the element intended for the user, | |
55 | * not the GPS. | |
56 | * | |
57 | * @var string | |
58 | */ | |
59 | protected $description; | |
60 | ||
61 | /** | |
62 | * Source of data. | |
63 | * | |
64 | * Included to give user some idea of reliability and accuracy of data. | |
65 | * E.g. "Garmin eTrex", "USGS quad Boston North". | |
66 | * | |
67 | * @var string | |
68 | */ | |
69 | protected $source; | |
70 | ||
71 | /** | |
72 | * A list of associated links. | |
73 | * | |
74 | * @var TypedDoublyLinkedList (Link) | |
75 | */ | |
76 | protected $links; | |
77 | ||
78 | /** | |
79 | * Type (classification). | |
80 | * | |
81 | * @var string | |
82 | */ | |
83 | protected $type; | |
84 | ||
85 | /** | |
86 | * A list of XML snippets describing unsupported data. | |
87 | * | |
88 | * @var TypedDoublyLinkedList (string) | |
89 | */ | |
90 | protected $extensions; | |
91 | ||
92 | /** | |
93 | * Fetch the name. | |
94 | * | |
95 | * @return string|null The name or null if not set. | |
96 | */ | |
97 | public function getName() | |
98 | { | |
99 | return $this->name; | |
100 | } | |
101 | ||
102 | /** | |
103 | * Set the name. | |
104 | * | |
105 | * @param string $name The name or null to delete. | |
106 | * @return void | |
107 | */ | |
108 | public function setName(string $name = null) | |
109 | { | |
110 | $this->name = $name; | |
111 | } | |
112 | ||
113 | /** | |
114 | * Fetch a comment. | |
115 | * | |
116 | * @return string The comment or null if not set. | |
117 | */ | |
118 | public function getComment() | |
119 | { | |
120 | return $this->comment; | |
121 | } | |
122 | ||
123 | /** | |
124 | * Set a comment. | |
125 | * | |
126 | * @param string $comment The comment or null to delete. | |
127 | * @return void | |
128 | */ | |
129 | public function setComment(string $comment = null) | |
130 | { | |
131 | $this->comment = $comment; | |
132 | } | |
133 | ||
134 | /** | |
135 | * Fetch the description. | |
136 | * | |
137 | * @return string The description or null if not set. | |
138 | */ | |
139 | public function getDescription() | |
140 | { | |
141 | return $this->description; | |
142 | } | |
143 | ||
144 | /** | |
145 | * Set the description. | |
146 | * | |
147 | * @param string $description The description or null to delete. | |
148 | * @return void | |
149 | */ | |
150 | public function setDescription(string $description = null) | |
151 | { | |
152 | $this->description = $description; | |
153 | } | |
154 | ||
155 | /** | |
156 | * Fetch the source of the data. | |
157 | * | |
158 | * @return string|null The source or null if not set. | |
159 | */ | |
160 | public function getSource() | |
161 | { | |
162 | return $this->source; | |
163 | } | |
164 | ||
165 | /** | |
166 | * Set the source of the data. | |
167 | * | |
168 | * @param string $source The source of the data or null to delete. | |
169 | * @return void | |
170 | */ | |
171 | public function setSource(string $source = null) | |
172 | { | |
173 | $this->source = $source; | |
174 | } | |
175 | ||
176 | /** | |
177 | * Fetch a list of associated links. | |
178 | * | |
179 | * @param boolean $create Create the list if it does not already exist. | |
180 | * @return TypedDoublyLinkedList|null A list of Link objects. | |
181 | */ | |
182 | public function getLinks(bool $create = true) | |
183 | { | |
184 | if ($create && $this->links === null) | |
185 | $this->links = new TypedDoublyLinkedList('libgpx\Link'); | |
186 | return $this->links; | |
187 | } | |
188 | ||
189 | /** | |
190 | * Fetch the type. | |
191 | * | |
192 | * @return string|null The type or null if not set. | |
193 | */ | |
194 | public function getType() | |
195 | { | |
196 | return $this->type; | |
197 | } | |
198 | ||
199 | /** | |
200 | * Set the type. | |
201 | * | |
202 | * @param string $type The type or null to delete. | |
203 | * @return void | |
204 | */ | |
205 | public function setType(string $type = null) | |
206 | { | |
207 | $this->type = $type; | |
208 | } | |
209 | ||
210 | /** | |
211 | * Fetch a list of XML strings that describe unsupported elements. | |
212 | * | |
213 | * @param boolean $create Create the list if it does not already exist. | |
214 | * @return TypedDoublyLinkedList|null A list of XML strings. | |
215 | */ | |
216 | public function getExtensions(bool $create = true) | |
217 | { | |
218 | if ($create && $this->extensions === null) | |
219 | $this->extensions = new TypedDoublyLinkedList('string'); | |
220 | return $this->extensions; | |
221 | } | |
222 | ||
223 | } |