Migrates residual Lts sources to generated rtiddsgen API
Adds NmeaManagement tests, fixes codegen includes and Qt6 SerialPort CMake target.
This commit is contained in:
1 parent
5485a90385
commit
881d44f4dd
512 files changed
+6887
-6426
No files matched your search
+50
-50
@@ -28,12 +28,12 @@ AudioVideoManagement::Database::AvmMenuStruct toDb(const AudioVideoManagement::A
|
||||
{
|
||||
AudioVideoManagement::Database::AvmMenuStruct dbItem;
|
||||
|
||||
dbItem.id = ddsItem.id() <= 0 ? 0 : ddsItem.id();
|
||||
dbItem.id = ddsItem.id <= 0 ? 0 : ddsItem.id;
|
||||
dbItem.parentId = parentId;
|
||||
dbItem.isGroup = ddsItem.isGroup();
|
||||
dbItem.rowid = ddsItem.rowId();
|
||||
dbItem.isGroup = ddsItem.isGroup;
|
||||
dbItem.rowid = ddsItem.rowId;
|
||||
|
||||
if (ddsItem.isGroup())
|
||||
if (ddsItem.isGroup)
|
||||
dbItem.name = QString::fromStdString(ddsItem.name.get());
|
||||
else
|
||||
dbItem.mountingPointId = ddsItem.mountingPointId.get();
|
||||
@@ -45,27 +45,27 @@ void checkHierarchy(const std::vector<AudioVideoManagement::AvMenuEntry> &entrie
|
||||
{
|
||||
std::vector<AudioVideoManagement::AvMenuEntry> entries = entries_;
|
||||
|
||||
auto isToplevel = [toplevelId] (const AudioVideoManagement::AvMenuEntry &entry) { return entry.parentId() == toplevelId; };
|
||||
auto isToplevel = [toplevelId] (const AudioVideoManagement::AvMenuEntry &entry) { return entry.parentId == toplevelId; };
|
||||
auto sublevelStart = std::partition(entries.begin(), entries.end(), isToplevel);
|
||||
|
||||
std::set<int32_t> ids;
|
||||
std::set<int32_t> groupIds;
|
||||
for (auto entry = entries.begin(); entry != sublevelStart; ++entry)
|
||||
{
|
||||
auto result = ids.insert(entry->id());
|
||||
auto result = ids.insert(entry->id);
|
||||
Q_ASSERT(result.second);
|
||||
|
||||
if (entry->isGroup())
|
||||
groupIds.insert(entry->id());
|
||||
if (entry->isGroup)
|
||||
groupIds.insert(entry->id);
|
||||
}
|
||||
|
||||
for (auto entry = sublevelStart; entry != entries.end(); ++entry)
|
||||
{
|
||||
auto result = ids.insert(entry->id());
|
||||
auto result = ids.insert(entry->id);
|
||||
Q_ASSERT(result.second);
|
||||
|
||||
Q_ASSERT(!entry->isGroup());
|
||||
Q_ASSERT(groupIds.count(entry->parentId()) > 0);
|
||||
Q_ASSERT(!entry->isGroup);
|
||||
Q_ASSERT(groupIds.count(entry->parentId) > 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,12 +86,12 @@ ObjectMenuStruct::ObjectMenuStruct(Interface::Dts *dts, DatabaseInterface *db)
|
||||
|
||||
ObjectMenuStruct::~ObjectMenuStruct()
|
||||
{
|
||||
m_dts->removeMenuStructByKey(m_data.id());
|
||||
m_dts->removeMenuStructByKey(m_data.id);
|
||||
}
|
||||
|
||||
Core::FunctionReplyObject ObjectMenuStruct::createFromDds(const MenuStruct &data)
|
||||
{
|
||||
Q_ASSERT(data.id() <= 0 && m_data.id() <= 0);
|
||||
Q_ASSERT(data.id <= 0 && m_data.id <= 0);
|
||||
auto reply = insertUpdateDb(data);
|
||||
onPublishData();
|
||||
return reply;
|
||||
@@ -99,7 +99,7 @@ Core::FunctionReplyObject ObjectMenuStruct::createFromDds(const MenuStruct &data
|
||||
|
||||
Core::FunctionReplyObject ObjectMenuStruct::updateFromDds(const MenuStruct &data)
|
||||
{
|
||||
Q_ASSERT(data.id() > 0 && data.id() == m_data.id());
|
||||
Q_ASSERT(data.id > 0 && data.id == m_data.id);
|
||||
auto reply = insertUpdateDb(data);
|
||||
onPublishData();
|
||||
return reply;
|
||||
@@ -107,19 +107,19 @@ Core::FunctionReplyObject ObjectMenuStruct::updateFromDds(const MenuStruct &data
|
||||
|
||||
void ObjectMenuStruct::createFromDb(const MenuStruct &data)
|
||||
{
|
||||
Q_ASSERT(data.id() > 0 && m_data.id() <= 0);
|
||||
checkHierarchy(data.menuEntries(), data.id());
|
||||
Q_ASSERT(data.id > 0 && m_data.id <= 0);
|
||||
checkHierarchy(data.menuEntries, data.id);
|
||||
m_data = data;
|
||||
onPublishData();
|
||||
}
|
||||
|
||||
void ObjectMenuStruct::updateFromDb(const MenuStruct &data)
|
||||
{
|
||||
Q_ASSERT(data.id() > 0 && data.id() == m_data.id());
|
||||
Q_ASSERT(data.id > 0 && data.id == m_data.id);
|
||||
if (data == m_data)
|
||||
return;
|
||||
|
||||
checkHierarchy(data.menuEntries(), data.id());
|
||||
checkHierarchy(data.menuEntries, data.id);
|
||||
m_data = data;
|
||||
onPublishData();
|
||||
}
|
||||
@@ -128,31 +128,31 @@ Core::FunctionReplyObject ObjectMenuStruct::remove()
|
||||
{
|
||||
DBTransaction trans(m_db->database());
|
||||
|
||||
INFO_LOG(m_logger) << "menuEntries.size(): " << m_data.menuEntries().size();
|
||||
for (const AudioVideoManagement::AvMenuEntry &me : m_data.menuEntries())
|
||||
INFO_LOG(m_logger) << "menuEntries.size(): " << m_data.menuEntries.size();
|
||||
for (const AudioVideoManagement::AvMenuEntry &me : m_data.menuEntries)
|
||||
{
|
||||
INFO_LOG(m_logger) << "Remove entries with id/parentId: " << me.id();
|
||||
INFO_LOG(m_logger) << "Remove entries with id/parentId: " << me.id;
|
||||
// no recursion needed, only 2 levels allowed
|
||||
if (me.isGroup())
|
||||
if (!m_db->removeAvmMenuStructByParentId(me.id()))
|
||||
return Core::FunctionReplyObject(m_data.id(), "Error while removing menu entries");
|
||||
if (!m_db->removeAvmMenuStruct(me.id()))
|
||||
return Core::FunctionReplyObject(m_data.id(), "Error while removing menu entries");
|
||||
if (me.isGroup)
|
||||
if (!m_db->removeAvmMenuStructByParentId(me.id))
|
||||
return Core::FunctionReplyObject(m_data.id, "Error while removing menu entries");
|
||||
if (!m_db->removeAvmMenuStruct(me.id))
|
||||
return Core::FunctionReplyObject(m_data.id, "Error while removing menu entries");
|
||||
}
|
||||
if (!m_db->removeAvmMenuStruct(m_data.id()))
|
||||
return Core::FunctionReplyObject(m_data.id(), "Error while removing menu struct");
|
||||
if (!m_db->removeAvmMenuStruct(m_data.id))
|
||||
return Core::FunctionReplyObject(m_data.id, "Error while removing menu struct");
|
||||
|
||||
trans.commit();
|
||||
|
||||
m_dts->removeMenuStructByKey(m_data.id());
|
||||
m_dts->removeMenuStructByKey(m_data.id);
|
||||
|
||||
return Core::FunctionReplyObject(m_data.id());
|
||||
return Core::FunctionReplyObject(m_data.id);
|
||||
}
|
||||
|
||||
void ObjectMenuStruct::onPublishData()
|
||||
{
|
||||
|
||||
INFO_LOG(m_logger) << "Publish MenuStruct-data to dds (" << m_data.id() << ") ...";
|
||||
INFO_LOG(m_logger) << "Publish MenuStruct-data to dds (" << m_data.id << ") ...";
|
||||
|
||||
if (!m_dts->publish(m_data))
|
||||
ERROR_LOG(m_logger) << "Error publishing MenuStruct-data to dds";
|
||||
@@ -161,24 +161,24 @@ void ObjectMenuStruct::onPublishData()
|
||||
|
||||
Core::FunctionReplyObject ObjectMenuStruct::insertUpdateDb(const MenuStruct &data)
|
||||
{
|
||||
checkHierarchy(data.menuEntries(), data.id());
|
||||
checkHierarchy(data.menuEntries, data.id);
|
||||
|
||||
const auto oldEntries = m_data.menuEntries();
|
||||
const auto oldEntries = m_data.menuEntries;
|
||||
m_data = data;
|
||||
|
||||
Database::AvmMenuStruct ms;
|
||||
|
||||
// Insert Parent
|
||||
ms.parentId = 0;
|
||||
ms.name = QString::fromStdString(data.name());
|
||||
ms.isAudio = data.isAudio();
|
||||
ms.name = QString::fromStdString(data.name);
|
||||
ms.isAudio = data.isAudio;
|
||||
ms.isGroup = true;
|
||||
|
||||
DBTransaction trans(m_db->database());
|
||||
|
||||
if (m_data.id() > 0)
|
||||
if (m_data.id > 0)
|
||||
{
|
||||
ms.id = m_data.id();
|
||||
ms.id = m_data.id;
|
||||
if (!m_db->update(ms))
|
||||
return Core::FunctionReplyObject(0, tr_lts("dds", "Error inserting AvmMenuStruct-data into database"));
|
||||
}
|
||||
@@ -188,14 +188,14 @@ Core::FunctionReplyObject ObjectMenuStruct::insertUpdateDb(const MenuStruct &dat
|
||||
return Core::FunctionReplyObject(0, tr_lts("dds", "Error inserting AvmMenuStruct-data into database"));
|
||||
}
|
||||
|
||||
m_data.id(ms.id);
|
||||
const int virtualMenuStructId = data.id();
|
||||
const int realMenuStructId = m_data.id();
|
||||
m_data.id = ms.id;
|
||||
const int virtualMenuStructId = data.id;
|
||||
const int realMenuStructId = m_data.id;
|
||||
|
||||
std::vector<AvMenuEntry> newEntries;
|
||||
newEntries.reserve(data.menuEntries().size());
|
||||
newEntries.reserve(data.menuEntries.size());
|
||||
|
||||
auto ret = insertUpdateChildren(virtualMenuStructId, realMenuStructId, data.menuEntries(), newEntries);
|
||||
auto ret = insertUpdateChildren(virtualMenuStructId, realMenuStructId, data.menuEntries, newEntries);
|
||||
if (ret.error())
|
||||
return ret;
|
||||
|
||||
@@ -203,23 +203,23 @@ Core::FunctionReplyObject ObjectMenuStruct::insertUpdateDb(const MenuStruct &dat
|
||||
for (const AvMenuEntry &me : oldEntries)
|
||||
{
|
||||
// new entries - ignore
|
||||
if (me.id() <= 0)
|
||||
if (me.id <= 0)
|
||||
continue;
|
||||
|
||||
auto found = std::find_if(newEntries.begin(), newEntries.end(), [&me] (const AvMenuEntry &newEntry) { return me.id() == newEntry.id(); });
|
||||
auto found = std::find_if(newEntries.begin(), newEntries.end(), [&me] (const AvMenuEntry &newEntry) { return me.id == newEntry.id; });
|
||||
if (found == newEntries.end())
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Menu Entry with id not found - was removed: " << me.id();
|
||||
m_db->removeAvmMenuStruct(me.id());
|
||||
DEBUG_LOG(m_logger) << "Menu Entry with id not found - was removed: " << me.id;
|
||||
m_db->removeAvmMenuStruct(me.id);
|
||||
}
|
||||
}
|
||||
|
||||
m_data.menuEntries(newEntries);
|
||||
m_data.menuEntries = newEntries;
|
||||
HandlerMenuStruct::sortEntries(m_data);
|
||||
DEBUG_LOG(m_logger) << "new entries: " << m_data;
|
||||
|
||||
trans.commit();
|
||||
return Core::FunctionReplyObject(m_data.id());
|
||||
return Core::FunctionReplyObject(m_data.id);
|
||||
}
|
||||
|
||||
Core::FunctionReplyObject ObjectMenuStruct::insertUpdateChildren(int virtualParentId,
|
||||
@@ -229,7 +229,7 @@ Core::FunctionReplyObject ObjectMenuStruct::insertUpdateChildren(int virtualPare
|
||||
{
|
||||
for(const AudioVideoManagement::AvMenuEntry &ddsItem : entries)
|
||||
{
|
||||
if (ddsItem.parentId() != virtualParentId)
|
||||
if (ddsItem.parentId != virtualParentId)
|
||||
continue;
|
||||
|
||||
Database::AvmMenuStruct dbEntry = ::toDb(ddsItem, realParentId);
|
||||
@@ -250,7 +250,7 @@ Core::FunctionReplyObject ObjectMenuStruct::insertUpdateChildren(int virtualPare
|
||||
|
||||
if (dbEntry.isGroup)
|
||||
{
|
||||
const int virtualId = ddsItem.id();
|
||||
const int virtualId = ddsItem.id;
|
||||
const int realId = dbEntry.id;
|
||||
insertUpdateChildren(virtualId, realId, entries, newEntries);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user