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.
SWGAMBEDevices.cpp
Go to the documentation of this file.
1 
14 #include "SWGAMBEDevices.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  nb_devices = 0;
32  m_nb_devices_isSet = false;
33  ambe_devices = nullptr;
34  m_ambe_devices_isSet = false;
35 }
36 
38  this->cleanup();
39 }
40 
41 void
43  nb_devices = 0;
44  m_nb_devices_isSet = false;
45  ambe_devices = new QList<SWGAMBEDevice*>();
46  m_ambe_devices_isSet = false;
47 }
48 
49 void
51 
52  if(ambe_devices != nullptr) {
53  auto arr = ambe_devices;
54  for(auto o: *arr) {
55  delete o;
56  }
57  delete ambe_devices;
58  }
59 }
60 
62 SWGAMBEDevices::fromJson(QString &json) {
63  QByteArray array (json.toStdString().c_str());
64  QJsonDocument doc = QJsonDocument::fromJson(array);
65  QJsonObject jsonObject = doc.object();
66  this->fromJsonObject(jsonObject);
67  return this;
68 }
69 
70 void
71 SWGAMBEDevices::fromJsonObject(QJsonObject &pJson) {
72  ::SWGSDRangel::setValue(&nb_devices, pJson["nbDevices"], "qint32", "");
73 
74 
75  ::SWGSDRangel::setValue(&ambe_devices, pJson["ambeDevices"], "QList", "SWGAMBEDevice");
76 }
77 
78 QString
80 {
81  QJsonObject* obj = this->asJsonObject();
82 
83  QJsonDocument doc(*obj);
84  QByteArray bytes = doc.toJson();
85  delete obj;
86  return QString(bytes);
87 }
88 
89 QJsonObject*
91  QJsonObject* obj = new QJsonObject();
93  obj->insert("nbDevices", QJsonValue(nb_devices));
94  }
95  if(ambe_devices->size() > 0){
96  toJsonArray((QList<void*>*)ambe_devices, obj, "ambeDevices", "SWGAMBEDevice");
97  }
98 
99  return obj;
100 }
101 
102 qint32
104  return nb_devices;
105 }
106 void
108  this->nb_devices = nb_devices;
109  this->m_nb_devices_isSet = true;
110 }
111 
112 QList<SWGAMBEDevice*>*
114  return ambe_devices;
115 }
116 void
118  this->ambe_devices = ambe_devices;
119  this->m_ambe_devices_isSet = true;
120 }
121 
122 
123 bool
125  bool isObjectUpdated = false;
126  do{
127  if(m_nb_devices_isSet){ isObjectUpdated = true; break;}
128  if(ambe_devices->size() > 0){ isObjectUpdated = true; break;}
129  }while(false);
130  return isObjectUpdated;
131 }
132 }
133 
virtual void fromJsonObject(QJsonObject &json) override
void setNbDevices(qint32 nb_devices)
QList< SWGAMBEDevice * > * ambe_devices
virtual QString asJson() override
virtual bool isSet() 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
void setAmbeDevices(QList< SWGAMBEDevice *> *ambe_devices)
QList< SWGAMBEDevice * > * getAmbeDevices()
virtual SWGAMBEDevices * fromJson(QString &jsonString) override
virtual QJsonObject * asJsonObject() override