| | |
| | | #include "SerializeUtil.h" |
| | | |
| | | static inline std::string trimCopy(std::string s) { |
| | | auto notspace = [](int ch) { return !std::isspace(ch); }; |
| | | s.erase(s.begin(), std::find_if(s.begin(), s.end(), notspace)); |
| | | s.erase(std::find_if(s.rbegin(), s.rend(), notspace).base(), s.end()); |
| | | s.erase(s.begin(), |
| | | std::find_if(s.begin(), s.end(), |
| | | [](char c) { return !std::isspace(static_cast<unsigned char>(c)); })); |
| | | s.erase(std::find_if(s.rbegin(), s.rend(), |
| | | [](char c) { return !std::isspace(static_cast<unsigned char>(c)); }).base(), |
| | | s.end()); |
| | | return s; |
| | | } |
| | | |
| | |
| | | { |
| | | m_pjs = pjs; |
| | | return true; |
| | | } |
| | | |
| | | bool CControlJob::addPjPointer(CProcessJob* pj) |
| | | { |
| | | for (auto item : m_pjs) { |
| | | if (item->id().compare(pj->id()) == 0) return false; |
| | | } |
| | | |
| | | m_pjs.push_back(pj); |
| | | return true; |
| | | } |
| | | |
| | | bool CControlJob::removePjPointer(const std::string& id) |
| | | { |
| | | for(auto iter = m_pjs.begin(); iter != m_pjs.end(); ++iter) { |
| | | if ((*iter)->id().compare(id) == 0) { |
| | | m_pjs.erase(iter); |
| | | return true; |
| | | } |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | bool CControlJob::removePJ(const std::string& pjId) { |
| | |
| | | out = CControlJob(cjId); |
| | | out.setPriority(prio); |
| | | |
| | | // 直接恢复内部状态(若你要求走状态机,可在这里按合法过渡调用 queue()/start()/...) |
| | | // 简化:直接赋值(你在 CControlJob.cpp 内部,可访问私有成员) |
| | | struct Access : CControlJob { |
| | | using CControlJob::m_state; |
| | | using CControlJob::m_failReason; |
| | | using CControlJob::m_tQueued; |
| | | using CControlJob::m_tStart; |
| | | using CControlJob::m_tEnd; |
| | | using CControlJob::m_pjIds; |
| | | }; |
| | | auto& a = reinterpret_cast<Access&>(out); |
| | | a.m_state = static_cast<CJState>(st); |
| | | a.m_failReason = std::move(failText); |
| | | a.m_tQueued = std::move(tQ); |
| | | a.m_tStart = std::move(tS); |
| | | a.m_tEnd = std::move(tE); |
| | | a.m_pjIds = std::move(pjIds); |
| | | out.m_state = static_cast<CJState>(st); |
| | | out.m_failReason = std::move(failText); |
| | | out.m_tQueued = std::move(tQ); |
| | | out.m_tStart = std::move(tS); |
| | | out.m_tEnd = std::move(tE); |
| | | out.m_pjIds = std::move(pjIds); |
| | | |
| | | return true; |
| | | } |