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.
SWGFileSourceReport.cpp
Go to the documentation of this file.
1 
14 #include "SWGFileSourceReport.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;
33  file_sample_rate = 0;
35  file_sample_size = 0;
37  absolute_time = nullptr;
38  m_absolute_time_isSet = false;
39  elapsed_time = nullptr;
40  m_elapsed_time_isSet = false;
41  duration_time = nullptr;
42  m_duration_time_isSet = false;
43  sample_rate = 0;
44  m_sample_rate_isSet = false;
45  channel_power_db = 0.0f;
47 }
48 
50  this->cleanup();
51 }
52 
53 void
55  file_name = new QString("");
56  m_file_name_isSet = false;
57  file_sample_rate = 0;
59  file_sample_size = 0;
61  absolute_time = new QString("");
62  m_absolute_time_isSet = false;
63  elapsed_time = new QString("");
64  m_elapsed_time_isSet = false;
65  duration_time = new QString("");
66  m_duration_time_isSet = false;
67  sample_rate = 0;
68  m_sample_rate_isSet = false;
69  channel_power_db = 0.0f;
71 }
72 
73 void
75  if(file_name != nullptr) {
76  delete file_name;
77  }
78 
79 
80  if(absolute_time != nullptr) {
81  delete absolute_time;
82  }
83  if(elapsed_time != nullptr) {
84  delete elapsed_time;
85  }
86  if(duration_time != nullptr) {
87  delete duration_time;
88  }
89 
90 
91 }
92 
95  QByteArray array (json.toStdString().c_str());
96  QJsonDocument doc = QJsonDocument::fromJson(array);
97  QJsonObject jsonObject = doc.object();
98  this->fromJsonObject(jsonObject);
99  return this;
100 }
101 
102 void
104  ::SWGSDRangel::setValue(&file_name, pJson["fileName"], "QString", "QString");
105 
106  ::SWGSDRangel::setValue(&file_sample_rate, pJson["fileSampleRate"], "qint32", "");
107 
108  ::SWGSDRangel::setValue(&file_sample_size, pJson["fileSampleSize"], "qint32", "");
109 
110  ::SWGSDRangel::setValue(&absolute_time, pJson["absoluteTime"], "QString", "QString");
111 
112  ::SWGSDRangel::setValue(&elapsed_time, pJson["elapsedTime"], "QString", "QString");
113 
114  ::SWGSDRangel::setValue(&duration_time, pJson["durationTime"], "QString", "QString");
115 
116  ::SWGSDRangel::setValue(&sample_rate, pJson["sampleRate"], "qint32", "");
117 
118  ::SWGSDRangel::setValue(&channel_power_db, pJson["channelPowerDB"], "float", "");
119 
120 }
121 
122 QString
124 {
125  QJsonObject* obj = this->asJsonObject();
126 
127  QJsonDocument doc(*obj);
128  QByteArray bytes = doc.toJson();
129  delete obj;
130  return QString(bytes);
131 }
132 
133 QJsonObject*
135  QJsonObject* obj = new QJsonObject();
136  if(file_name != nullptr && *file_name != QString("")){
137  toJsonValue(QString("fileName"), file_name, obj, QString("QString"));
138  }
140  obj->insert("fileSampleRate", QJsonValue(file_sample_rate));
141  }
143  obj->insert("fileSampleSize", QJsonValue(file_sample_size));
144  }
145  if(absolute_time != nullptr && *absolute_time != QString("")){
146  toJsonValue(QString("absoluteTime"), absolute_time, obj, QString("QString"));
147  }
148  if(elapsed_time != nullptr && *elapsed_time != QString("")){
149  toJsonValue(QString("elapsedTime"), elapsed_time, obj, QString("QString"));
150  }
151  if(duration_time != nullptr && *duration_time != QString("")){
152  toJsonValue(QString("durationTime"), duration_time, obj, QString("QString"));
153  }
155  obj->insert("sampleRate", QJsonValue(sample_rate));
156  }
158  obj->insert("channelPowerDB", QJsonValue(channel_power_db));
159  }
160 
161  return obj;
162 }
163 
164 QString*
166  return file_name;
167 }
168 void
170  this->file_name = file_name;
171  this->m_file_name_isSet = true;
172 }
173 
174 qint32
176  return file_sample_rate;
177 }
178 void
180  this->file_sample_rate = file_sample_rate;
181  this->m_file_sample_rate_isSet = true;
182 }
183 
184 qint32
186  return file_sample_size;
187 }
188 void
190  this->file_sample_size = file_sample_size;
191  this->m_file_sample_size_isSet = true;
192 }
193 
194 QString*
196  return absolute_time;
197 }
198 void
200  this->absolute_time = absolute_time;
201  this->m_absolute_time_isSet = true;
202 }
203 
204 QString*
206  return elapsed_time;
207 }
208 void
210  this->elapsed_time = elapsed_time;
211  this->m_elapsed_time_isSet = true;
212 }
213 
214 QString*
216  return duration_time;
217 }
218 void
220  this->duration_time = duration_time;
221  this->m_duration_time_isSet = true;
222 }
223 
224 qint32
226  return sample_rate;
227 }
228 void
230  this->sample_rate = sample_rate;
231  this->m_sample_rate_isSet = true;
232 }
233 
234 float
236  return channel_power_db;
237 }
238 void
240  this->channel_power_db = channel_power_db;
241  this->m_channel_power_db_isSet = true;
242 }
243 
244 
245 bool
247  bool isObjectUpdated = false;
248  do{
249  if(file_name != nullptr && *file_name != QString("")){ isObjectUpdated = true; break;}
250  if(m_file_sample_rate_isSet){ isObjectUpdated = true; break;}
251  if(m_file_sample_size_isSet){ isObjectUpdated = true; break;}
252  if(absolute_time != nullptr && *absolute_time != QString("")){ isObjectUpdated = true; break;}
253  if(elapsed_time != nullptr && *elapsed_time != QString("")){ isObjectUpdated = true; break;}
254  if(duration_time != nullptr && *duration_time != QString("")){ isObjectUpdated = true; break;}
255  if(m_sample_rate_isSet){ isObjectUpdated = true; break;}
256  if(m_channel_power_db_isSet){ isObjectUpdated = true; break;}
257  }while(false);
258  return isObjectUpdated;
259 }
260 }
261 
void setSampleRate(qint32 sample_rate)
void setDurationTime(QString *duration_time)
virtual QString asJson() override
void setFileName(QString *file_name)
void toJsonValue(QString name, void *value, QJsonObject *output, QString type)
Definition: SWGHelpers.cpp:383
virtual SWGFileSourceReport * fromJson(QString &jsonString) override
void setFileSampleRate(qint32 file_sample_rate)
virtual QJsonObject * asJsonObject() override
void setChannelPowerDb(float channel_power_db)
void setElapsedTime(QString *elapsed_time)
void setValue(void *value, QJsonValue obj, QString type, QString complexType)
Definition: SWGHelpers.cpp:25
void setAbsoluteTime(QString *absolute_time)
virtual void fromJsonObject(QJsonObject &json) override
void setFileSampleSize(qint32 file_sample_size)