diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 0000000..538db84 --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,42 @@ +{ + "version": 3, + "configurePresets": [ + { + "name": "base", + "displayName": "base preset", + "generator": "Ninja", + "binaryDir": "${sourceDir}/build-${presetName}", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug", + "CMAKE_EXPORT_COMPILE_COMMANDS": true + }, + "hidden": true + }, + { + "name": "dev", + "inherits": [ + "base" + ] + }, + { + "name": "dev-clang", + "inherits": [ + "base" + ], + "cacheVariables": { + "CMAKE_C_COMPILER": "clang", + "CMAKE_CXX_COMPILER": "clang++" + } + }, + { + "name": "dev-qt5-clang", + "inherits": [ + "base" + ], + "cacheVariables": { + "CMAKE_C_COMPILER": "clang", + "CMAKE_CXX_COMPILER": "clang++" + } + } + ] +} diff --git a/src/icecreammonitor.cc b/src/icecreammonitor.cc index 7471675..17b4ac2 100644 --- a/src/icecreammonitor.cc +++ b/src/icecreammonitor.cc @@ -190,30 +190,30 @@ bool IcecreamMonitor::handle_activity() } switch (ICECC_MSG_API_COMPAT(m->type, *m)) { - case ICECC_MSG_API_COMPAT(M_MON_GET_CS, Msg::GET_CS): + case ICECC_MSG_API_COMPAT(M_MON_GET_CS, Msg::MON_GET_CS): handle_getcs(m.get()); break; - case ICECC_MSG_API_COMPAT(M_MON_JOB_BEGIN, Msg::JOB_BEGIN): + case ICECC_MSG_API_COMPAT(M_MON_JOB_BEGIN, Msg::MON_JOB_BEGIN): handle_job_begin(m.get()); break; - case ICECC_MSG_API_COMPAT(M_MON_JOB_DONE, Msg::JOB_DONE): + case ICECC_MSG_API_COMPAT(M_MON_JOB_DONE, Msg::MON_JOB_DONE): handle_job_done(m.get()); break; case ICECC_MSG_API_COMPAT(M_END, Msg::END): std::cout << "END" << endl; checkScheduler(true); break; - case ICECC_MSG_API_COMPAT(M_MON_STATS, Msg::STATS): + case ICECC_MSG_API_COMPAT(M_MON_STATS, Msg::MON_STATS): handle_stats(m.get()); break; - case ICECC_MSG_API_COMPAT(M_MON_LOCAL_JOB_BEGIN, Msg::JOB_LOCAL_BEGIN): + case ICECC_MSG_API_COMPAT(M_MON_LOCAL_JOB_BEGIN, Msg::MON_LOCAL_JOB_BEGIN): handle_local_begin(m.get()); break; case ICECC_MSG_API_COMPAT(M_JOB_LOCAL_DONE, Msg::JOB_LOCAL_DONE): handle_local_done(m.get()); break; default: - cout << "UNKNOWN" << endl; + cout << "UNKNOWN message type " << ICECC_MSG_API_COMPAT(m->type, m->to_string()) << endl; break; } return true; @@ -222,9 +222,11 @@ bool IcecreamMonitor::handle_activity() void IcecreamMonitor::handle_getcs(Msg *_m) { MonGetCSMsg *m = dynamic_cast(_m); + assert(m); if (!m) { return; } + m_rememberedJobs[m->job_id] = Job(m->job_id, m->clientid, QString::fromStdString(m->filename), m->lang == CompileJob::Lang_C ? @@ -237,6 +239,7 @@ void IcecreamMonitor::handle_getcs(Msg *_m) void IcecreamMonitor::handle_local_begin(Msg *_m) { MonLocalJobBeginMsg *m = dynamic_cast(_m); + assert(m); if (!m) { return; } @@ -251,6 +254,7 @@ void IcecreamMonitor::handle_local_begin(Msg *_m) void IcecreamMonitor::handle_local_done(Msg *_m) { JobLocalDoneMsg *m = dynamic_cast(_m); + assert(m); if (!m) { return; } @@ -275,6 +279,7 @@ void IcecreamMonitor::handle_local_done(Msg *_m) void IcecreamMonitor::handle_stats(Msg *_m) { MonStatsMsg *m = dynamic_cast(_m); + assert(m); if (!m) { return; } @@ -302,6 +307,7 @@ void IcecreamMonitor::handle_stats(Msg *_m) void IcecreamMonitor::handle_job_begin(Msg *_m) { MonJobBeginMsg *m = dynamic_cast(_m); + assert(m); if (!m) { return; } @@ -313,6 +319,7 @@ void IcecreamMonitor::handle_job_begin(Msg *_m) } HostInfo *hostInfo = hostInfoManager()->find(m->hostid); + assert(hostInfo); if (hostInfo) hostInfo->incJobs(); @@ -326,6 +333,7 @@ void IcecreamMonitor::handle_job_begin(Msg *_m) void IcecreamMonitor::handle_job_done(Msg *_m) { MonJobDoneMsg *m = dynamic_cast(_m); + assert(m); if (!m) { return; } diff --git a/src/models/hostlistmodel.cc b/src/models/hostlistmodel.cc index 38ec20f..d9bc1c9 100644 --- a/src/models/hostlistmodel.cc +++ b/src/models/hostlistmodel.cc @@ -213,25 +213,12 @@ void HostListModel::checkNode(unsigned int hostid) } } -struct find_hostid - : public std::unary_function -{ -public: - explicit find_hostid(unsigned int hostId) - : m_hostId(hostId) {} - - bool operator()(const HostInfo &info) const - { - return info.id() == m_hostId; - } - -private: - unsigned int m_hostId; -}; - void HostListModel::removeNodeById(unsigned int hostId) { - QVector::iterator it = std::find_if(m_hostInfos.begin(), m_hostInfos.end(), find_hostid(hostId)); + auto it = std::find_if(m_hostInfos.begin(), m_hostInfos.end(), + [hostId](const HostInfo &info) { + return info.id() == hostId; + }); if (it == m_hostInfos.end()) { return; } diff --git a/src/models/joblistmodel.cc b/src/models/joblistmodel.cc index c69a9e1..5b87149 100644 --- a/src/models/joblistmodel.cc +++ b/src/models/joblistmodel.cc @@ -263,22 +263,6 @@ int JobListModel::rowCount(const QModelIndex &parent) const return m_jobs.size(); } -struct find_jobid - : public std::unary_function -{ -public: - explicit find_jobid(unsigned int jobId) - : m_jobId(jobId) {} - - bool operator()(const Job &job) const - { - return job.id == m_jobId; - } - -private: - unsigned int m_jobId; -}; - void JobListModel::slotExpireFinishedJobs() { const uint currentTime = QDateTime::currentDateTime().toSecsSinceEpoch(); @@ -309,7 +293,10 @@ void JobListModel::removeItem(const Job &job) void JobListModel::removeItemById(unsigned int jobId) { - QVector::iterator it = std::find_if(m_jobs.begin(), m_jobs.end(), find_jobid(jobId)); + QVector::iterator it = std::find_if(m_jobs.begin(), m_jobs.end(), + [jobId](const Job &job) { + return job.id == jobId; + }); int index = std::distance(m_jobs.begin(), it); beginRemoveRows(QModelIndex(), index, index); m_jobs.erase(it);