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.
SWGAudioInputDevice.cpp
Go to the documentation of this file.
1 
14 #include "SWGAudioInputDevice.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  name = nullptr;
32  m_name_isSet = false;
33  index = 0;
34  m_index_isSet = false;
35  sample_rate = 0;
36  m_sample_rate_isSet = false;
41  volume = 0.0f;
42  m_volume_isSet = false;
43 }
44 
46  this->cleanup();
47 }
48 
49 void
51  name = new QString("");
52  m_name_isSet = false;
53  index = 0;
54  m_index_isSet = false;
55  sample_rate = 0;
56  m_sample_rate_isSet = false;
61  volume = 0.0f;
62  m_volume_isSet = false;
63 }
64 
65 void
67  if(name != nullptr) {
68  delete name;
69  }
70 
71 
72 
73 
74 
75 }
76 
79  QByteArray array (json.toStdString().c_str());
80  QJsonDocument doc = QJsonDocument::fromJson(array);
81  QJsonObject jsonObject = doc.object();
82  this->fromJsonObject(jsonObject);
83  return this;
84 }
85 
86 void
88  ::SWGSDRangel::setValue(&name, pJson["name"], "QString", "QString");
89 
90  ::SWGSDRangel::setValue(&index, pJson["index"], "qint32", "");
91 
92  ::SWGSDRangel::setValue(&sample_rate, pJson["sampleRate"], "qint32", "");
93 
94  ::SWGSDRangel::setValue(&is_system_default, pJson["isSystemDefault"], "qint32", "");
95 
96  ::SWGSDRangel::setValue(&default_unregistered, pJson["defaultUnregistered"], "qint32", "");
97 
98  ::SWGSDRangel::setValue(&volume, pJson["volume"], "float", "");
99 
100 }
101 
102 QString
104 {
105  QJsonObject* obj = this->asJsonObject();
106 
107  QJsonDocument doc(*obj);
108  QByteArray bytes = doc.toJson();
109  delete obj;
110  return QString(bytes);
111 }
112 
113 QJsonObject*
115  QJsonObject* obj = new QJsonObject();
116  if(name != nullptr && *name != QString("")){
117  toJsonValue(QString("name"), name, obj, QString("QString"));
118  }
119  if(m_index_isSet){
120  obj->insert("index", QJsonValue(index));
121  }
123  obj->insert("sampleRate", QJsonValue(sample_rate));
124  }
126  obj->insert("isSystemDefault", QJsonValue(is_system_default));
127  }
129  obj->insert("defaultUnregistered", QJsonValue(default_unregistered));
130  }
131  if(m_volume_isSet){
132  obj->insert("volume", QJsonValue(volume));
133  }
134 
135  return obj;
136 }
137 
138 QString*
140  return name;
141 }
142 void
144  this->name = name;
145  this->m_name_isSet = true;
146 }
147 
148 qint32
150  return index;
151 }
152 void
154  this->index = index;
155  this->m_index_isSet = true;
156 }
157 
158 qint32
160  return sample_rate;
161 }
162 void
164  this->sample_rate = sample_rate;
165  this->m_sample_rate_isSet = true;
166 }
167 
168 qint32
170  return is_system_default;
171 }
172 void
174  this->is_system_default = is_system_default;
175  this->m_is_system_default_isSet = true;
176 }
177 
178 qint32
180  return default_unregistered;
181 }
182 void
184  this->default_unregistered = default_unregistered;
185  this->m_default_unregistered_isSet = true;
186 }
187 
188 float
190  return volume;
191 }
192 void
194  this->volume = volume;
195  this->m_volume_isSet = true;
196 }
197 
198 
199 bool
201  bool isObjectUpdated = false;
202  do{
203  if(name != nullptr && *name != QString("")){ isObjectUpdated = true; break;}
204  if(m_index_isSet){ isObjectUpdated = true; break;}
205  if(m_sample_rate_isSet){ isObjectUpdated = true; break;}
206  if(m_is_system_default_isSet){ isObjectUpdated = true; break;}
207  if(m_default_unregistered_isSet){ isObjectUpdated = true; break;}
208  if(m_volume_isSet){ isObjectUpdated = true; break;}
209  }while(false);
210  return isObjectUpdated;
211 }
212 }
213 
virtual QJsonObject * asJsonObject() override
void setIsSystemDefault(qint32 is_system_default)
void toJsonValue(QString name, void *value, QJsonObject *output, QString type)
Definition: SWGHelpers.cpp:383
void setSampleRate(qint32 sample_rate)
virtual void fromJsonObject(QJsonObject &json) override
void setDefaultUnregistered(qint32 default_unregistered)
void setValue(void *value, QJsonValue obj, QString type, QString complexType)
Definition: SWGHelpers.cpp:25
virtual SWGAudioInputDevice * fromJson(QString &jsonString) override
virtual QString asJson() override