refs #314, fixed DBus crash because of wrong list type

discussion here: https://dev.vatsim-germany.org/boards/22/topics/2006?r=2015#message-2015
* Fixed CIndexVariantMap
* In the same step added more tests in the DBus sample
This commit is contained in:
Klaus Basan
2014-08-21 11:27:17 +02:00
parent 2089ab89a1
commit a97830b7cf
5 changed files with 62 additions and 2 deletions

View File

@@ -127,6 +127,9 @@ namespace BlackMiscTest
*/
CAtcStationList ServiceTool::getStations(qint32 number)
{
QElapsedTimer timer;
timer.start();
BlackMisc::Aviation::CAtcStationList list;
for (int i = 0; i < number; i++)
{
@@ -138,6 +141,8 @@ namespace BlackMiscTest
s.setPosition(CCoordinateGeodetic(i, i, i));
list.push_back(s);
}
qDebug() << number << "stations in" << timer.nsecsElapsed() / 1000000; // ms
return list;
}
@@ -329,6 +334,17 @@ namespace BlackMiscTest
qDebug() << "Send geo position" << geoPos;
qDebug() << "----------------- pings ----------------";
CPropertyIndex pi({ 1, 2, 3, 4, 5});
pi = testserviceInterface.pingPropertyIndex(pi);
qDebug() << "Pinged properties via interface" << pi;
CIndexVariantMap ivm;
ivm.addValue(1, "one");
ivm.addValue(2, "two");
ivm.addValue(3, "three");
ivm = testserviceInterface.pingIndexVariantMap(ivm);
qDebug() << "Pinged variant map via interface" << ivm;
CAtcStation stationReceived = testserviceInterface.pingAtcStation(station);
qDebug() << "Pinged ATC station via interface"
<< ((station == stationReceived) ? "OK" : "ERROR!") << stationReceived;

View File

@@ -10,6 +10,7 @@
#include "testservice.h"
#include "blackmisc/blackmiscfreefunctions.h"
using namespace BlackMisc;
using namespace BlackMisc::Aviation;
using namespace BlackMisc::Geo;
using namespace BlackMisc::PhysicalQuantities;
@@ -243,7 +244,7 @@ namespace BlackMiscTest
*/
CAircraftList Testservice::pingAircraftList(const CAircraftList &aircraftList)
{
qDebug() << "Pid:" << ServiceTool::getPid() << "ping ATCs:" << aircraftList;
qDebug() << "Pid:" << ServiceTool::getPid() << "ping aircrafts:" << aircraftList;
return aircraftList;
}
@@ -256,6 +257,24 @@ namespace BlackMiscTest
return airportList;
}
/*
* Ping property index
*/
CPropertyIndex Testservice::pingPropertyIndex(const CPropertyIndex &properties)
{
qDebug() << "Pid:" << ServiceTool::getPid() << "ping properties:" << properties;
return properties;
}
/*
* Ping index variant map
*/
CIndexVariantMap Testservice::pingIndexVariantMap(const CIndexVariantMap &indexVariantMap)
{
qDebug() << "Pid:" << ServiceTool::getPid() << "ping properties:" << indexVariantMap;
return indexVariantMap;
}
/*
* NW client
*/

View File

@@ -143,6 +143,20 @@ namespace BlackMiscTest
return asyncCallWithArgumentList(QLatin1String("pingCVariant"), argumentList);
}
inline QDBusPendingReply<BlackMisc::CPropertyIndex> pingPropertyIndex(BlackMisc::CPropertyIndex index)
{
QList<QVariant> argumentList;
argumentList << index.toQVariant();
return asyncCallWithArgumentList(QLatin1String("pingPropertyIndex"), argumentList);
}
inline QDBusPendingReply<BlackMisc::CIndexVariantMap> pingIndexVariantMap(BlackMisc::CIndexVariantMap indexVariantMap)
{
QList<QVariant> argumentList;
argumentList << indexVariantMap.toQVariant();
return asyncCallWithArgumentList(QLatin1String("pingIndexVariantMap"), argumentList);
}
inline QDBusPendingReply<BlackMisc::Aviation::CAltitude> receiveAltitude(BlackMisc::Aviation::CAltitude altitude)
{
QList<QVariant> argumentList;

View File

@@ -107,7 +107,7 @@ namespace BlackMisc
*/
void CIndexVariantMap::unmarshallFromDbus(const QDBusArgument &argument)
{
QList<int> indexes;
QList<CPropertyIndex> indexes;
QList<CVariant> values;
argument >> indexes;
argument >> values;
@@ -129,6 +129,14 @@ namespace BlackMisc
this->m_values.insert(index, value);
}
/*
* Add string by literal
*/
void CIndexVariantMap::addValue(const CPropertyIndex &index, const char *str)
{
this->addValue(index, QString(str));
}
/*
* Register metadata
*/

View File

@@ -47,6 +47,9 @@ namespace BlackMisc
//! Add a value
void addValue(const CPropertyIndex &index, const QVariant &value);
//! Add QString as literal, disambiguate as I want to add QString
void addValue(const CPropertyIndex &index, const char* str);
//! Add a value as non QVariant
template<class T> void addValue(const CPropertyIndex &index, const T &value) { this->m_values.insert(index, CVariant::fromValue(value)); }