#include "EntityDocks.h" #include QList> deduct_each(std::shared_ptr item) { QList> rets; auto immediate = std::make_shared(item); for (auto msg : DeduceFramework::_accept_stack) { if (msg->targetEntity() == item->entityID()) { auto enters = item->getEntryWithInType(msg->topicString()); for (auto e : enters) e(immediate, msg, rets); } } return rets; } QList> DeduceFramework::_accept_stack; void DeduceFramework::accept(const QList>& set) { _accept_stack.append(set); } #include #include void DeduceFramework::deduceBegin(std::shared_ptr ins) { auto dt = QTime::currentTime(); auto ret_list_set = QtConcurrent::blockingMapped( _entity_map.values(), deduct_each ); _accept_stack.clear(); for (auto vlist : ret_list_set) emit this->reply(vlist); auto fmsg = std::make_shared(); fmsg->reset(ins->targetEntity(), ins->sourceEntity()); fmsg->_time_consume = dt.msecsTo(QTime::currentTime()); emit this->complete(fmsg); } #include DeduceFramework::DeduceFramework() { auto mgr_e = std::make_shared(); mgr_e->append(this->shared_from_this()); this->_entity_map[mgr_e->entityID()] = mgr_e; } std::shared_ptr DeduceFramework::defaultNew() const { throw std::logic_error("The method or operation is not implemented."); } void DeduceFramework::bindEntity(uint64_t entity_id) { this->_bind_entity = entity_id; } QString DeduceFramework::name() const { return NAME(DeduceFramework); } void DeduceFramework::recoveryFrom(const QJsonObject& obj) { throw std::logic_error("The method or operation is not implemented."); } void DeduceFramework::saveTo(QJsonObject& obj) const { throw std::logic_error("The method or operation is not implemented."); } void DeduceFramework::execute(std::shared_ptr map, std::shared_ptr in, QList>& out) { } void DeduceFramework::execute(std::shared_ptr map, std::shared_ptr in, QList>& out) { auto rst = std::make_shared(); rst->reset(in->targetEntity(), in->sourceEntity()); rst->_entities_list = _entity_map.keys(); out << rst; }