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.
SWGRtlSdrReport.cpp
Go to the documentation of this file.
1 
14 #include "SWGRtlSdrReport.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  gains = nullptr;
32  m_gains_isSet = false;
33 }
34 
36  this->cleanup();
37 }
38 
39 void
41  gains = new QList<SWGGain*>();
42  m_gains_isSet = false;
43 }
44 
45 void
47  if(gains != nullptr) {
48  auto arr = gains;
49  for(auto o: *arr) {
50  delete o;
51  }
52  delete gains;
53  }
54 }
55 
57 SWGRtlSdrReport::fromJson(QString &json) {
58  QByteArray array (json.toStdString().c_str());
59  QJsonDocument doc = QJsonDocument::fromJson(array);
60  QJsonObject jsonObject = doc.object();
61  this->fromJsonObject(jsonObject);
62  return this;
63 }
64 
65 void
66 SWGRtlSdrReport::fromJsonObject(QJsonObject &pJson) {
67 
68  ::SWGSDRangel::setValue(&gains, pJson["gains"], "QList", "SWGGain");
69 }
70 
71 QString
73 {
74  QJsonObject* obj = this->asJsonObject();
75 
76  QJsonDocument doc(*obj);
77  QByteArray bytes = doc.toJson();
78  delete obj;
79  return QString(bytes);
80 }
81 
82 QJsonObject*
84  QJsonObject* obj = new QJsonObject();
85  if(gains->size() > 0){
86  toJsonArray((QList<void*>*)gains, obj, "gains", "SWGGain");
87  }
88 
89  return obj;
90 }
91 
92 QList<SWGGain*>*
94  return gains;
95 }
96 void
97 SWGRtlSdrReport::setGains(QList<SWGGain*>* gains) {
98  this->gains = gains;
99  this->m_gains_isSet = true;
100 }
101 
102 
103 bool
105  bool isObjectUpdated = false;
106  do{
107  if(gains->size() > 0){ isObjectUpdated = true; break;}
108  }while(false);
109  return isObjectUpdated;
110 }
111 }
112 
QList< SWGGain * > * getGains()
virtual bool isSet() override
QList< SWGGain * > * gains
virtual QJsonObject * asJsonObject() override
virtual SWGRtlSdrReport * fromJson(QString &jsonString) override
void setGains(QList< SWGGain *> *gains)
virtual void fromJsonObject(QJsonObject &json) override
void setValue(void *value, QJsonValue obj, QString type, QString complexType)
Definition: SWGHelpers.cpp:25
void toJsonArray(QList< void *> *value, QJsonObject *output, QString innerName, QString innerType)
Definition: SWGHelpers.cpp:445
virtual QString asJson() override