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.
SWGRemoteInputSettings.cpp
Go to the documentation of this file.
1 
14 #include "SWGRemoteInputSettings.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  api_address = nullptr;
32  m_api_address_isSet = false;
33  api_port = 0;
34  m_api_port_isSet = false;
35  data_address = nullptr;
36  m_data_address_isSet = false;
37  data_port = 0;
38  m_data_port_isSet = false;
39  dc_block = 0;
40  m_dc_block_isSet = false;
41  iq_correction = 0;
42  m_iq_correction_isSet = false;
43  file_record_name = nullptr;
45  use_reverse_api = 0;
47  reverse_api_address = nullptr;
49  reverse_api_port = 0;
53 }
54 
56  this->cleanup();
57 }
58 
59 void
61  api_address = new QString("");
62  m_api_address_isSet = false;
63  api_port = 0;
64  m_api_port_isSet = false;
65  data_address = new QString("");
66  m_data_address_isSet = false;
67  data_port = 0;
68  m_data_port_isSet = false;
69  dc_block = 0;
70  m_dc_block_isSet = false;
71  iq_correction = 0;
72  m_iq_correction_isSet = false;
73  file_record_name = new QString("");
75  use_reverse_api = 0;
77  reverse_api_address = new QString("");
79  reverse_api_port = 0;
83 }
84 
85 void
87  if(api_address != nullptr) {
88  delete api_address;
89  }
90 
91  if(data_address != nullptr) {
92  delete data_address;
93  }
94 
95 
96 
97  if(file_record_name != nullptr) {
98  delete file_record_name;
99  }
100 
101  if(reverse_api_address != nullptr) {
102  delete reverse_api_address;
103  }
104 
105 
106 }
107 
110  QByteArray array (json.toStdString().c_str());
111  QJsonDocument doc = QJsonDocument::fromJson(array);
112  QJsonObject jsonObject = doc.object();
113  this->fromJsonObject(jsonObject);
114  return this;
115 }
116 
117 void
119  ::SWGSDRangel::setValue(&api_address, pJson["apiAddress"], "QString", "QString");
120 
121  ::SWGSDRangel::setValue(&api_port, pJson["apiPort"], "qint32", "");
122 
123  ::SWGSDRangel::setValue(&data_address, pJson["dataAddress"], "QString", "QString");
124 
125  ::SWGSDRangel::setValue(&data_port, pJson["dataPort"], "qint32", "");
126 
127  ::SWGSDRangel::setValue(&dc_block, pJson["dcBlock"], "qint32", "");
128 
129  ::SWGSDRangel::setValue(&iq_correction, pJson["iqCorrection"], "qint32", "");
130 
131  ::SWGSDRangel::setValue(&file_record_name, pJson["fileRecordName"], "QString", "QString");
132 
133  ::SWGSDRangel::setValue(&use_reverse_api, pJson["useReverseAPI"], "qint32", "");
134 
135  ::SWGSDRangel::setValue(&reverse_api_address, pJson["reverseAPIAddress"], "QString", "QString");
136 
137  ::SWGSDRangel::setValue(&reverse_api_port, pJson["reverseAPIPort"], "qint32", "");
138 
139  ::SWGSDRangel::setValue(&reverse_api_device_index, pJson["reverseAPIDeviceIndex"], "qint32", "");
140 
141 }
142 
143 QString
145 {
146  QJsonObject* obj = this->asJsonObject();
147 
148  QJsonDocument doc(*obj);
149  QByteArray bytes = doc.toJson();
150  delete obj;
151  return QString(bytes);
152 }
153 
154 QJsonObject*
156  QJsonObject* obj = new QJsonObject();
157  if(api_address != nullptr && *api_address != QString("")){
158  toJsonValue(QString("apiAddress"), api_address, obj, QString("QString"));
159  }
160  if(m_api_port_isSet){
161  obj->insert("apiPort", QJsonValue(api_port));
162  }
163  if(data_address != nullptr && *data_address != QString("")){
164  toJsonValue(QString("dataAddress"), data_address, obj, QString("QString"));
165  }
166  if(m_data_port_isSet){
167  obj->insert("dataPort", QJsonValue(data_port));
168  }
169  if(m_dc_block_isSet){
170  obj->insert("dcBlock", QJsonValue(dc_block));
171  }
173  obj->insert("iqCorrection", QJsonValue(iq_correction));
174  }
175  if(file_record_name != nullptr && *file_record_name != QString("")){
176  toJsonValue(QString("fileRecordName"), file_record_name, obj, QString("QString"));
177  }
179  obj->insert("useReverseAPI", QJsonValue(use_reverse_api));
180  }
181  if(reverse_api_address != nullptr && *reverse_api_address != QString("")){
182  toJsonValue(QString("reverseAPIAddress"), reverse_api_address, obj, QString("QString"));
183  }
185  obj->insert("reverseAPIPort", QJsonValue(reverse_api_port));
186  }
188  obj->insert("reverseAPIDeviceIndex", QJsonValue(reverse_api_device_index));
189  }
190 
191  return obj;
192 }
193 
194 QString*
196  return api_address;
197 }
198 void
200  this->api_address = api_address;
201  this->m_api_address_isSet = true;
202 }
203 
204 qint32
206  return api_port;
207 }
208 void
210  this->api_port = api_port;
211  this->m_api_port_isSet = true;
212 }
213 
214 QString*
216  return data_address;
217 }
218 void
220  this->data_address = data_address;
221  this->m_data_address_isSet = true;
222 }
223 
224 qint32
226  return data_port;
227 }
228 void
230  this->data_port = data_port;
231  this->m_data_port_isSet = true;
232 }
233 
234 qint32
236  return dc_block;
237 }
238 void
240  this->dc_block = dc_block;
241  this->m_dc_block_isSet = true;
242 }
243 
244 qint32
246  return iq_correction;
247 }
248 void
250  this->iq_correction = iq_correction;
251  this->m_iq_correction_isSet = true;
252 }
253 
254 QString*
256  return file_record_name;
257 }
258 void
260  this->file_record_name = file_record_name;
261  this->m_file_record_name_isSet = true;
262 }
263 
264 qint32
266  return use_reverse_api;
267 }
268 void
270  this->use_reverse_api = use_reverse_api;
271  this->m_use_reverse_api_isSet = true;
272 }
273 
274 QString*
276  return reverse_api_address;
277 }
278 void
280  this->reverse_api_address = reverse_api_address;
281  this->m_reverse_api_address_isSet = true;
282 }
283 
284 qint32
286  return reverse_api_port;
287 }
288 void
290  this->reverse_api_port = reverse_api_port;
291  this->m_reverse_api_port_isSet = true;
292 }
293 
294 qint32
297 }
298 void
300  this->reverse_api_device_index = reverse_api_device_index;
302 }
303 
304 
305 bool
307  bool isObjectUpdated = false;
308  do{
309  if(api_address != nullptr && *api_address != QString("")){ isObjectUpdated = true; break;}
310  if(m_api_port_isSet){ isObjectUpdated = true; break;}
311  if(data_address != nullptr && *data_address != QString("")){ isObjectUpdated = true; break;}
312  if(m_data_port_isSet){ isObjectUpdated = true; break;}
313  if(m_dc_block_isSet){ isObjectUpdated = true; break;}
314  if(m_iq_correction_isSet){ isObjectUpdated = true; break;}
315  if(file_record_name != nullptr && *file_record_name != QString("")){ isObjectUpdated = true; break;}
316  if(m_use_reverse_api_isSet){ isObjectUpdated = true; break;}
317  if(reverse_api_address != nullptr && *reverse_api_address != QString("")){ isObjectUpdated = true; break;}
318  if(m_reverse_api_port_isSet){ isObjectUpdated = true; break;}
319  if(m_reverse_api_device_index_isSet){ isObjectUpdated = true; break;}
320  }while(false);
321  return isObjectUpdated;
322 }
323 }
324 
void setDataAddress(QString *data_address)
void toJsonValue(QString name, void *value, QJsonObject *output, QString type)
Definition: SWGHelpers.cpp:383
void setReverseApiPort(qint32 reverse_api_port)
void setReverseApiDeviceIndex(qint32 reverse_api_device_index)
virtual void fromJsonObject(QJsonObject &json) override
void setUseReverseApi(qint32 use_reverse_api)
virtual QJsonObject * asJsonObject() override
void setValue(void *value, QJsonValue obj, QString type, QString complexType)
Definition: SWGHelpers.cpp:25
virtual SWGRemoteInputSettings * fromJson(QString &jsonString) override
void setFileRecordName(QString *file_record_name)
void setReverseApiAddress(QString *reverse_api_address)