SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
SWGDeviceListItem.cpp
Go to the documentation of this file.
1 
14 #include "SWGDeviceListItem.h"
15 
16 #include "SWGHelpers.h"
17 
18 #include <QJsonDocument>
19 #include <QJsonArray>
20 #include <QObject>
21 #include <QDebug>
22 
23 namespace SWGSDRangel {
24 
26  init();
27  this->fromJson(*json);
28 }
29 
31  displayed_name = nullptr;
32  m_displayed_name_isSet = false;
33  hw_type = nullptr;
34  m_hw_type_isSet = false;
35  serial = nullptr;
36  m_serial_isSet = false;
37  sequence = 0;
38  m_sequence_isSet = false;
39  direction = 0;
40  m_direction_isSet = false;
45  device_set_index = 0;
47  index = 0;
48  m_index_isSet = false;
49 }
50 
52  this->cleanup();
53 }
54 
55 void
57  displayed_name = new QString("");
58  m_displayed_name_isSet = false;
59  hw_type = new QString("");
60  m_hw_type_isSet = false;
61  serial = new QString("");
62  m_serial_isSet = false;
63  sequence = 0;
64  m_sequence_isSet = false;
65  direction = 0;
66  m_direction_isSet = false;
71  device_set_index = 0;
73  index = 0;
74  m_index_isSet = false;
75 }
76 
77 void
79  if(displayed_name != nullptr) {
80  delete displayed_name;
81  }
82  if(hw_type != nullptr) {
83  delete hw_type;
84  }
85  if(serial != nullptr) {
86  delete serial;
87  }
88 
89 
90 
91 
92 
93 
94 }
95 
98  QByteArray array (json.toStdString().c_str());
99  QJsonDocument doc = QJsonDocument::fromJson(array);
100  QJsonObject jsonObject = doc.object();
101  this->fromJsonObject(jsonObject);
102  return this;
103 }
104 
105 void
107  ::SWGSDRangel::setValue(&displayed_name, pJson["displayedName"], "QString", "QString");
108 
109  ::SWGSDRangel::setValue(&hw_type, pJson["hwType"], "QString", "QString");
110 
111  ::SWGSDRangel::setValue(&serial, pJson["serial"], "QString", "QString");
112 
113  ::SWGSDRangel::setValue(&sequence, pJson["sequence"], "qint32", "");
114 
115  ::SWGSDRangel::setValue(&direction, pJson["direction"], "qint32", "");
116 
117  ::SWGSDRangel::setValue(&device_nb_streams, pJson["deviceNbStreams"], "qint32", "");
118 
119  ::SWGSDRangel::setValue(&device_stream_index, pJson["deviceStreamIndex"], "qint32", "");
120 
121  ::SWGSDRangel::setValue(&device_set_index, pJson["deviceSetIndex"], "qint32", "");
122 
123  ::SWGSDRangel::setValue(&index, pJson["index"], "qint32", "");
124 
125 }
126 
127 QString
129 {
130  QJsonObject* obj = this->asJsonObject();
131 
132  QJsonDocument doc(*obj);
133  QByteArray bytes = doc.toJson();
134  delete obj;
135  return QString(bytes);
136 }
137 
138 QJsonObject*
140  QJsonObject* obj = new QJsonObject();
141  if(displayed_name != nullptr && *displayed_name != QString("")){
142  toJsonValue(QString("displayedName"), displayed_name, obj, QString("QString"));
143  }
144  if(hw_type != nullptr && *hw_type != QString("")){
145  toJsonValue(QString("hwType"), hw_type, obj, QString("QString"));
146  }
147  if(serial != nullptr && *serial != QString("")){
148  toJsonValue(QString("serial"), serial, obj, QString("QString"));
149  }
150  if(m_sequence_isSet){
151  obj->insert("sequence", QJsonValue(sequence));
152  }
153  if(m_direction_isSet){
154  obj->insert("direction", QJsonValue(direction));
155  }
157  obj->insert("deviceNbStreams", QJsonValue(device_nb_streams));
158  }
160  obj->insert("deviceStreamIndex", QJsonValue(device_stream_index));
161  }
163  obj->insert("deviceSetIndex", QJsonValue(device_set_index));
164  }
165  if(m_index_isSet){
166  obj->insert("index", QJsonValue(index));
167  }
168 
169  return obj;
170 }
171 
172 QString*
174  return displayed_name;
175 }
176 void
178  this->displayed_name = displayed_name;
179  this->m_displayed_name_isSet = true;
180 }
181 
182 QString*
184  return hw_type;
185 }
186 void
188  this->hw_type = hw_type;
189  this->m_hw_type_isSet = true;
190 }
191 
192 QString*
194  return serial;
195 }
196 void
198  this->serial = serial;
199  this->m_serial_isSet = true;
200 }
201 
202 qint32
204  return sequence;
205 }
206 void
208  this->sequence = sequence;
209  this->m_sequence_isSet = true;
210 }
211 
212 qint32
214  return direction;
215 }
216 void
218  this->direction = direction;
219  this->m_direction_isSet = true;
220 }
221 
222 qint32
224  return device_nb_streams;
225 }
226 void
228  this->device_nb_streams = device_nb_streams;
229  this->m_device_nb_streams_isSet = true;
230 }
231 
232 qint32
234  return device_stream_index;
235 }
236 void
238  this->device_stream_index = device_stream_index;
239  this->m_device_stream_index_isSet = true;
240 }
241 
242 qint32
244  return device_set_index;
245 }
246 void
248  this->device_set_index = device_set_index;
249  this->m_device_set_index_isSet = true;
250 }
251 
252 qint32
254  return index;
255 }
256 void
258  this->index = index;
259  this->m_index_isSet = true;
260 }
261 
262 
263 bool
265  bool isObjectUpdated = false;
266  do{
267  if(displayed_name != nullptr && *displayed_name != QString("")){ isObjectUpdated = true; break;}
268  if(hw_type != nullptr && *hw_type != QString("")){ isObjectUpdated = true; break;}
269  if(serial != nullptr && *serial != QString("")){ isObjectUpdated = true; break;}
270  if(m_sequence_isSet){ isObjectUpdated = true; break;}
271  if(m_direction_isSet){ isObjectUpdated = true; break;}
272  if(m_device_nb_streams_isSet){ isObjectUpdated = true; break;}
273  if(m_device_stream_index_isSet){ isObjectUpdated = true; break;}
274  if(m_device_set_index_isSet){ isObjectUpdated = true; break;}
275  if(m_index_isSet){ isObjectUpdated = true; break;}
276  }while(false);
277  return isObjectUpdated;
278 }
279 }
280 
void setDeviceStreamIndex(qint32 device_stream_index)
void toJsonValue(QString name, void *value, QJsonObject *output, QString type)
Definition: SWGHelpers.cpp:383
virtual void fromJsonObject(QJsonObject &json) override
void setDeviceSetIndex(qint32 device_set_index)
void setDirection(qint32 direction)
void setDisplayedName(QString *displayed_name)
void setHwType(QString *hw_type)
void setDeviceNbStreams(qint32 device_nb_streams)
virtual SWGDeviceListItem * fromJson(QString &jsonString) override
void setValue(void *value, QJsonValue obj, QString type, QString complexType)
Definition: SWGHelpers.cpp:25
virtual QString asJson() override
virtual QJsonObject * asJsonObject() override