FOR_EACH (node,nodes) { // Adding components std::list<std::shared_ptr<PlugNode>> node_and_components; PlugNodeUtils::node_and_components(*node, node_and_components); // Build nodes and components FOR_EACH (node_and_components_iter,node_and_components) { // Scan connections for (PlugIter p_iter(node_and_components_iter->get()); p_iter; ++p_iter) { if (p_iter()->is_no_draw()) continue; // Incoming if (p_iter()->has_incoming_connection()) { if (p_iter()->incoming_connection()->is_no_draw()) continue; cr.append_undo_command(CommandParams("ConnectPlugs \"" + p_iter()->incoming_connection()->full_name() + "\" \"" + p_iter()->full_name() + "\"" )); } // Outgoing const std::vector<PlugBase*> &connections = p_iter()->outgoing_connections(); for (DTuint k = 0; k < connections.size(); ++k) { if (connections[k]->is_no_draw()) continue; cr.append_undo_command(CommandParams("ConnectPlugs \"" + p_iter()->full_name() + "\" \"" + connections[k]->full_name() + "\"" )); } } // Events for (EventIter e_iter(node_and_components_iter->get()); e_iter; ++e_iter) { if (e_iter()->is_no_draw()) continue; // Incoming const std::vector<Event*> &connections_in = e_iter()->incoming_connections(); for (DTuint k = 0; k < connections_in.size(); ++k) { if (connections_in[k]->is_no_draw()) continue; cr.append_undo_command(CommandParams("ConnectEvents \"" + connections_in[k]->full_name() + "\" \"" + e_iter()->full_name() + "\"" )); } // Outgoing const std::vector<Event*> &connections_out = e_iter()->outgoing_connections(); for (DTuint k = 0; k < connections_out.size(); ++k) { if (connections_out[k]->is_no_draw()) continue; cr.append_undo_command(CommandParams("ConnectEvents \"" + e_iter()->full_name() + "\" \"" + connections_out[k]->full_name() + "\"" )); } } } }
//main int _tmain(int argc, _TCHAR* argv[]) { if (argc > 1) CommandParams(SERVICE_NAME, argv[0], argv[1]); else { SERVICE_TABLE_ENTRY tDispatchTable[2] = { 0 }; //由于指定了SERVICE_WIN32_OWN_PROCESS, lpServiceName被忽略 tDispatchTable[0].lpServiceName = _T(""); tDispatchTable[0].lpServiceProc = (LPSERVICE_MAIN_FUNCTION)CkServiceMain::ServiceMain; tDispatchTable[1].lpServiceName = NULL; //固定 tDispatchTable[1].lpServiceProc = NULL; //固定 if (!StartServiceCtrlDispatcher(tDispatchTable)) { if (ERROR_SERVICE_ALREADY_RUNNING == ::GetLastError()) ::printf("Service is already running.\n"); return -1; } } return 0; }