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.
SWGFileInputSettings.cpp
Go to the documentation of this file.
1 
14 #include "SWGFileInputSettings.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  file_name = nullptr;
32  m_file_name_isSet = false;
35  loop = 0;
36  m_loop_isSet = false;
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  file_name = new QString("");
54  m_file_name_isSet = false;
57  loop = 0;
58  m_loop_isSet = false;
59  use_reverse_api = 0;
61  reverse_api_address = new QString("");
63  reverse_api_port = 0;
67 }
68 
69 void
71  if(file_name != nullptr) {
72  delete file_name;
73  }
74 
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(&file_name, pJson["fileName"], "QString", "QString");
96 
97  ::SWGSDRangel::setValue(&acceleration_factor, pJson["accelerationFactor"], "qint32", "");
98 
99  ::SWGSDRangel::setValue(&loop, pJson["loop"], "qint32", "");
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(file_name != nullptr && *file_name != QString("")){
126  toJsonValue(QString("fileName"), file_name, obj, QString("QString"));
127  }
129  obj->insert("accelerationFactor", QJsonValue(acceleration_factor));
130  }
131  if(m_loop_isSet){
132  obj->insert("loop", QJsonValue(loop));
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 QString*
152  return file_name;
153 }
154 void
156  this->file_name = file_name;
157  this->m_file_name_isSet = true;
158 }
159 
160 qint32
162  return acceleration_factor;
163 }
164 void
166  this->acceleration_factor = acceleration_factor;
167  this->m_acceleration_factor_isSet = true;
168 }
169 
170 qint32
172  return loop;
173 }
174 void
176  this->loop = loop;
177  this->m_loop_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(file_name != nullptr && *file_name != QString("")){ isObjectUpdated = true; break;}
226  if(m_acceleration_factor_isSet){ isObjectUpdated = true; break;}
227  if(m_loop_isSet){ 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 setReverseApiDeviceIndex(qint32 reverse_api_device_index)
void toJsonValue(QString name, void *value, QJsonObject *output, QString type)
Definition: SWGHelpers.cpp:383
virtual SWGFileInputSettings * fromJson(QString &jsonString) override
virtual void fromJsonObject(QJsonObject &json) override
void setValue(void *value, QJsonValue obj, QString type, QString complexType)
Definition: SWGHelpers.cpp:25
void setAccelerationFactor(qint32 acceleration_factor)
virtual QJsonObject * asJsonObject() override
void setReverseApiPort(qint32 reverse_api_port)
void setReverseApiAddress(QString *reverse_api_address)
void setUseReverseApi(qint32 use_reverse_api)