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.
SWGChannelConfig.cpp
Go to the documentation of this file.
1 
14 #include "SWGChannelConfig.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  channel_id_uri = nullptr;
32  m_channel_id_uri_isSet = false;
33  channel_id = nullptr;
34  m_channel_id_isSet = false;
35  config = nullptr;
36  m_config_isSet = false;
37 }
38 
40  this->cleanup();
41 }
42 
43 void
45  channel_id_uri = new QString("");
46  m_channel_id_uri_isSet = false;
47  channel_id = new QString("");
48  m_channel_id_isSet = false;
49  config = new SWGChannelSettings();
50  m_config_isSet = false;
51 }
52 
53 void
55  if(channel_id_uri != nullptr) {
56  delete channel_id_uri;
57  }
58  if(channel_id != nullptr) {
59  delete channel_id;
60  }
61  if(config != nullptr) {
62  delete config;
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 SWGChannelConfig::fromJsonObject(QJsonObject &pJson) {
77  ::SWGSDRangel::setValue(&channel_id_uri, pJson["channelIdURI"], "QString", "QString");
78 
79  ::SWGSDRangel::setValue(&channel_id, pJson["channelId"], "QString", "QString");
80 
81  ::SWGSDRangel::setValue(&config, pJson["config"], "SWGChannelSettings", "SWGChannelSettings");
82 
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();
99  if(channel_id_uri != nullptr && *channel_id_uri != QString("")){
100  toJsonValue(QString("channelIdURI"), channel_id_uri, obj, QString("QString"));
101  }
102  if(channel_id != nullptr && *channel_id != QString("")){
103  toJsonValue(QString("channelId"), channel_id, obj, QString("QString"));
104  }
105  if((config != nullptr) && (config->isSet())){
106  toJsonValue(QString("config"), config, obj, QString("SWGChannelSettings"));
107  }
108 
109  return obj;
110 }
111 
112 QString*
114  return channel_id_uri;
115 }
116 void
118  this->channel_id_uri = channel_id_uri;
119  this->m_channel_id_uri_isSet = true;
120 }
121 
122 QString*
124  return channel_id;
125 }
126 void
128  this->channel_id = channel_id;
129  this->m_channel_id_isSet = true;
130 }
131 
134  return config;
135 }
136 void
138  this->config = config;
139  this->m_config_isSet = true;
140 }
141 
142 
143 bool
145  bool isObjectUpdated = false;
146  do{
147  if(channel_id_uri != nullptr && *channel_id_uri != QString("")){ isObjectUpdated = true; break;}
148  if(channel_id != nullptr && *channel_id != QString("")){ isObjectUpdated = true; break;}
149  if(config != nullptr && config->isSet()){ isObjectUpdated = true; break;}
150  }while(false);
151  return isObjectUpdated;
152 }
153 }
154 
SWGChannelSettings * getConfig()
void toJsonValue(QString name, void *value, QJsonObject *output, QString type)
Definition: SWGHelpers.cpp:383
virtual QJsonObject * asJsonObject() override
void setChannelId(QString *channel_id)
virtual void fromJsonObject(QJsonObject &json) override
virtual QString asJson() override
void setConfig(SWGChannelSettings *config)
void setValue(void *value, QJsonValue obj, QString type, QString complexType)
Definition: SWGHelpers.cpp:25
void setChannelIdUri(QString *channel_id_uri)
SWGChannelSettings * config
virtual SWGChannelConfig * fromJson(QString &jsonString) override
virtual bool isSet() override