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.
SWGLocalInputSettings.cpp
Go to the documentation of this file.
1 
14 #include "SWGLocalInputSettings.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  dc_block = 0;
32  m_dc_block_isSet = false;
33  iq_correction = 0;
34  m_iq_correction_isSet = false;
35  file_record_name = nullptr;
37  use_reverse_api = 0;
39  reverse_api_address = nullptr;
41  reverse_api_port = 0;
45 }
46 
48  this->cleanup();
49 }
50 
51 void
53  dc_block = 0;
54  m_dc_block_isSet = false;
55  iq_correction = 0;
56  m_iq_correction_isSet = false;
57  file_record_name = new QString("");
59  use_reverse_api = 0;
61  reverse_api_address = new QString("");
63  reverse_api_port = 0;
67 }
68 
69 void
71 
72 
73  if(file_record_name != nullptr) {
74  delete file_record_name;
75  }
76 
77  if(reverse_api_address != nullptr) {
78  delete reverse_api_address;
79  }
80 
81 
82 }
83 
86  QByteArray array (json.toStdString().c_str());
87  QJsonDocument doc = QJsonDocument::fromJson(array);
88  QJsonObject jsonObject = doc.object();
89  this->fromJsonObject(jsonObject);
90  return this;
91 }
92 
93 void
95  ::SWGSDRangel::setValue(&dc_block, pJson["dcBlock"], "qint32", "");
96 
97  ::SWGSDRangel::setValue(&iq_correction, pJson["iqCorrection"], "qint32", "");
98 
99  ::SWGSDRangel::setValue(&file_record_name, pJson["fileRecordName"], "QString", "QString");
100 
101  ::SWGSDRangel::setValue(&use_reverse_api, pJson["useReverseAPI"], "qint32", "");
102 
103  ::SWGSDRangel::setValue(&reverse_api_address, pJson["reverseAPIAddress"], "QString", "QString");
104 
105  ::SWGSDRangel::setValue(&reverse_api_port, pJson["reverseAPIPort"], "qint32", "");
106 
107  ::SWGSDRangel::setValue(&reverse_api_device_index, pJson["reverseAPIDeviceIndex"], "qint32", "");
108 
109 }
110 
111 QString
113 {
114  QJsonObject* obj = this->asJsonObject();
115 
116  QJsonDocument doc(*obj);
117  QByteArray bytes = doc.toJson();
118  delete obj;
119  return QString(bytes);
120 }
121 
122 QJsonObject*
124  QJsonObject* obj = new QJsonObject();
125  if(m_dc_block_isSet){
126  obj->insert("dcBlock", QJsonValue(dc_block));
127  }
129  obj->insert("iqCorrection", QJsonValue(iq_correction));
130  }
131  if(file_record_name != nullptr && *file_record_name != QString("")){
132  toJsonValue(QString("fileRecordName"), file_record_name, obj, QString("QString"));
133  }
135  obj->insert("useReverseAPI", QJsonValue(use_reverse_api));
136  }
137  if(reverse_api_address != nullptr && *reverse_api_address != QString("")){
138  toJsonValue(QString("reverseAPIAddress"), reverse_api_address, obj, QString("QString"));
139  }
141  obj->insert("reverseAPIPort", QJsonValue(reverse_api_port));
142  }
144  obj->insert("reverseAPIDeviceIndex", QJsonValue(reverse_api_device_index));
145  }
146 
147  return obj;
148 }
149 
150 qint32
152  return dc_block;
153 }
154 void
156  this->dc_block = dc_block;
157  this->m_dc_block_isSet = true;
158 }
159 
160 qint32
162  return iq_correction;
163 }
164 void
166  this->iq_correction = iq_correction;
167  this->m_iq_correction_isSet = true;
168 }
169 
170 QString*
172  return file_record_name;
173 }
174 void
176  this->file_record_name = file_record_name;
177  this->m_file_record_name_isSet = true;
178 }
179 
180 qint32
182  return use_reverse_api;
183 }
184 void
186  this->use_reverse_api = use_reverse_api;
187  this->m_use_reverse_api_isSet = true;
188 }
189 
190 QString*
192  return reverse_api_address;
193 }
194 void
196  this->reverse_api_address = reverse_api_address;
197  this->m_reverse_api_address_isSet = true;
198 }
199 
200 qint32
202  return reverse_api_port;
203 }
204 void
206  this->reverse_api_port = reverse_api_port;
207  this->m_reverse_api_port_isSet = true;
208 }
209 
210 qint32
213 }
214 void
216  this->reverse_api_device_index = reverse_api_device_index;
218 }
219 
220 
221 bool
223  bool isObjectUpdated = false;
224  do{
225  if(m_dc_block_isSet){ isObjectUpdated = true; break;}
226  if(m_iq_correction_isSet){ isObjectUpdated = true; break;}
227  if(file_record_name != nullptr && *file_record_name != QString("")){ isObjectUpdated = true; break;}
228  if(m_use_reverse_api_isSet){ isObjectUpdated = true; break;}
229  if(reverse_api_address != nullptr && *reverse_api_address != QString("")){ isObjectUpdated = true; break;}
230  if(m_reverse_api_port_isSet){ isObjectUpdated = true; break;}
231  if(m_reverse_api_device_index_isSet){ isObjectUpdated = true; break;}
232  }while(false);
233  return isObjectUpdated;
234 }
235 }
236 
void toJsonValue(QString name, void *value, QJsonObject *output, QString type)
Definition: SWGHelpers.cpp:383
void setReverseApiDeviceIndex(qint32 reverse_api_device_index)
virtual void fromJsonObject(QJsonObject &json) override
void setReverseApiAddress(QString *reverse_api_address)
void setIqCorrection(qint32 iq_correction)
void setUseReverseApi(qint32 use_reverse_api)
void setReverseApiPort(qint32 reverse_api_port)
void setValue(void *value, QJsonValue obj, QString type, QString complexType)
Definition: SWGHelpers.cpp:25
void setFileRecordName(QString *file_record_name)
virtual QJsonObject * asJsonObject() override
virtual SWGLocalInputSettings * fromJson(QString &jsonString) override