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.
SWGDeviceSetList.cpp
Go to the documentation of this file.
1 
14 #include "SWGDeviceSetList.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  devicesetcount = 0;
32  m_devicesetcount_isSet = false;
33  devicesetfocus = 0;
34  m_devicesetfocus_isSet = false;
35  device_sets = nullptr;
36  m_device_sets_isSet = false;
37 }
38 
40  this->cleanup();
41 }
42 
43 void
45  devicesetcount = 0;
46  m_devicesetcount_isSet = false;
47  devicesetfocus = 0;
48  m_devicesetfocus_isSet = false;
49  device_sets = new QList<SWGDeviceSet*>();
50  m_device_sets_isSet = false;
51 }
52 
53 void
55 
56 
57  if(device_sets != nullptr) {
58  auto arr = device_sets;
59  for(auto o: *arr) {
60  delete o;
61  }
62  delete device_sets;
63  }
64 }
65 
68  QByteArray array (json.toStdString().c_str());
69  QJsonDocument doc = QJsonDocument::fromJson(array);
70  QJsonObject jsonObject = doc.object();
71  this->fromJsonObject(jsonObject);
72  return this;
73 }
74 
75 void
76 SWGDeviceSetList::fromJsonObject(QJsonObject &pJson) {
77  ::SWGSDRangel::setValue(&devicesetcount, pJson["devicesetcount"], "qint32", "");
78 
79  ::SWGSDRangel::setValue(&devicesetfocus, pJson["devicesetfocus"], "qint32", "");
80 
81 
82  ::SWGSDRangel::setValue(&device_sets, pJson["deviceSets"], "QList", "SWGDeviceSet");
83 }
84 
85 QString
87 {
88  QJsonObject* obj = this->asJsonObject();
89 
90  QJsonDocument doc(*obj);
91  QByteArray bytes = doc.toJson();
92  delete obj;
93  return QString(bytes);
94 }
95 
96 QJsonObject*
98  QJsonObject* obj = new QJsonObject();
100  obj->insert("devicesetcount", QJsonValue(devicesetcount));
101  }
103  obj->insert("devicesetfocus", QJsonValue(devicesetfocus));
104  }
105  if(device_sets->size() > 0){
106  toJsonArray((QList<void*>*)device_sets, obj, "deviceSets", "SWGDeviceSet");
107  }
108 
109  return obj;
110 }
111 
112 qint32
114  return devicesetcount;
115 }
116 void
118  this->devicesetcount = devicesetcount;
119  this->m_devicesetcount_isSet = true;
120 }
121 
122 qint32
124  return devicesetfocus;
125 }
126 void
128  this->devicesetfocus = devicesetfocus;
129  this->m_devicesetfocus_isSet = true;
130 }
131 
132 QList<SWGDeviceSet*>*
134  return device_sets;
135 }
136 void
138  this->device_sets = device_sets;
139  this->m_device_sets_isSet = true;
140 }
141 
142 
143 bool
145  bool isObjectUpdated = false;
146  do{
147  if(m_devicesetcount_isSet){ isObjectUpdated = true; break;}
148  if(m_devicesetfocus_isSet){ isObjectUpdated = true; break;}
149  if(device_sets->size() > 0){ isObjectUpdated = true; break;}
150  }while(false);
151  return isObjectUpdated;
152 }
153 }
154 
virtual bool isSet() override
QList< SWGDeviceSet * > * getDeviceSets()
virtual QString asJson() override
QList< SWGDeviceSet * > * device_sets
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 QJsonObject * asJsonObject() override
void setDevicesetcount(qint32 devicesetcount)
virtual void fromJsonObject(QJsonObject &json) override
void setDevicesetfocus(qint32 devicesetfocus)
void setDeviceSets(QList< SWGDeviceSet *> *device_sets)
virtual SWGDeviceSetList * fromJson(QString &jsonString) override