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.
SWGSamplingDevice.cpp
Go to the documentation of this file.
1 
14 #include "SWGSamplingDevice.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  index = 0;
32  m_index_isSet = false;
33  hw_type = nullptr;
34  m_hw_type_isSet = false;
35  direction = 0;
36  m_direction_isSet = false;
41  sequence = 0;
42  m_sequence_isSet = false;
43  serial = nullptr;
44  m_serial_isSet = false;
45  center_frequency = 0L;
47  bandwidth = 0;
48  m_bandwidth_isSet = false;
49  state = nullptr;
50  m_state_isSet = false;
51 }
52 
54  this->cleanup();
55 }
56 
57 void
59  index = 0;
60  m_index_isSet = false;
61  hw_type = new QString("");
62  m_hw_type_isSet = false;
63  direction = 0;
64  m_direction_isSet = false;
69  sequence = 0;
70  m_sequence_isSet = false;
71  serial = new QString("");
72  m_serial_isSet = false;
73  center_frequency = 0L;
75  bandwidth = 0;
76  m_bandwidth_isSet = false;
77  state = new QString("");
78  m_state_isSet = false;
79 }
80 
81 void
83 
84  if(hw_type != nullptr) {
85  delete hw_type;
86  }
87 
88 
89 
90 
91  if(serial != nullptr) {
92  delete serial;
93  }
94 
95 
96  if(state != nullptr) {
97  delete state;
98  }
99 }
100 
103  QByteArray array (json.toStdString().c_str());
104  QJsonDocument doc = QJsonDocument::fromJson(array);
105  QJsonObject jsonObject = doc.object();
106  this->fromJsonObject(jsonObject);
107  return this;
108 }
109 
110 void
112  ::SWGSDRangel::setValue(&index, pJson["index"], "qint32", "");
113 
114  ::SWGSDRangel::setValue(&hw_type, pJson["hwType"], "QString", "QString");
115 
116  ::SWGSDRangel::setValue(&direction, pJson["direction"], "qint32", "");
117 
118  ::SWGSDRangel::setValue(&device_nb_streams, pJson["deviceNbStreams"], "qint32", "");
119 
120  ::SWGSDRangel::setValue(&device_stream_index, pJson["deviceStreamIndex"], "qint32", "");
121 
122  ::SWGSDRangel::setValue(&sequence, pJson["sequence"], "qint32", "");
123 
124  ::SWGSDRangel::setValue(&serial, pJson["serial"], "QString", "QString");
125 
126  ::SWGSDRangel::setValue(&center_frequency, pJson["centerFrequency"], "qint64", "");
127 
128  ::SWGSDRangel::setValue(&bandwidth, pJson["bandwidth"], "qint32", "");
129 
130  ::SWGSDRangel::setValue(&state, pJson["state"], "QString", "QString");
131 
132 }
133 
134 QString
136 {
137  QJsonObject* obj = this->asJsonObject();
138 
139  QJsonDocument doc(*obj);
140  QByteArray bytes = doc.toJson();
141  delete obj;
142  return QString(bytes);
143 }
144 
145 QJsonObject*
147  QJsonObject* obj = new QJsonObject();
148  if(m_index_isSet){
149  obj->insert("index", QJsonValue(index));
150  }
151  if(hw_type != nullptr && *hw_type != QString("")){
152  toJsonValue(QString("hwType"), hw_type, obj, QString("QString"));
153  }
154  if(m_direction_isSet){
155  obj->insert("direction", QJsonValue(direction));
156  }
158  obj->insert("deviceNbStreams", QJsonValue(device_nb_streams));
159  }
161  obj->insert("deviceStreamIndex", QJsonValue(device_stream_index));
162  }
163  if(m_sequence_isSet){
164  obj->insert("sequence", QJsonValue(sequence));
165  }
166  if(serial != nullptr && *serial != QString("")){
167  toJsonValue(QString("serial"), serial, obj, QString("QString"));
168  }
170  obj->insert("centerFrequency", QJsonValue(center_frequency));
171  }
172  if(m_bandwidth_isSet){
173  obj->insert("bandwidth", QJsonValue(bandwidth));
174  }
175  if(state != nullptr && *state != QString("")){
176  toJsonValue(QString("state"), state, obj, QString("QString"));
177  }
178 
179  return obj;
180 }
181 
182 qint32
184  return index;
185 }
186 void
188  this->index = index;
189  this->m_index_isSet = true;
190 }
191 
192 QString*
194  return hw_type;
195 }
196 void
198  this->hw_type = hw_type;
199  this->m_hw_type_isSet = true;
200 }
201 
202 qint32
204  return direction;
205 }
206 void
208  this->direction = direction;
209  this->m_direction_isSet = true;
210 }
211 
212 qint32
214  return device_nb_streams;
215 }
216 void
218  this->device_nb_streams = device_nb_streams;
219  this->m_device_nb_streams_isSet = true;
220 }
221 
222 qint32
224  return device_stream_index;
225 }
226 void
228  this->device_stream_index = device_stream_index;
229  this->m_device_stream_index_isSet = true;
230 }
231 
232 qint32
234  return sequence;
235 }
236 void
238  this->sequence = sequence;
239  this->m_sequence_isSet = true;
240 }
241 
242 QString*
244  return serial;
245 }
246 void
248  this->serial = serial;
249  this->m_serial_isSet = true;
250 }
251 
252 qint64
254  return center_frequency;
255 }
256 void
258  this->center_frequency = center_frequency;
259  this->m_center_frequency_isSet = true;
260 }
261 
262 qint32
264  return bandwidth;
265 }
266 void
268  this->bandwidth = bandwidth;
269  this->m_bandwidth_isSet = true;
270 }
271 
272 QString*
274  return state;
275 }
276 void
278  this->state = state;
279  this->m_state_isSet = true;
280 }
281 
282 
283 bool
285  bool isObjectUpdated = false;
286  do{
287  if(m_index_isSet){ isObjectUpdated = true; break;}
288  if(hw_type != nullptr && *hw_type != QString("")){ isObjectUpdated = true; break;}
289  if(m_direction_isSet){ isObjectUpdated = true; break;}
290  if(m_device_nb_streams_isSet){ isObjectUpdated = true; break;}
291  if(m_device_stream_index_isSet){ isObjectUpdated = true; break;}
292  if(m_sequence_isSet){ isObjectUpdated = true; break;}
293  if(serial != nullptr && *serial != QString("")){ isObjectUpdated = true; break;}
294  if(m_center_frequency_isSet){ isObjectUpdated = true; break;}
295  if(m_bandwidth_isSet){ isObjectUpdated = true; break;}
296  if(state != nullptr && *state != QString("")){ isObjectUpdated = true; break;}
297  }while(false);
298  return isObjectUpdated;
299 }
300 }
301 
void setHwType(QString *hw_type)
void toJsonValue(QString name, void *value, QJsonObject *output, QString type)
Definition: SWGHelpers.cpp:383
void setCenterFrequency(qint64 center_frequency)
virtual SWGSamplingDevice * fromJson(QString &jsonString) override
virtual QJsonObject * asJsonObject() override
void setDirection(qint32 direction)
void setDeviceStreamIndex(qint32 device_stream_index)
virtual QString asJson() override
void setDeviceNbStreams(qint32 device_nb_streams)
void setValue(void *value, QJsonValue obj, QString type, QString complexType)
Definition: SWGHelpers.cpp:25
virtual void fromJsonObject(QJsonObject &json) override
void setBandwidth(qint32 bandwidth)