Instrument Neutral Distributed Interface INDI  2.0.2
indiproperties.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 #include "indiproperties.h"
19 #include "indiproperties_p.h"
20 
21 namespace INDI
22 {
23 
25 { }
26 
28 { }
29 
31  : d_ptr(new PropertiesPrivate)
32 { }
33 
35 { }
36 
37 Properties::Properties(std::shared_ptr<PropertiesPrivate> dd)
38  : d_ptr(dd)
39 { }
40 
42 {
43  D_PTR(Properties);
44  d->properties.push_back(property);
45 }
46 
48 {
49  D_PTR(Properties);
50  d->properties.push_back(std::move(property));
51 }
52 
54 {
55  D_PTR(Properties);
56  d->properties.clear();
57 }
58 
60 {
61  D_PTR(const Properties);
62  return d->properties.size();
63 }
64 
66 {
67  D_PTR(Properties);
68  return d->properties.at(pos);
69 }
70 
72 {
73  D_PTR(const Properties);
74  return d->properties.at(pos);
75 }
76 
78 {
79  D_PTR(Properties);
80  return d->properties.at(pos);
81 }
82 
84 {
85  D_PTR(const Properties);
86  return d->properties.at(pos);
87 }
88 
90 {
91  D_PTR(Properties);
92  return d->properties.front();
93 }
94 
96 {
97  D_PTR(const Properties);
98  return d->properties.front();
99 }
100 
102 {
103  D_PTR(Properties);
104  return d->properties.back();
105 }
106 
108 {
109  D_PTR(const Properties);
110  return d->properties.back();
111 }
112 
114 {
115  D_PTR(Properties);
116  return d->properties.begin();
117 }
118 
120 {
121  D_PTR(Properties);
122  return d->properties.end();
123 }
124 
126 {
127  D_PTR(const Properties);
128  return d->properties.begin();
129 }
130 
132 {
133  D_PTR(const Properties);
134  return d->properties.end();
135 }
136 
138 {
139  D_PTR(Properties);
140  return d->properties.erase(pos);
141 }
142 
144 {
145  D_PTR(Properties);
146  return d->properties.erase(pos);
147 }
148 
150 {
151  D_PTR(Properties);
152  return d->properties.erase(first, last);
153 }
154 
156 {
157  D_PTR(Properties);
158  return d->properties.erase(first, last);
159 }
160 
161 #ifdef INDI_PROPERTIES_BACKWARD_COMPATIBILE
163 {
164  return *this;
165 }
166 
168 {
169  return *this;
170 }
171 
173 {
174  return this;
175 }
176 
178 {
179  return this;
180 }
181 
182 Properties::operator Properties *()
183 {
184  D_PTR(Properties);
185  return &d->self;
186 }
187 
188 Properties::operator const Properties *() const
189 {
190  D_PTR(const Properties);
191  return &d->self;
192 }
193 
194 Properties::operator std::vector<INDI::Property *> *()
195 {
196  D_PTR(Properties);
197  d->propertiesBC.resize(0);
198  d->propertiesBC.reserve(d->properties.size());
199  for (auto &it : d->properties)
200  d->propertiesBC.push_back(&it);
201 
202  return &d->propertiesBC;
203 }
204 
205 Properties::operator const std::vector<INDI::Property *> *() const
206 {
207  D_PTR(const Properties);
208  d->propertiesBC.resize(0);
209  d->propertiesBC.reserve(d->properties.size());
210  for (auto &it : d->properties)
211  d->propertiesBC.push_back(const_cast<INDI::Property *>(&it));
212 
213  return &d->propertiesBC;
214 }
215 #endif
216 }
Properties * operator->()
INDI::Properties operator*()
iterator erase(iterator pos)
std::deque< INDI::Property >::const_iterator const_iterator
reference operator[](size_type pos)
std::deque< INDI::Property >::size_type size_type
std::deque< INDI::Property >::const_reference const_reference
void push_back(const INDI::Property &property)
reference at(size_type pos)
std::deque< INDI::Property >::reference reference
std::deque< INDI::Property >::iterator iterator
size_type size() const
Provides generic container for INDI properties.
Definition: indiproperty.h:48
Namespace to encapsulate INDI client, drivers, and mediator classes.