Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Institute of Technical Acoustics (ITA)
Redstart
Commits
c6b53b25
Commit
c6b53b25
authored
Nov 15, 2017
by
Dipl.-Ing. Jonas Stienen
Browse files
Progress in struct and hash map conversion
parent
beba8f26
Changes
3
Hide whitespace changes
Inline
Side-by-side
CMakeLists.txt
View file @
c6b53b25
...
...
@@ -61,7 +61,7 @@ include_directories( "${CMAKE_CURRENT_BINARY_DIR}" ) # Qt UI form compiler gener
qt5_add_resources
(
VA_REDSTART_RESOURCES
"res/QRedstart.qrc"
OPTIONS -compress 3
)
add_executable
(
Redstart
${
VA_REDSTART_RESOURCES
}
"src/main.cpp"
"src/RedstartWindow.cpp"
"src/RedstartWindow.h"
"ui/RedstartWindow.ui"
)
add_executable
(
Redstart
${
VA_REDSTART_RESOURCES
}
"src/main.cpp"
"src/RedstartWindow.cpp"
"src/RedstartWindow.h"
"src/RedstartUtils.h"
"ui/RedstartWindow.ui"
)
target_link_libraries
(
Redstart
${
VISTA_USE_PACKAGE_LIBRARIES
}
${
VISTAINTERPROCCOMM_ADDITIONAL_DEPENDENCIES
}
Qt5::Widgets
)
install
(
TARGETS Redstart RUNTIME DESTINATION
"bin"
)
...
...
src/RedstartUtils.h
0 → 100644
View file @
c6b53b25
/*
* --------------------------------------------------------------------------------------------
*
* VVV VVV A Virtual Acoustics (VA) | http://www.virtualacoustics.org
* VVV VVV AAA Licensed under the Apache License, Version 2.0
* VVV VVV AAA
* VVV VVV AAA Copyright 2015-2017
* VVVVVV AAA Institute of Technical Acoustics (ITA)
* VVVV AAA RWTH Aachen University
*
* --------------------------------------------------------------------------------------------
*/
#ifndef IW_REDSTART_UTILS
#define IW_REDSTART_UTILS
#include
<QHash>
#include
<VAStruct.h>
inline
QVariantHash
ConvertVAStructToQHash
(
const
CVAStruct
&
oStruct
)
{
QVariantHash
oHash
;
CVAStruct
::
const_iterator
cit
=
oStruct
.
Begin
();
while
(
cit
!=
oStruct
.
End
()
)
{
const
QString
sKey
(
cit
->
first
.
c_str
()
);
const
CVAStructValue
&
oValue
(
cit
->
second
);
cit
++
;
switch
(
oValue
.
GetDatatype
()
)
{
case
CVAStructValue
:
:
BOOL
:
{
oHash
[
sKey
]
=
bool
(
oValue
);
break
;
}
case
CVAStructValue
:
:
INT
:
{
oHash
[
sKey
]
=
int
(
oValue
);
break
;
}
case
CVAStructValue
:
:
DOUBLE
:
{
oHash
[
sKey
]
=
double
(
oValue
);
break
;
}
case
CVAStructValue
:
:
STRING
:
{
oHash
[
sKey
]
=
QString
(
std
::
string
(
oValue
).
c_str
()
);
break
;
}
case
CVAStructValue
:
:
DATA
:
{
oHash
[
sKey
]
=
QByteArray
(
(
const
char
*
)
oValue
.
GetData
(),
oValue
.
GetDataSize
()
);
break
;
}
case
CVAStructValue
:
:
STRUCT
:
{
oHash
[
sKey
]
=
ConvertVAStructToQHash
(
oValue
);
break
;
}
}
}
return
oHash
;
};
inline
CVAStruct
ConvertQHashToVAStruct
(
const
QVariantHash
&
oHash
)
{
CVAStruct
oStruct
;
QVariantHash
::
const_iterator
cit
=
oHash
.
constBegin
();
while
(
cit
!=
oHash
.
constEnd
()
)
{
const
QString
&
sKey
(
cit
.
key
()
);
const
QVariant
&
oValue
(
cit
.
value
()
);
++
cit
;
bool
bOK
=
true
;
switch
(
oValue
.
type
()
)
{
case
QVariant
:
:
Bool
:
{
oStruct
[
sKey
.
toStdString
()
]
=
oValue
.
toBool
();
break
;
}
case
QVariant
:
:
Int
:
{
oStruct
[
sKey
.
toStdString
()
]
=
oValue
.
toInt
(
&
bOK
);
break
;
}
case
QVariant
:
:
Double
:
{
oStruct
[
sKey
.
toStdString
()
]
=
oValue
.
toDouble
(
&
bOK
);
break
;
}
case
QVariant
:
:
String
:
{
oStruct
[
sKey
.
toStdString
()
]
=
oValue
.
toString
().
toStdString
();
break
;
}
case
QVariant
:
:
ByteArray
:
{
oStruct
[
sKey
.
toStdString
()
]
=
CVAStructValue
(
(
void
*
)
oValue
.
toByteArray
().
data
(),
oValue
.
toByteArray
().
size
()
);
break
;
}
case
QVariant
:
:
Map
:
oStruct
[
sKey
.
toStdString
()
]
=
ConvertQHashToVAStruct
(
oValue
.
toHash
()
);
break
;
}
}
return
oStruct
;
};
#endif // IW_REDSTART_UTILS
src/RedstartWindow.cpp
View file @
c6b53b25
...
...
@@ -13,7 +13,8 @@
#include
<QErrorMessage>
#include
<QUrl>
#include
<qdesktopservices>
#include
<QDesktopServices>
#include
<QHash>
#include
"RedstartWindow.h"
#include
<ui_RedstartWindow.h>
...
...
@@ -147,8 +148,23 @@ void RedstartWindow::on_pushButton_start_stop_clicked()
}
else
{
// @todo get config from session
CVAStruct
oVAConfigArgs
=
VACore
::
GetCoreConfigFromFile
(
"../VACore/conf/VACore.ini"
);
QHash
<
QString
,
QVariant
>
oHash
,
oHash2
;
oHash
[
QString
(
"test"
)
]
=
int
(
1
);
oHash
[
QString
(
"test2"
)
]
=
QHash
<
QString
,
QVariant
>
();
m_qSettings
.
setValue
(
"sessions_test"
,
oHash
);
m_qSettings
.
sync
();
oHash2
=
m_qSettings
.
value
(
"sessions_test"
).
toHash
();
int
c
=
oHash2
.
count
();
bool
bOK2
;
int
iTest
=
oHash
[
QString
(
"test"
)
].
toInt
(
&
bOK2
);
int
iTest2
=
oHash2
[
QString
(
"test"
)
].
toInt
(
&
bOK2
);
std
::
string
sBackend
,
sDevice
;
// Override configs
switch
(
ui
->
comboBox_audio_driver
->
currentIndex
()
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment