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.
SWGTestMISettings.cpp
Go to the documentation of this file.
1 
14 #include "SWGTestMISettings.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_record_name = nullptr;
33  use_reverse_api = 0;
35  reverse_api_address = nullptr;
37  reverse_api_port = 0;
41  streams = nullptr;
42  m_streams_isSet = false;
43 }
44 
46  this->cleanup();
47 }
48 
49 void
51  file_record_name = new QString("");
53  use_reverse_api = 0;
55  reverse_api_address = new QString("");
57  reverse_api_port = 0;
61  streams = new QList<SWGTestMiStreamSettings*>();
62  m_streams_isSet = false;
63 }
64 
65 void
67  if(file_record_name != nullptr) {
68  delete file_record_name;
69  }
70 
71  if(reverse_api_address != nullptr) {
72  delete reverse_api_address;
73  }
74 
75 
76  if(streams != nullptr) {
77  auto arr = streams;
78  for(auto o: *arr) {
79  delete o;
80  }
81  delete streams;
82  }
83 }
84 
87  QByteArray array (json.toStdString().c_str());
88  QJsonDocument doc = QJsonDocument::fromJson(array);
89  QJsonObject jsonObject = doc.object();
90  this->fromJsonObject(jsonObject);
91  return this;
92 }
93 
94 void
95 SWGTestMISettings::fromJsonObject(QJsonObject &pJson) {
96  ::SWGSDRangel::setValue(&file_record_name, pJson["fileRecordName"], "QString", "QString");
97 
98  ::SWGSDRangel::setValue(&use_reverse_api, pJson["useReverseAPI"], "qint32", "");
99 
100  ::SWGSDRangel::setValue(&reverse_api_address, pJson["reverseAPIAddress"], "QString", "QString");
101 
102  ::SWGSDRangel::setValue(&reverse_api_port, pJson["reverseAPIPort"], "qint32", "");
103 
104  ::SWGSDRangel::setValue(&reverse_api_device_index, pJson["reverseAPIDeviceIndex"], "qint32", "");
105 
106 
107  ::SWGSDRangel::setValue(&streams, pJson["streams"], "QList", "SWGTestMiStreamSettings");
108 }
109 
110 QString
112 {
113  QJsonObject* obj = this->asJsonObject();
114 
115  QJsonDocument doc(*obj);
116  QByteArray bytes = doc.toJson();
117  delete obj;
118  return QString(bytes);
119 }
120 
121 QJsonObject*
123  QJsonObject* obj = new QJsonObject();
124  if(file_record_name != nullptr && *file_record_name != QString("")){
125  toJsonValue(QString("fileRecordName"), file_record_name, obj, QString("QString"));
126  }
128  obj->insert("useReverseAPI", QJsonValue(use_reverse_api));
129  }
130  if(reverse_api_address != nullptr && *reverse_api_address != QString("")){
131  toJsonValue(QString("reverseAPIAddress"), reverse_api_address, obj, QString("QString"));
132  }
134  obj->insert("reverseAPIPort", QJsonValue(reverse_api_port));
135  }
137  obj->insert("reverseAPIDeviceIndex", QJsonValue(reverse_api_device_index));
138  }
139  if(streams->size() > 0){
140  toJsonArray((QList<void*>*)streams, obj, "streams", "SWGTestMiStreamSettings");
141  }
142 
143  return obj;
144 }
145 
146 QString*
148  return file_record_name;
149 }
150 void
152  this->file_record_name = file_record_name;
153  this->m_file_record_name_isSet = true;
154 }
155 
156 qint32
158  return use_reverse_api;
159 }
160 void
162  this->use_reverse_api = use_reverse_api;
163  this->m_use_reverse_api_isSet = true;
164 }
165 
166 QString*
168  return reverse_api_address;
169 }
170 void
172  this->reverse_api_address = reverse_api_address;
173  this->m_reverse_api_address_isSet = true;
174 }
175 
176 qint32
178  return reverse_api_port;
179 }
180 void
182  this->reverse_api_port = reverse_api_port;
183  this->m_reverse_api_port_isSet = true;
184 }
185 
186 qint32
189 }
190 void
192  this->reverse_api_device_index = reverse_api_device_index;
194 }
195 
196 QList<SWGTestMiStreamSettings*>*
198  return streams;
199 }
200 void
201 SWGTestMISettings::setStreams(QList<SWGTestMiStreamSettings*>* streams) {
202  this->streams = streams;
203  this->m_streams_isSet = true;
204 }
205 
206 
207 bool
209  bool isObjectUpdated = false;
210  do{
211  if(file_record_name != nullptr && *file_record_name != QString("")){ isObjectUpdated = true; break;}
212  if(m_use_reverse_api_isSet){ isObjectUpdated = true; break;}
213  if(reverse_api_address != nullptr && *reverse_api_address != QString("")){ isObjectUpdated = true; break;}
214  if(m_reverse_api_port_isSet){ isObjectUpdated = true; break;}
215  if(m_reverse_api_device_index_isSet){ isObjectUpdated = true; break;}
216  if(streams->size() > 0){ isObjectUpdated = true; break;}
217  }while(false);
218  return isObjectUpdated;
219 }
220 }
221 
void toJsonValue(QString name, void *value, QJsonObject *output, QString type)
Definition: SWGHelpers.cpp:383
void setUseReverseApi(qint32 use_reverse_api)
virtual QString asJson() override
void setStreams(QList< SWGTestMiStreamSettings *> *streams)
void setReverseApiDeviceIndex(qint32 reverse_api_device_index)
QList< SWGTestMiStreamSettings * > * streams
void setValue(void *value, QJsonValue obj, QString type, QString complexType)
Definition: SWGHelpers.cpp:25
QList< SWGTestMiStreamSettings * > * getStreams()
void toJsonArray(QList< void *> *value, QJsonObject *output, QString innerName, QString innerType)
Definition: SWGHelpers.cpp:445
virtual SWGTestMISettings * fromJson(QString &jsonString) override
void setReverseApiAddress(QString *reverse_api_address)
void setFileRecordName(QString *file_record_name)
void setReverseApiPort(qint32 reverse_api_port)
virtual QJsonObject * asJsonObject() override
virtual void fromJsonObject(QJsonObject &json) override