Instrument Neutral Distributed Interface INDI  1.9.2
indipropertybasic.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2021 by Pawel Soja <kernel32.pl@gmail.com>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Lesser General Public
6  License as published by the Free Software Foundation; either
7  version 2.1 of the License, or (at your option) any later version.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Lesser General Public License for more details.
13 
14  You should have received a copy of the GNU Lesser General Public
15  License along with this library; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18 
19 #include "indipropertybasic.h"
20 #include "indipropertybasic_p.h"
21 
22 namespace INDI
23 {
24 
25 template <typename T>
27  : PropertyPrivate(&property)
28  , widgets(count)
29 {
30  property.setWidgets(widgets.data(), widgets.size());
31 }
32 
33 template <typename T>
35 { }
36 
37 template <typename T>
39 { }
40 
41 template <typename T>
43  : Property(dd)
44 { }
45 
46 template <typename T>
47 void PropertyBasic<T>::setName(const char *name)
48 {
49  D_PTR(PropertyBasic);
50  d->property.setName(name);
51 }
52 
53 template <typename T>
54 void PropertyBasic<T>::setName(const std::string &name)
55 {
56  D_PTR(PropertyBasic);
57  d->property.setName(name);
58 }
59 
60 template <typename T>
61 void PropertyBasic<T>::setLabel(const char *label)
62 {
63  D_PTR(PropertyBasic);
64  d->property.setLabel(label);
65 }
66 
67 template <typename T>
68 void PropertyBasic<T>::setLabel(const std::string &label)
69 {
70  D_PTR(PropertyBasic);
71  d->property.setLabel(label);
72 }
73 
74 template <typename T>
75 void PropertyBasic<T>::setGroupName(const char *name)
76 {
77  D_PTR(PropertyBasic);
78  d->property.setGroupName(name);
79 }
80 
81 template <typename T>
82 void PropertyBasic<T>::setGroupName(const std::string &name)
83 {
84  D_PTR(PropertyBasic);
85  d->property.setGroupName(name);
86 }
87 
88 template <typename T>
90 {
91  D_PTR(PropertyBasic);
92  d->property.setPermission(permission);
93 }
94 
95 template <typename T>
96 void PropertyBasic<T>::setTimeout(double timeout)
97 {
98  D_PTR(PropertyBasic);
99  d->property.setTimeout(timeout);
100 }
101 
102 template <typename T>
104 {
105  D_PTR(PropertyBasic);
106  d->property.setState(state);
107 }
108 
109 template <typename T>
111 {
112  D_PTR(PropertyBasic);
113  d->property.setTimestamp(timestamp);
114 }
115 
116 template <typename T>
118 {
119  D_PTR(PropertyBasic);
120  d->property.setTimestamp(timestamp);
121 }
122 
123 template <typename T>
124 const char *PropertyBasic<T>::getName() const
125 {
126  D_PTR(const PropertyBasic);
127  return d->property.getName();
128 }
129 
130 template <typename T>
131 const char *PropertyBasic<T>::getLabel() const
132 {
133  D_PTR(const PropertyBasic);
134  return d->property.getLabel();
135 }
136 
137 template <typename T>
139 {
140  D_PTR(const PropertyBasic);
141  return d->property.getGroupName();
142 }
143 
144 template <typename T>
146 {
147  D_PTR(const PropertyBasic);
148  return d->property.getPermission();
149 }
150 
151 template <typename T>
153 {
154  D_PTR(const PropertyBasic);
155  return d->property.getPermissionAsString();
156 }
157 
158 template <typename T>
160 {
161  D_PTR(const PropertyBasic);
162  return d->property.getTimeout();
163 }
164 
165 template <typename T>
167 {
168  D_PTR(const PropertyBasic);
169  return d->property.getState();
170 }
171 
172 template <typename T>
174 {
175  D_PTR(const PropertyBasic);
176  return d->property.getStateAsString();
177 }
178 
179 template <typename T>
181 {
182  D_PTR(const PropertyBasic);
183  return d->property.getTimestamp();
184 }
185 
186 template <typename T>
188 {
189  D_PTR(const PropertyBasic);
190  return d->property.isEmpty();
191 }
192 
193 template <typename T>
194 bool PropertyBasic<T>::isNameMatch(const char *otherName) const
195 {
196  D_PTR(const PropertyBasic);
197  return d->property.isNameMatch(otherName);
198 }
199 
200 template <typename T>
201 bool PropertyBasic<T>::isNameMatch(const std::string &otherName) const
202 {
203  D_PTR(const PropertyBasic);
204  return d->property.isNameMatch(otherName);
205 }
206 
207 template <typename T>
208 bool PropertyBasic<T>::isLabelMatch(const char *otherLabel) const
209 {
210  D_PTR(const PropertyBasic);
211  return d->property.isLabelMatch(otherLabel);
212 }
213 
214 template <typename T>
215 bool PropertyBasic<T>::isLabelMatch(const std::string &otherLabel) const
216 {
217  D_PTR(const PropertyBasic);
218  return d->property.isLabelMatch(otherLabel);
219 }
220 
221 template <typename T>
222 void PropertyBasic<T>::save(FILE *f) const
223 {
224  D_PTR(const PropertyBasic);
225  d->property.save(f);
226 }
227 
228 template <typename T>
229 void PropertyBasic<T>::vapply(const char *format, va_list args) const
230 {
231  D_PTR(const PropertyBasic);
232  d->property.vapply(format, args);
233 }
234 
235 template <typename T>
236 void PropertyBasic<T>::vdefine(const char *format, va_list args) const
237 {
238  D_PTR(const PropertyBasic);
239  d->property.vdefine(format, args);
240 }
241 
242 template <typename T>
243 void PropertyBasic<T>::apply(const char *format, ...) const
244 {
245  D_PTR(const PropertyBasic);
246  va_list ap;
247  va_start(ap, format);
248  d->property.vapply(format, ap);
249  va_end(ap);
250 }
251 
252 template <typename T>
253 void PropertyBasic<T>::define(const char *format, ...) const
254 {
255  D_PTR(const PropertyBasic);
256  va_list ap;
257  va_start(ap, format);
258  d->property.vdefine(format, ap);
259  va_end(ap);
260 }
261 
262 template <typename T>
264 {
265  D_PTR(const PropertyBasic);
266  d->property.apply();
267 }
268 
269 template <typename T>
271 {
272  D_PTR(const PropertyBasic);
273  d->property.define();
274 }
275 
276 template <typename T>
278 {
279  D_PTR(const PropertyBasic);
280  return d->property.findWidgetByName(name);
281 }
282 
283 template <typename T>
284 int PropertyBasic<T>::findWidgetIndexByName(const char *name) const
285 {
286  auto it = findWidgetByName(name);
287  return it == nullptr ? -1 : it - begin();
288 }
289 
290 template <typename T>
292 {
293  D_PTR(const PropertyBasic);
294  return d->property.count();
295 }
296 
297 template <typename T>
298 void PropertyBasic<T>::resize(size_t size)
299 {
300  D_PTR(PropertyBasic);
301  d->widgets.resize(size);
302  d->property.setWidgets(d->widgets.data(), d->widgets.size());
303 
304 }
305 
306 template <typename T>
307 void PropertyBasic<T>::reserve(size_t size)
308 {
309  D_PTR(PropertyBasic);
310  d->widgets.reserve(size);
311  d->property.setWidgets(d->widgets.data(), d->widgets.size());
312 }
313 
314 template <typename T>
316 {
317  D_PTR(PropertyBasic);
318  d->widgets.shrink_to_fit();
319  d->property.setWidgets(d->widgets.data(), d->widgets.size());
320 }
321 
322 template <typename T>
324 {
325  D_PTR(PropertyBasic);
326  item.setParent(&d->property);
327  d->widgets.push_back(std::move(item));
328  d->property.setWidgets(d->widgets.data(), d->widgets.size());
329 }
330 
331 template <typename T>
333 {
334  push(std::move(WidgetView<T>(item)));
335 }
336 
337 template <typename T>
338 const WidgetView<T> *PropertyBasic<T>::at(size_t index) const
339 {
340  D_PTR(const PropertyBasic);
341  return d->property.at(index);
342 }
343 
344 template <typename T>
346 {
347  D_PTR(const PropertyBasic);
348  return *d->property.at(index);
349 }
350 
351 template <typename T>
353 {
354  D_PTR(PropertyBasic);
355  return d->property.begin();
356 }
357 
358 template <typename T>
360 {
361  D_PTR(PropertyBasic);
362  return d->property.end();
363 }
364 
365 template <typename T>
367 {
368  D_PTR(const PropertyBasic);
369  return d->property.begin();
370 }
371 
372 template <typename T>
373 const WidgetView<T> *PropertyBasic<T>::end() const
374 {
375  D_PTR(const PropertyBasic);
376  return d->property.end();
377 }
378 
379 template <typename T>
381 {
382  D_PTR(PropertyBasic);
383  return &d->property;
384 }
385 
391 
392 template class PropertyBasic<IText>;
393 template class PropertyBasic<INumber>;
394 template class PropertyBasic<ISwitch>;
395 template class PropertyBasic<ILight>;
396 template class PropertyBasic<IBLOB>;
397 
398 }
IPState
IPState
Property state.
Definition: indiapi.h:158
timestamp
const char * timestamp()
Create an ISO 8601 formatted time stamp. The format is YYYY-MM-DDTHH:MM:SS.
Definition: indicom.c:334
indipropertybasic.h
INDI::Property
Provides generic container for INDI properties.
Definition: indiproperty.h:43
INDI::PropertyBasicPrivateTemplate
Definition: indipropertybasic.h:34
begin
JsonIterator begin(JsonValue o)
Definition: gason.h:104
INDI::WidgetView
Definition: indipropertyview.h:38
end
JsonIterator end(JsonValue)
Definition: gason.h:108
INDI::PropertyPrivate
Definition: indiproperty_p.h:52
indipropertybasic_p.h
IPerm
IPerm
Permission hint, with respect to client.
Definition: indiapi.h:181
INDI::PropertyView< T >
INDI
Namespace to encapsulate INDI client, drivers, and mediator classes.
Definition: AlignmentSubsystemForClients.cpp:11
INDI::operator&
Logger::loggerConf operator&(Logger::loggerConf __a, Logger::loggerConf __b)
Definition: indilogger.h:285
INDI::PropertyBasic
Definition: indipropertybasic.h:37
INDI::PropertyBasicPrivateTemplate::PropertyBasicPrivateTemplate
PropertyBasicPrivateTemplate(size_t count)
Definition: indipropertybasic.cpp:26