// Prints a message to a given node. void GameNode::print(char* szText, short nColor, short nNewlines, short nType) { OutputData odMessage; char szBuffer[250]; // Need to convert szText to an output message. odMessage.szMessage[0] = '\0'; if ( szText != NULL ) { if ( strlen(szText) >= 200 - 2*nNewlines ) szText[199 - 2*nNewlines] = '\0'; strcpy(odMessage.szMessage, szText); } // Add the specified number of newlines (1 by default) for ( short n = 0; n < nNewlines; n++ ) { strcat(odMessage.szMessage, "\r\n"); } // Set the message color, type, and player stat info odMessage.nColor = nColor; odMessage.nType = nType; fillStats(&odMessage); // Send the message to the slot, after converting it to a string. sendToSlot(hOutputSlot, odMessage.toString(szBuffer)); }
void InternalPortModel::updateInputPortColor(void) { if((type == INPUTD) && input && (string(input->getName()) != "*")) { strColor = COLOR_NOMAL; if(!destinationArrows.size()) strColor = (input->isRequired()) ? COLOR_WARNING : COLOR_NOMAL; else { std::vector<ArrowModel*>::iterator itr; for(itr=destinationArrows.begin(); itr<destinationArrows.end(); itr++) if((*itr)->getSource() && Glib::RefPtr<InternalPortModel>::cast_dynamic((*itr)->getSource())) { OutputData* outp = Glib::RefPtr<InternalPortModel>::cast_dynamic((*itr)->getSource())->getOutput(); if(outp && !compareString(outp->getName(), input->getName())) { strColor = COLOR_MISMATCH; break; } } } poly->property_fill_color().set_value(strColor.c_str()); } }
OutputData process(bool const & stop, ThreadData & /*data*/) { OutputData resultObject; int value; m_stop = stop; while (CloudI::API::return_value::timeout == (value = m_api.poll(1000))) { if (stop) return resultObject.setError( CloudI::API::return_value::success); } return resultObject.setError(value); }
OutputData process(bool const & stop, ThreadData & /*data*/) { OutputData resultObject; int value; m_stop = stop; // a return from this Input object function, provides // a single OutputData object (with the error value) to the // single shared Output object, which will then cause the // thread pool to use the exit() function // (m_stop is set to true in all threads, // so all threads are asked to abort their processing) while (CloudI::API::return_value::timeout == (value = m_api.poll(1000))) { if (stop) return resultObject.setError( CloudI::API::return_value::success); } return resultObject.setError(value); }
ArrowModel::ArrowModel(ApplicationWindow* parentWnd, Glib::RefPtr<PortModel> src, Glib::RefPtr<PortModel> dest, Connection* con, ApplicationModel* appModel, bool nullArw): PolylineModel(0,0,0,0), connection(NULL, NULL) { parentWindow = parentWnd; source = src; destination = dest; selected = false; bExist = false; bNullArrow = nullArw; applicationModel = appModel; bNested = (applicationModel != NULL); if(appModel) application = appModel->getApplication(); else application = parentWindow->manager.getKnowledgeBase()->getApplication(); if(con) { strLabel = con->carrier(); connection = *con; } this->property_close_path().set_value(false); this->property_line_width().set_value(ARROW_LINEWIDTH); this->property_arrow_width().set_value(5.0); if(!bNullArrow) this->property_end_arrow().set_value(true); if(bNested) { defaultColor = "#555555"; //GooCanvasLineDash *dash = goo_canvas_line_dash_new (ARROW_LINEWIDTH, 3.0, 3.0); //g_object_set(this->gobj(), "line-dash", dash, NULL); } else defaultColor = "black"; source->addSourceArrow(this); destination->addDestinationArrow(this); if(!bNullArrow) { string strCarrier = strLabel; string dummyLabel; //Adding connection if(application) { string strFrom, strTo; Glib::RefPtr<InternalPortModel> intPort; Glib::RefPtr<ExternalPortModel> extPort; Glib::RefPtr<PortArbitratorModel> arbPort; Module* module; InputData* input = NULL; OutputData* output = NULL; bool bExternFrom = false; bool bExternTo = false; // port arbitrator at the destination arbPort = Glib::RefPtr<PortArbitratorModel>::cast_dynamic(destination); // source intPort = Glib::RefPtr<InternalPortModel>::cast_dynamic(source); if(intPort) { output = intPort->getOutput(); module = (Module*) output->owner(); strFrom = string(module->getPrefix()) + string(intPort->getOutput()->getPort()); dummyLabel = string(intPort->getOutput()->getPort()); if(!strCarrier.size()) { strCarrier = intPort->getOutput()->getCarrier(); if(arbPort) strCarrier += "+recv.priority"; } } else { extPort = Glib::RefPtr<ExternalPortModel>::cast_dynamic(source); strFrom = extPort->getPort(); dummyLabel = string(extPort->getPort()); if(!strCarrier.size() && arbPort) strCarrier = "udp+recv.priority"; bExternFrom = true; } // destination intPort = Glib::RefPtr<InternalPortModel>::cast_dynamic(destination); if(intPort) { input = intPort->getInput(); module = (Module*) input->owner(); strTo = string(module->getPrefix()) + string(intPort->getInput()->getPort()); dummyLabel += string(" -> ") + string(intPort->getInput()->getPort()) + string(" "); if(!strCarrier.size()) { strCarrier = intPort->getInput()->getCarrier(); if(arbPort) strCarrier += "+recv.priority"; } } else if(arbPort) { intPort = Glib::RefPtr<InternalPortModel>::cast_dynamic(arbPort->getPortModel()); extPort = Glib::RefPtr<ExternalPortModel>::cast_dynamic(arbPort->getPortModel()); if(intPort) { input = intPort->getInput(); module = (Module*) input->owner(); strTo = string(module->getPrefix()) + string(intPort->getInput()->getPort()); dummyLabel += string(" -> ") + string(intPort->getInput()->getPort()) + string(" "); if(!strCarrier.size()) { strCarrier = intPort->getInput()->getCarrier(); strCarrier += "+recv.priority"; } } else { strTo = extPort->getPort(); dummyLabel += string(" -> ") + string(extPort->getPort()) + string(" "); bExternTo = true; if(!strCarrier.size()) strCarrier = "udp+recv.priority"; } } else { extPort = Glib::RefPtr<ExternalPortModel>::cast_dynamic(destination); strTo = extPort->getPort(); dummyLabel += string(" -> ") + string(extPort->getPort()) + string(" "); bExternTo = true; if(!strCarrier.size()) strCarrier = "udp"; } connection.setFrom(strFrom.c_str()); connection.setTo(strTo.c_str()); connection.setCarrier(strCarrier.c_str()); connection.setFromExternal(bExternFrom); connection.setToExternal(bExternTo); connection.setCorOutputData(output); connection.setCorInputData(input); connection.setModel(this); connection = parentWindow->manager.getKnowledgeBase()->addConnectionToApplication(application, connection); tool = TooltipModel::create(parentWindow, dummyLabel.c_str()); } strLabel = strCarrier; this->property_stroke_color().set_value(defaultColor.c_str()); if(strLabel.size()) label = LabelModel::create(parentWindow, this, strLabel.c_str()); else label = LabelModel::create(parentWindow, this, strCarrier.c_str()); // if it is an auxilary connections /* if((strLabel.find("virtual") != std::string::npos) || (strLabel.find("auxiliary") != std::string::npos) ) { GooCanvasLineDash *dash = goo_canvas_line_dash_new (ARROW_LINEWIDTH, 3.0, 3.0); g_object_set(this->gobj(), "line-dash", dash, NULL); } */ if(bNested) { applicationModel->add_child(label); label->property_visibility().set_value(Goocanvas::ITEM_HIDDEN); } else parentWindow->getRootModel()->add_child(label); label->raise(); showLabel(parentWindow->m_showLabel); } Gdk::Point pt1 = source->getContactPoint(this); Gdk::Point pt2 = destination->getContactPoint(this); setPoint(0, pt1.get_x(), pt1.get_y()-ARROW_LINEWIDTH/2.0); Goocanvas::Points points = this->property_points().get_value(); setPoint(points.get_num_points()-1, pt2.get_x(), pt2.get_y()-ARROW_LINEWIDTH/2.0); setLabel(strLabel.c_str()); updatCoordiantes(); //printf("%s : %d\n", __FILE__, __LINE__); }
Module* XmlModLoader::parsXml(const char* szFile) { module.clear(); ErrorLogger* logger = ErrorLogger::Instance(); TiXmlDocument doc(szFile); if(!doc.LoadFile()) { OSTRINGSTREAM err; err<<"Syntax error while loading "<<szFile<<" at line "\ <<doc.ErrorRow()<<": "; err<<doc.ErrorDesc(); logger->addError(err); return nullptr; } /* retrieving root module */ TiXmlElement *root = doc.RootElement(); if(!root) { OSTRINGSTREAM err; err<<"Syntax error while loading "<<szFile<<" . "; err<<"No root element."; logger->addError(err); return nullptr; } if(!compareString(root->Value(), "module")) { /* OSTRINGSTREAM msg; msg<<szFile<<" is not a module descriptor file."; logger->addWarning(msg); */ return nullptr; } /* retrieving name */ auto* name = (TiXmlElement*) root->FirstChild("name"); if(!name || !name->GetText()) { OSTRINGSTREAM err; err<<"Module from "<<szFile<<" has no name."; logger->addError(err); //return NULL; } for(TiXmlElement* var = root->FirstChildElement("var"); var; var = var->NextSiblingElement()) { if(var->Attribute("name") && var->GetText()) { parser->addVariable(var->Attribute("name"), var->GetText()); } } module.setXmlFile(szFile); if(name) module.setName(parser->parseText(name->GetText()).c_str()); /* retrieving description */ TiXmlElement* desc; if((desc = (TiXmlElement*) root->FirstChild("description"))) module.setDescription(parser->parseText(desc->GetText()).c_str()); /* retrieving version */ TiXmlElement* ver; if((ver = (TiXmlElement*) root->FirstChild("version"))) module.setVersion(parser->parseText(ver->GetText()).c_str()); /* retrieving parameter */ TiXmlElement* arguments; if((arguments = (TiXmlElement*) root->FirstChild("arguments"))) for(TiXmlElement* param = arguments->FirstChildElement(); param; param = param->NextSiblingElement()) { if(compareString(param->Value(), "param")) { if(param->GetText()) { bool brequired = false; if(compareString(param->Attribute("required"), "yes")) brequired = true; Argument arg(parser->parseText(param->GetText()).c_str(), brequired, param->Attribute("desc")); arg.setDefault(param->Attribute("default")); module.addArgument(arg); } } else if(compareString(param->Value(), "switch")) { if(param->GetText()) { bool brequired = false; if(compareString(param->Attribute("required"), "yes")) brequired = true; Argument arg(parser->parseText(param->GetText()).c_str(), brequired, param->Attribute("desc"), true); arg.setDefault(param->Attribute("default")); module.addArgument(arg); } } else { OSTRINGSTREAM war; war<<"Unrecognized tag from "<<szFile<<" at line "\ <<param->Row()<<"."; logger->addWarning(war); } } /* retrieving rank */ TiXmlElement* rank; if((rank = (TiXmlElement*) root->FirstChild("rank")) && rank->GetText()) module.setRank(atoi(parser->parseText(rank->GetText()).c_str())); /* retrieving authors information*/ TiXmlElement* authors; if((authors = (TiXmlElement*) root->FirstChild("authors"))) for(TiXmlElement* ath = authors->FirstChildElement(); ath; ath = ath->NextSiblingElement()) { if(compareString(ath->Value(), "author")) { Author author; if(ath->GetText()) author.setName(parser->parseText(ath->GetText()).c_str()); if(ath->Attribute("email")) author.setEmail(ath->Attribute("email")); module.addAuthor(author); } else { OSTRINGSTREAM war; war<<"Unrecognized tag from "<<szFile<<" at line "\ <<ath->Row()<<"."; logger->addWarning(war); } } /* retrieving data */ if(root->FirstChild("data")) for(TiXmlElement* data = root->FirstChild("data")->FirstChildElement(); data; data = data->NextSiblingElement()) { /* output data */ if(compareString(data->Value(), "output")) { OutputData output; if(compareString(data->Attribute("port_type"), "stream") || !data->Attribute("port_type")) output.setPortType(STREAM_PORT); else if(compareString(data->Attribute("port_type"), "event")) output.setPortType(EVENT_PORT); else if(compareString(data->Attribute("port_type"), "service")) output.setPortType(SERVICE_PORT); else { OSTRINGSTREAM war; war<<"Unknown port type \'"<<data->Attribute("port_type")<<"\' from "<<szFile<<" at line "\ <<data->Row()<<". Available types : stream, event, service"; logger->addWarning(war); } TiXmlElement* element; if(output.getPortType() != SERVICE_PORT ) { if((element = (TiXmlElement*) data->FirstChild("type"))) output.setName(parser->parseText(element->GetText()).c_str()); else { OSTRINGSTREAM war; war<<"Output data from "<<szFile<<" at line "\ <<data->Row()<<" has no type."; logger->addWarning(war); } } else output.setName("*"); if((element = (TiXmlElement*) data->FirstChild("port"))) { output.setPort(parser->parseText(element->GetText()).c_str()); output.setCarrier(element->Attribute("carrier")); } else { OSTRINGSTREAM war; war<<"Output data from "<<szFile<<" at line "\ <<data->Row()<<" has no port."; logger->addWarning(war); } if((element = (TiXmlElement*) data->FirstChild("description"))) output.setDescription(parser->parseText(element->GetText()).c_str()); module.addOutput(output); } // end of output data /* input data */ if(compareString(data->Value(), "input")) { InputData input; if(compareString(data->Attribute("port_type"), "stream") || !data->Attribute("port_type")) input.setPortType(STREAM_PORT); else if(compareString(data->Attribute("port_type"), "event")) input.setPortType(EVENT_PORT); else if(compareString(data->Attribute("port_type"), "service")) input.setPortType(SERVICE_PORT); else { OSTRINGSTREAM war; war<<"Unknown port type \'"<<data->Attribute("port_type")<<"\' from "<<szFile<<" at line "\ <<data->Row()<<". Available types : stream, event, service"; logger->addWarning(war); } TiXmlElement* element; if(input.getPortType() != SERVICE_PORT ) { if((element = (TiXmlElement*) data->FirstChild("type"))) input.setName(parser->parseText(element->GetText()).c_str()); else { OSTRINGSTREAM war; war<<"Input data from "<<szFile<<" at line "\ <<data->Row()<<" has no type."; logger->addWarning(war); } } else input.setName("rpc"); if((element = (TiXmlElement*) data->FirstChild("port"))) { input.setPort(parser->parseText(element->GetText()).c_str()); input.setCarrier(element->Attribute("carrier")); } else { OSTRINGSTREAM war; war<<"Input data from "<<szFile<<" at line "\ <<data->Row()<<" has no port."; logger->addWarning(war); } if((element = (TiXmlElement*) data->FirstChild("description"))) input.setDescription(parser->parseText(element->GetText()).c_str()); if((element = (TiXmlElement*) data->FirstChild("required"))) if(compareString(parser->parseText(element->GetText()).c_str(), "yes")) input.setRequired(true); if((element = (TiXmlElement*) data->FirstChild("priority"))) if(compareString(parser->parseText(element->GetText()).c_str(), "yes")) input.setPriority(true); module.addInput(input); } // end of input data } if(root->FirstChild("services")) { for(TiXmlElement* services = root->FirstChild("services")->FirstChildElement(); services; services = services->NextSiblingElement()) { /* server */ if(compareString(services->Value(), "server")) { InputData input; input.setPortType(SERVICE_PORT); TiXmlElement* element; if((element = (TiXmlElement*) services->FirstChild("port"))) { input.setPort(parser->parseText(element->GetText()).c_str()); input.setCarrier("tcp"); } if((element = (TiXmlElement*) services->FirstChild("description"))) input.setDescription(parser->parseText(element->GetText()).c_str()); if((element = (TiXmlElement*) services->FirstChild("type"))) input.setName(parser->parseText(element->GetText()).c_str()); else input.setName("rpc"); module.addInput(input); } /* client */ if(compareString(services->Value(), "client")) { OutputData output; output.setPortType(SERVICE_PORT); TiXmlElement* element; if((element = (TiXmlElement*) services->FirstChild("port"))) { output.setPort(parser->parseText(element->GetText()).c_str()); output.setCarrier("tcp"); } if((element = (TiXmlElement*) services->FirstChild("description"))) output.setDescription(parser->parseText(element->GetText()).c_str()); if((element = (TiXmlElement*) services->FirstChild("type"))) output.setName(parser->parseText(element->GetText()).c_str()); else output.setName("rpc"); module.addOutput(output); } } } /* retrieving broker*/ TiXmlElement* element; if((element = (TiXmlElement*) root->FirstChild("deployer"))) { module.setBroker(parser->parseText(element->GetText()).c_str()); module.setNeedDeployer(true); } /* retrieving dependencies*/ if(root->FirstChild("dependencies")) for(TiXmlElement* restag = root->FirstChild("dependencies")->FirstChildElement(); restag; restag = restag->NextSiblingElement()) { Computer computer; if(compareString(restag->Value(), "computer")) { Computer computer; computer.setXmlFile(szFile); for(TiXmlElement* comptag = restag->FirstChildElement(); comptag; comptag = comptag->NextSiblingElement()) { /* retrieving name */ if(compareString(comptag->Value(), "name")) computer.setName(parser->parseText(comptag->GetText()).c_str()); /* retrieving description */ if(compareString(comptag->Value(), "description")) computer.setDescription(parser->parseText(comptag->GetText()).c_str()); // platform if(compareString(comptag->Value(), "platform")) { Platform os; TiXmlElement* element; if((element = (TiXmlElement*) comptag->FirstChild("name"))) os.setName(parser->parseText(element->GetText()).c_str()); if((element = (TiXmlElement*) comptag->FirstChild("distribution"))) os.setDistribution(parser->parseText(element->GetText()).c_str()); if((element = (TiXmlElement*) comptag->FirstChild("release"))) os.setRelease(parser->parseText(element->GetText()).c_str()); computer.setPlatform(os); } // end of platform tag /* //multiplatform if(compareString(comptag->Value(), "multiplatform")) { MultiPlatform mltPlatform; for(TiXmlElement* mptag = comptag->FirstChild("multiplatform")->FirstChildElement(); mptag; mptag = mptag->NextSiblingElement()) { // platform if(compareString(mptag->Value(), "platform")) { Platform os; TiXmlElement* element; if((element = (TiXmlElement*) mptag->FirstChild("name"))) os.setName(element->GetText()); if((element = (TiXmlElement*) mptag->FirstChild("distribution"))) os.setDistribution(element->GetText()); if((element = (TiXmlElement*) mptag->FirstChild("release"))) os.setDistribution(element->GetText()); mltPlatform.addPlatform(os); } } module.addResource(mltPlatform); } // end of multiplatform tag */ // memory if(compareString(comptag->Value(), "memory")) { Memory mem; TiXmlElement* element; if((element = (TiXmlElement*) comptag->FirstChild("total_space"))) mem.setTotalSpace((Capacity)atol(parser->parseText(element->GetText()).c_str())); if((element = (TiXmlElement*) comptag->FirstChild("free_space"))) mem.setFreeSpace((Capacity)atol(parser->parseText(element->GetText()).c_str())); computer.setMemory(mem); } // end of memory tag // storage if(compareString(comptag->Value(), "storage")) { Storage stg; TiXmlElement* element; if((element = (TiXmlElement*) comptag->FirstChild("total_space"))) stg.setTotalSpace((Capacity)atol(parser->parseText(element->GetText()).c_str())); if((element = (TiXmlElement*) comptag->FirstChild("free_space"))) stg.setFreeSpace((Capacity)atol(parser->parseText(element->GetText()).c_str())); computer.setStorage(stg); } // end of storage tag // processor if(compareString(comptag->Value(), "processor")) { Processor proc; TiXmlElement* element; if((element = (TiXmlElement*) comptag->FirstChild("architecture"))) proc.setArchitecture(parser->parseText(element->GetText()).c_str()); if((element = (TiXmlElement*) comptag->FirstChild("model"))) proc.setModel(parser->parseText(element->GetText()).c_str()); if((element = (TiXmlElement*) comptag->FirstChild("cores"))) proc.setCores((size_t)atoi(parser->parseText(element->GetText()).c_str())); if((element = (TiXmlElement*) comptag->FirstChild("siblings"))) proc.setSiblings((size_t)atoi(parser->parseText(element->GetText()).c_str())); if((element = (TiXmlElement*) comptag->FirstChild("frequency"))) proc.setFrequency(atof(parser->parseText(element->GetText()).c_str())); computer.setProcessor(proc); } // end of processor tag // network if(compareString(comptag->Value(), "network")) { Network net; TiXmlElement* element; if((element = (TiXmlElement*) comptag->FirstChild("ip4"))) net.setIP4(parser->parseText(element->GetText()).c_str()); if((element = (TiXmlElement*) comptag->FirstChild("ip6"))) net.setIP6(parser->parseText(element->GetText()).c_str()); if((element = (TiXmlElement*) comptag->FirstChild("mac"))) net.setMAC(parser->parseText(element->GetText()).c_str()); module.addResource(net); computer.setNetwork(net); } // end of network tag // yarp_port if(compareString(comptag->Value(), "yarp_port")) { ResYarpPort yport; auto* element = (TiXmlElement*) comptag->FirstChild("name"); if(element && element->GetText()) { yport.setName(parser->parseText(element->GetText()).c_str()); yport.setPort(parser->parseText(element->GetText()).c_str()); computer.addPeripheral(yport); } else { OSTRINGSTREAM war; war<<"yarp_port from "<<szFile<<" at line " <<comptag->Row()<<" has no name."; logger->addWarning(war); } } // gpu if(compareString(comptag->Value(), "gpu")) { GPU gpu; TiXmlElement* element; if((element = (TiXmlElement*) comptag->FirstChild("name"))) gpu.setName(parser->parseText(element->GetText()).c_str()); if((element = (TiXmlElement*) comptag->FirstChild("capability"))) gpu.setCompCompatibility(parser->parseText(element->GetText()).c_str()); if((element = (TiXmlElement*) comptag->FirstChild("cores"))) gpu.setCores((size_t)atoi(parser->parseText(element->GetText()).c_str())); if((element = (TiXmlElement*) comptag->FirstChild("frequency"))) gpu.setFrequency(atof(parser->parseText(element->GetText()).c_str())); if((element = (TiXmlElement*) comptag->FirstChild("register_block"))) gpu.setResgisterPerBlock((size_t)atoi(parser->parseText(element->GetText()).c_str())); if((element = (TiXmlElement*) comptag->FirstChild("thread_block"))) gpu.setThreadPerBlock((size_t)atoi(parser->parseText(element->GetText()).c_str())); if((element = (TiXmlElement*) comptag->FirstChild("overlap"))) { if(compareString(parser->parseText(element->GetText()).c_str(), "yes")) gpu.setOverlap(true); else gpu.setOverlap(false); } // global memory if(comptag->FirstChild("global_memory")) { TiXmlElement* element; element = (TiXmlElement*) comptag->FirstChild("global_memory"); if((element = (TiXmlElement*) element->FirstChild("total_space"))) gpu.setGlobalMemory((Capacity)atol(parser->parseText(element->GetText()).c_str())); } // end of global memory tag // shared memory if(comptag->FirstChild("shared_memory")) { TiXmlElement* element; element = (TiXmlElement*) comptag->FirstChild("shared_memory"); if((element = (TiXmlElement*) element->FirstChild("total_space"))) gpu.setSharedMemory((Capacity)atol(parser->parseText(element->GetText()).c_str())); } // end of shared memory tag // constant memory if(comptag->FirstChild("constant_memory")) { TiXmlElement* element; element = (TiXmlElement*) comptag->FirstChild("constant_memory"); if((element = (TiXmlElement*) element->FirstChild("total_space"))) gpu.setConstantMemory((Capacity)atol(parser->parseText(element->GetText()).c_str())); } // end of shared memory tag computer.addPeripheral(gpu); } // end of gpu tag } // end of computer tag loop module.addResource(computer); } //end of if computer tag }// end of dependecnies tag return &module; }
void ModuleWindow::updateWidget() { Module* m_pModule = ModuleWindow::m_pModule; m_refTreeModel->clear(); Gtk::TreeModel::Row row; Gtk::TreeModel::Row childrow; Gtk::TreeModel::Row cchildrow; row = *(m_refTreeModel->append()); row[m_Columns.m_col_name] = "Name"; row[m_Columns.m_col_value] = m_pModule->getName(); row = *(m_refTreeModel->append()); row[m_Columns.m_col_name] = "Version"; row[m_Columns.m_col_value] = m_pModule->getVersion(); row = *(m_refTreeModel->append()); row[m_Columns.m_col_name] = "Description"; row[m_Columns.m_col_value] = m_pModule->getDescription(); row = *(m_refTreeModel->append()); row[m_Columns.m_col_name] = "Parameters"; row[m_Columns.m_col_value] = ""; for(int i=0; i<m_pModule->argumentCount(); i++) { childrow = *(m_refTreeModel->append(row.children())); childrow[m_Columns.m_col_name] = m_pModule->getArgumentAt(i).getParam(); childrow[m_Columns.m_col_value] = m_pModule->getArgumentAt(i).getDescription(); } row = *(m_refTreeModel->append()); row[m_Columns.m_col_name] = "Authors"; row[m_Columns.m_col_value] = ""; for(int i=0; i<m_pModule->authorCount(); i++) { childrow = *(m_refTreeModel->append(row.children())); childrow[m_Columns.m_col_name] = m_pModule->getAuthorAt(i).getName(); childrow[m_Columns.m_col_value] = m_pModule->getAuthorAt(i).getEmail(); } row = *(m_refTreeModel->append()); row[m_Columns.m_col_name] = "Inputs"; row[m_Columns.m_col_value] = ""; for(int i=0; i<m_pModule->inputCount(); i++) { InputData in = m_pModule->getInputAt(i); childrow = *(m_refTreeModel->append(row.children())); childrow[m_Columns.m_col_name] = "Type"; childrow[m_Columns.m_col_value] = in.getName(); cchildrow = *(m_refTreeModel->append(childrow.children())); cchildrow[m_Columns.m_col_name] = "Port"; cchildrow[m_Columns.m_col_value] = in.getPort(); cchildrow = *(m_refTreeModel->append(childrow.children())); cchildrow[m_Columns.m_col_name] = "Description"; cchildrow[m_Columns.m_col_value] = in.getDescription(); childrow = *(m_refTreeModel->append(childrow.children())); childrow[m_Columns.m_col_name] = "Required"; childrow[m_Columns.m_col_value] = (in.isRequired())?"Yes":"No"; } row = *(m_refTreeModel->append()); row[m_Columns.m_col_name] = "Outputs"; row[m_Columns.m_col_value] = ""; for(int i=0; i<m_pModule->outputCount(); i++) { OutputData out = m_pModule->getOutputAt(i); childrow = *(m_refTreeModel->append(row.children())); childrow[m_Columns.m_col_name] = "Type"; childrow[m_Columns.m_col_value] = out.getName(); cchildrow = *(m_refTreeModel->append(childrow.children())); cchildrow[m_Columns.m_col_name] = "Port"; cchildrow[m_Columns.m_col_value] = out.getPort(); cchildrow = *(m_refTreeModel->append(childrow.children())); cchildrow[m_Columns.m_col_name] = "Description"; cchildrow[m_Columns.m_col_value] = out.getDescription(); } }
void ApplicationPropertyWindow::updateApplication(const char* item, const char* value) { if(strcmp(item, "Prefix") == 0) { m_pManager->getKnowledgeBase()->setApplicationPrefix(m_pApplication, value); Application* mainApplication = m_pManager->getKnowledgeBase()->getApplication(); for(int i=0; i<m_pApplication->sucCount(); i++) { Module* module = dynamic_cast<Module*>(m_pApplication->getLinkAt(i).to()); if(module) { for(int j=0; j<module->outputCount(); j++) { OutputData *output = &module->getOutputAt(j); for(int i=0; i<mainApplication->connectionCount(); i++) { Connection con = mainApplication->getConnectionAt(i); string strOldFrom = con.from(); Connection updatedCon = con; if(con.getCorOutputData() && (con.getCorOutputData() == output)) { string strFrom = string(module->getPrefix()) + string(output->getPort()); updatedCon.setFrom(strFrom.c_str()); m_pManager->getKnowledgeBase()->updateConnectionOfApplication(mainApplication, con, updatedCon); // updating arrow's connection ArrowModel* arrow = dynamic_cast<ArrowModel*>(con.getModel()); if(arrow) { arrow->setConnection(updatedCon); // updating excitatory links from other connections Glib::RefPtr<PortArbitratorModel> arbPort = Glib::RefPtr<PortArbitratorModel>::cast_dynamic(arrow->getDestination()); if(arbPort) arbPort->updateExcitation(arrow, strOldFrom.c_str(), strFrom.c_str()); } } } } for(int j=0; j<module->inputCount(); j++) { InputData *input = &module->getInputAt(j); for(int i=0; i<mainApplication->connectionCount(); i++) { Connection con = mainApplication->getConnectionAt(i); Connection updatedCon = con; if(con.getCorInputData() && (con.getCorInputData() == input)) { string strTo = string(module->getPrefix()) + string(input->getPort()); updatedCon.setTo(strTo.c_str()); m_pManager->getKnowledgeBase()->updateConnectionOfApplication(mainApplication, con, updatedCon); // updating arrow's connection if(dynamic_cast<ArrowModel*>(con.getModel())) dynamic_cast<ArrowModel*>(con.getModel())->setConnection(updatedCon); } } } } // end of if(module) } // end of for } }
void output(OutputData & data) { if (data.error()) std::cerr << "CloudI error " << data.error() << std::endl; m_got_output = true; }
void ModulePropertyWindow::updateModule(const char* item, const char* value) { if(!m_pModule) return; // updating modules if(strcmp(item, "Node") == 0) { m_pModule->setHost(value); } else if(strcmp(item,"Stdio") == 0) { m_pModule->setStdio(value); } else if(strcmp(item, "Workdir") == 0) { m_pModule->setWorkDir(value); } else if(strcmp(item, "Prefix") == 0) { m_pModule->setBasePrefix(value); string strPrefix; Application* application = m_pManager->getKnowledgeBase()->getApplication(); if(application) { strPrefix = string(application->getPrefix()) + string(value); for(int j=0; j<m_pModule->outputCount(); j++) { OutputData *output = &m_pModule->getOutputAt(j); for(int i=0; i<application->connectionCount(); i++) { Connection con = application->getConnectionAt(i); string strOldFrom = con.from(); Connection updatedCon = con; if(con.getCorOutputData()) { if(con.getCorOutputData() == output) { string strFrom = strPrefix + string(output->getPort()); updatedCon.setFrom(strFrom.c_str()); m_pManager->getKnowledgeBase()->updateConnectionOfApplication(application, con, updatedCon); // updating arrow's connection ArrowModel* arrow = dynamic_cast<ArrowModel*>(con.getModel()); if(arrow) { arrow->setConnection(updatedCon); // updating excitatory links from other connections Glib::RefPtr<PortArbitratorModel> arbPort = Glib::RefPtr<PortArbitratorModel>::cast_dynamic(arrow->getDestination()); if(arbPort) arbPort->updateExcitation(arrow, strOldFrom.c_str(), strFrom.c_str()); } } } } } for(int j=0; j<m_pModule->inputCount(); j++) { InputData *input = &m_pModule->getInputAt(j); for(int i=0; i<application->connectionCount(); i++) { Connection con = application->getConnectionAt(i); Connection updatedCon = con; if(con.getCorInputData()) { if(con.getCorInputData() == input) { string strTo = strPrefix + string(input->getPort()); updatedCon.setTo(strTo.c_str()); m_pManager->getKnowledgeBase()->updateConnectionOfApplication(application, con, updatedCon); // updating arrow's connection if(dynamic_cast<ArrowModel*>(con.getModel())) dynamic_cast<ArrowModel*>(con.getModel())->setConnection(updatedCon); } } } } // updating module prefix. m_pManager->getKnowledgeBase()->setModulePrefix(m_pModule, strPrefix.c_str(), false); } } else if(strcmp(item, "Parameters") == 0) { m_pModule->setParam(value); } else if(strcmp(item, "Deployer") == 0) { m_pModule->setBroker(value); } }
void ModuleWindow::updateWidget() { Module* m_pModule = ModuleWindow::m_pModule; m_refTreeModel->clear(); size_t width = 20; for(int i=0; i<m_pModule->inputCount(); i++) { if(strlen(m_pModule->getInputAt(i).getPort()) > width) width = strlen(m_pModule->getInputAt(i).getPort()); } for(int i=0; i<m_pModule->outputCount(); i++) { if(strlen(m_pModule->getOutputAt(i).getPort()) > width) width = strlen(m_pModule->getOutputAt(i).getPort()); } width *= 8; Gtk::TreeModel::Row row; Gtk::TreeModel::Row childrow; Gtk::TreeModel::Row cchildrow; row = *(m_refTreeModel->append()); row[m_Columns.m_col_name] = "Name"; row[m_Columns.m_col_value] = m_pModule->getName(); row[m_Columns.m_col_width] = width; row = *(m_refTreeModel->append()); row[m_Columns.m_col_name] = "Version"; row[m_Columns.m_col_value] = m_pModule->getVersion(); row[m_Columns.m_col_width] = width; row = *(m_refTreeModel->append()); row[m_Columns.m_col_name] = "Description"; row[m_Columns.m_col_value] = m_pModule->getDescription(); row[m_Columns.m_col_width] = width; row = *(m_refTreeModel->append()); row[m_Columns.m_col_name] = "Parameters"; row[m_Columns.m_col_value] = ""; row[m_Columns.m_col_width] = width; for(int i=0; i<m_pModule->argumentCount(); i++) { childrow = *(m_refTreeModel->append(row.children())); childrow[m_Columns.m_col_name] = m_pModule->getArgumentAt(i).getParam(); childrow[m_Columns.m_col_value] = m_pModule->getArgumentAt(i).getDescription(); childrow[m_Columns.m_col_width] = width; } row = *(m_refTreeModel->append()); row[m_Columns.m_col_name] = "Authors"; row[m_Columns.m_col_value] = ""; row[m_Columns.m_col_width] = width; //char buff[64]; for(int i=0; i<m_pModule->authorCount(); i++) { childrow = *(m_refTreeModel->append(row.children())); //sprintf(buff, "%d", i+1); childrow[m_Columns.m_col_name] = m_pModule->getAuthorAt(i).getName(); childrow[m_Columns.m_col_value] = m_pModule->getAuthorAt(i).getEmail(); childrow[m_Columns.m_col_width] = width; } row = *(m_refTreeModel->append()); row[m_Columns.m_col_name] = "Inputs"; row[m_Columns.m_col_value] = ""; row[m_Columns.m_col_width] = width; for(int i=0; i<m_pModule->inputCount(); i++) { InputData in = m_pModule->getInputAt(i); childrow = *(m_refTreeModel->append(row.children())); childrow[m_Columns.m_col_name] = "Port"; childrow[m_Columns.m_col_value] = in.getPort(); childrow[m_Columns.m_col_width] = width; cchildrow = *(m_refTreeModel->append(childrow.children())); cchildrow[m_Columns.m_col_name] = "Type"; cchildrow[m_Columns.m_col_value] = in.getName(); cchildrow[m_Columns.m_col_width] = width; cchildrow = *(m_refTreeModel->append(childrow.children())); cchildrow[m_Columns.m_col_name] = "Description"; cchildrow[m_Columns.m_col_value] = in.getDescription(); cchildrow[m_Columns.m_col_width] = width; childrow = *(m_refTreeModel->append(childrow.children())); childrow[m_Columns.m_col_name] = "Required"; childrow[m_Columns.m_col_value] = (in.isRequired())?"Yes":"No"; childrow[m_Columns.m_col_width] = 200; } row = *(m_refTreeModel->append()); row[m_Columns.m_col_name] = "Outputs"; row[m_Columns.m_col_value] = ""; row[m_Columns.m_col_width] = width; for(int i=0; i<m_pModule->outputCount(); i++) { OutputData out = m_pModule->getOutputAt(i); childrow = *(m_refTreeModel->append(row.children())); childrow[m_Columns.m_col_name] = "Port"; childrow[m_Columns.m_col_value] = out.getPort(); childrow[m_Columns.m_col_width] = width; cchildrow = *(m_refTreeModel->append(childrow.children())); cchildrow[m_Columns.m_col_name] = "Type"; cchildrow[m_Columns.m_col_value] = out.getName(); cchildrow[m_Columns.m_col_width] = width; cchildrow = *(m_refTreeModel->append(childrow.children())); cchildrow[m_Columns.m_col_name] = "Description"; cchildrow[m_Columns.m_col_value] = out.getDescription(); cchildrow[m_Columns.m_col_width] = width; } }
void PropertiesTable::showModuleTab(Module *mod) { modules.clear(); disconnect(moduleProperties,SIGNAL(itemChanged(QTreeWidgetItem*,int)),this,SLOT(onModItemChanged(QTreeWidgetItem*,int))); disconnect(moduleProperties,SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)),this,SLOT(onModItemDoubleClicked(QTreeWidgetItem*,int))); currentApplication = NULL; currentModule = mod; propertiesTab->clear(); propertiesTab->addTab(moduleProperties,"Module Properties"); propertiesTab->addTab(moduleDescription,"Description"); moduleProperties->clear(); moduleDescription->clear(); appProperties->hide(); moduleProperties->show(); moduleDescription->show(); modName = new QTreeWidgetItem(moduleProperties,QStringList() << "Name" << mod->getName()); modNode = new QTreeWidgetItem(moduleProperties,QStringList() << "Node"); modStdio = new QTreeWidgetItem(moduleProperties,QStringList() << "Stdio" << mod->getStdio()); modWorkDir = new QTreeWidgetItem(moduleProperties,QStringList() << "Workdir" << mod->getWorkDir()); modPrefix = new QTreeWidgetItem(moduleProperties,QStringList() << "Prefix" << mod->getBasePrefix()); modDeployer = new QTreeWidgetItem(moduleProperties,QStringList() << "Deployer"); modParams = new QTreeWidgetItem(moduleProperties,QStringList() << "Parameters" << mod->getParam()); lastPrefix = mod->getBasePrefix(); modStdio->setFlags(modStdio->flags() | Qt::ItemIsEditable); modWorkDir->setFlags(modWorkDir->flags() | Qt::ItemIsEditable); modPrefix->setFlags(modPrefix->flags() | Qt::ItemIsEditable); moduleProperties->addTopLevelItem(modName); moduleProperties->addTopLevelItem(modNode); moduleProperties->addTopLevelItem(modStdio); moduleProperties->addTopLevelItem(modWorkDir); moduleProperties->addTopLevelItem(modPrefix); moduleProperties->addTopLevelItem(modDeployer); moduleProperties->addTopLevelItem(modParams); if(deployerCombo){ delete deployerCombo; deployerCombo = NULL; } if(nodeCombo){ delete nodeCombo; nodeCombo = NULL; } deployerCombo = new QComboBox(); nodeCombo = new QComboBox(); deployerCombo->setEditable(true); nodeCombo->setEditable(true); if(compareString(mod->getBroker(),"yarpdev")){ deployerCombo->addItem("yarpdev"); }else if(compareString(mod->getBroker(),"icubmoddev")){ deployerCombo->addItem("icubmoddev"); }else{ deployerCombo->addItem("local"); deployerCombo->addItem("yarprun"); } if(strlen(mod->getBroker())){ deployerCombo->setCurrentText(mod->getBroker()); }else if(compareString(mod->getHost(),"localhost")){ deployerCombo->setCurrentText("local"); } if(mod->getNeedDeployer()){ deployerCombo->setEditable(false); } nodeCombo->addItem(mod->getHost()); if(QString(mod->getHost()) != "localhost"){ nodeCombo->addItem("localhost"); } ResourcePContainer resources = manager->getKnowledgeBase()->getResources(); for(ResourcePIterator itr=resources.begin(); itr!=resources.end(); itr++){ Computer* comp = dynamic_cast<Computer*>(*itr); if(comp && !compareString(comp->getName(), "localhost")){ nodeCombo->addItem(comp->getName()); } } connect(nodeCombo, SIGNAL(editTextChanged(QString)), paramsSignalMapper, SLOT(map())); connect(nodeCombo, SIGNAL(currentIndexChanged(int)), paramsSignalMapper, SLOT(map())); paramsSignalMapper->setMapping(nodeCombo,nodeCombo); connect(deployerCombo, SIGNAL(editTextChanged(QString)), paramsSignalMapper, SLOT(map())); connect(deployerCombo, SIGNAL(currentIndexChanged(int)), paramsSignalMapper, SLOT(map())); paramsSignalMapper->setMapping(deployerCombo,deployerCombo); /*****************************/ // Populate paramters for(int i=0;i<mod->argumentCount();i++){ Argument a = mod->getArgumentAt(i); QTreeWidgetItem *it = new QTreeWidgetItem(modParams,QStringList() << a.getParam()); QComboBox *paramCombo = new QComboBox(); paramCombo->setEditable(true); paramCombo->addItem(a.getValue()); if(strcmp(a.getDefault(),a.getValue()) != 0 ){ paramCombo->addItem(a.getDefault()); } moduleProperties->setItemWidget(it,1,paramCombo); connect(paramCombo, SIGNAL(editTextChanged(QString)), paramsSignalMapper, SLOT(map())); connect(paramCombo, SIGNAL(currentIndexChanged(int)), paramsSignalMapper, SLOT(map())); paramsSignalMapper->setMapping(paramCombo,paramCombo); } /*****************************/ moduleProperties->setItemWidget(modDeployer,1,deployerCombo); moduleProperties->setItemWidget(modNode,1,nodeCombo); modParams->setExpanded(true); QTreeWidgetItem *nameItem = new QTreeWidgetItem(moduleDescription,QStringList() << "Name" << mod->getName()); QTreeWidgetItem *versionItem = new QTreeWidgetItem(moduleDescription,QStringList() << "Version" << mod->getVersion()); QTreeWidgetItem *descriptionItem = new QTreeWidgetItem(moduleDescription,QStringList() << "Description" << mod->getDescription()); QTreeWidgetItem *parametersItem = new QTreeWidgetItem(moduleDescription,QStringList() << "Parameters"); for(int i=0;i<mod->argumentCount();i++){ Argument a = mod->getArgumentAt(i); QTreeWidgetItem *it = new QTreeWidgetItem(parametersItem,QStringList() << a.getParam() << a.getDescription()); } QTreeWidgetItem *authorsItem = new QTreeWidgetItem(moduleDescription,QStringList() << "Authors" ); for(int i=0;i<mod->authorCount();i++){ Author a = mod->getAuthorAt(i); QTreeWidgetItem *it = new QTreeWidgetItem(authorsItem,QStringList() << a.getName() << a.getEmail()); } QTreeWidgetItem *inputsItem = new QTreeWidgetItem(moduleDescription,QStringList() << "Inputs" ); for(int i=0;i<mod->inputCount();i++){ InputData a = mod->getInputAt(i); QTreeWidgetItem *type = new QTreeWidgetItem(inputsItem,QStringList() << "Type" << a.getName()); QTreeWidgetItem *port = new QTreeWidgetItem(type,QStringList() << "Port" << a.getPort()); QTreeWidgetItem *desc = new QTreeWidgetItem(type,QStringList() << "Description" << a.getDescription()); QTreeWidgetItem *req = new QTreeWidgetItem(type,QStringList() << "Required" << (a.isRequired() ? "yes" : "no")); Q_UNUSED(port); Q_UNUSED(desc); Q_UNUSED(req); } QTreeWidgetItem *outputsItem = new QTreeWidgetItem(moduleDescription,QStringList() << "Outputs" ); for(int i=0;i<mod->outputCount();i++){ OutputData a = mod->getOutputAt(i); //TODO controllare QTreeWidgetItem *type = new QTreeWidgetItem(outputsItem,QStringList() << "Type" << a.getName()); QTreeWidgetItem *port = new QTreeWidgetItem(type,QStringList() << "Port" << a.getPort()); QTreeWidgetItem *desc = new QTreeWidgetItem(type,QStringList() << "Description" << a.getDescription()); Q_UNUSED(port); Q_UNUSED(desc); } moduleDescription->addTopLevelItem(nameItem); moduleDescription->addTopLevelItem(versionItem); moduleDescription->addTopLevelItem(descriptionItem); moduleDescription->addTopLevelItem(parametersItem); moduleDescription->addTopLevelItem(authorsItem); moduleDescription->addTopLevelItem(inputsItem); moduleDescription->addTopLevelItem(outputsItem); connect(moduleProperties,SIGNAL(itemChanged(QTreeWidgetItem*,int)),this,SLOT(onModItemChanged(QTreeWidgetItem*,int))); connect(moduleProperties,SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)),this,SLOT(onModItemDoubleClicked(QTreeWidgetItem*,int))); }
void PropertiesTable::onModItemChanged(QTreeWidgetItem *it,int col) { Qt::ItemFlags tmp = it->flags(); if (!(tmp & Qt::ItemIsEditable)) { return; } if(currentModule){ currentModule->setStdio(modStdio->text(1).toLatin1().data()); currentModule->setWorkDir(modWorkDir->text(1).toLatin1().data()); if(lastPrefix != modPrefix->text(1)){ currentModule->setBasePrefix(modPrefix->text(1).toLatin1().data()); string strPrefix; Application* application = manager->getKnowledgeBase()->getApplication(); if(application){ strPrefix = string(application->getPrefix()) + string(modPrefix->text(1).toLatin1().data()); for(int j=0; j<currentModule->outputCount(); j++){ OutputData *output = ¤tModule->getOutputAt(j); for(int i=0; i<application->connectionCount(); i++){ Connection con = application->getConnectionAt(i); //string strOldFrom = con.from(); Connection updatedCon = con; if(con.getCorOutputData()){ if(con.getCorOutputData() == output){ string strFrom = strPrefix + string(output->getPort()); updatedCon.setFrom(strFrom.c_str()); manager->getKnowledgeBase()->updateConnectionOfApplication(application, con, updatedCon); } } } } } for(int j=0; j<currentModule->inputCount(); j++){ InputData *input = ¤tModule->getInputAt(j); for(int i=0; i<application->connectionCount(); i++){ Connection con = application->getConnectionAt(i); Connection updatedCon = con; if(con.getCorInputData()){ if(con.getCorInputData() == input){ string strTo = strPrefix + string(input->getPort()); updatedCon.setTo(strTo.c_str()); manager->getKnowledgeBase()->updateConnectionOfApplication(application, con, updatedCon); } } } } manager->getKnowledgeBase()->setModulePrefix(currentModule, strPrefix.c_str(), false); } } for(int i=0;i<modules.count();i++){ Module *module = modules.at(i); if(!strcmp(module->getName(),currentModule->getName())){ module->setStdio(currentModule->getStdio()); module->setWorkDir(currentModule->getWorkDir()); } } modified(); }
bool yarp::manager::exportDotGraph(Graph& graph, const char* szFileName) { ofstream dot; dot.open(szFileName); if(!dot.is_open()) return false; dot<<"digraph G {"<<endl; dot<<"rankdir=LR;"<<endl; dot<<"ranksep=0.0;"<<endl; dot<<"nodesep=0.2;"<<endl; for(GraphIterator itr=graph.begin(); itr!=graph.end(); itr++) { switch((*itr)->getType()) { case MODULE: { Module* mod = (Module*)(*itr); dot<<"\""<<mod->getLabel()<<"\""; dot<<" [label=\""<< mod->getName()<<"\""; dot<<" shape=component, color=midnightblue, fillcolor=lightslategrey, peripheries=1, style=filled, penwidth=2];"<<endl; for(int i=0; i<mod->sucCount(); i++) { Link l = mod->getLinkAt(i); InputData* in = (InputData*)l.to(); dot<<"\""<<mod->getLabel()<<"\" -> "; dot<<"\""<<in->getLabel()<<"\""; if(!l.isVirtual()) dot<<" [label=\"\"];"<<endl; else dot<<" [label=\"\" style=dashed];"<<endl; } break; } case INPUTD: { InputData* in = (InputData*)(*itr); dot<<"\""<<in->getLabel()<<"\""; if(in->withPriority()) { dot<<" [color=red, fillcolor=lightgrey, peripheries=1, style=filled"; dot<<" label=\""<< in->getName()<<"\\n"<<in->getPort()<<"\"];"<<endl; } else { dot<<" [color=black, fillcolor=lightgrey, peripheries=1, style=filled"; dot<<" label=\""<< in->getName()<<"\\n"<<in->getPort()<<"\"];"<<endl; } for(int i=0; i<in->sucCount(); i++) { Link l = in->getLinkAt(i); OutputData* out = (OutputData*)l.to(); dot<<"\""<<in->getLabel()<<"\" -> "; dot<<"\""<<out->getLabel()<<"\""; if(!l.isVirtual()) dot<<" [label=\""<<l.weight()<<"\"];"<<endl; else dot<<" [label=\""<<l.weight()<<"\" style=dashed];"<<endl; } break; } case OUTPUTD: { OutputData* out = (OutputData*)(*itr); dot<<"\""<<out->getLabel()<<"\""; dot<<" [color=black, fillcolor=wheat, peripheries=1, style=filled"; dot<<" label=\""<< out->getName()<<"\\n"<<out->getPort()<<"\"];"<<endl; for(int i=0; i<out->sucCount(); i++) { Link l = out->getLinkAt(i); Module* mod = (Module*)l.to(); dot<<"\""<<out->getLabel()<<"\" -> "; dot<<"\""<<mod->getLabel()<<"\""; dot<<" [label=\"\" arrowhead=none];"<<endl; } break; } case APPLICATION: { Application* app = (Application*)(*itr); dot<<"\""<<app->getLabel()<<"\""; dot<<" [shape=folder, color=darkgreen, fillcolor=darkseagreen, peripheries=1, style=filled, penwidth=2"; dot<<" label=\""<<app->getLabel()<<"\""<<"];"<<endl; for(int i=0; i<app->sucCount(); i++) { Link l = app->getLinkAt(i); Module* mod = (Module*)l.to(); dot<<"\""<<app->getLabel()<<"\" -> "; dot<<"\""<<mod->getLabel()<<"\""; if(!l.isVirtual()) dot<<" [label=\"\"];"<<endl; else dot<<" [label=\"\" style=dashed];"<<endl; } break; } case RESOURCE: { GenericResource* res = (GenericResource*)(*itr); dot<<"\""<<res->getLabel()<<"\""; if(res->owner()) dot<<" [shape=rect, color=black, fillcolor=salmon, peripheries=1, style=filled "; else dot<<" [shape=house, color=maroon, fillcolor=indianred, peripheries=1, style=filled, penwidth=2"; dot<<" label=\""<<res->getName()<<"\""<<"];"<<endl; for(int i=0; i<res->sucCount(); i++) { Link l = res->getLinkAt(i); Node* prov = l.to(); dot<<"\""<<res->getLabel()<<"\" -> "; dot<<"\""<<prov->getLabel()<<"\""; dot<<" [label=\""<<l.weight()<<"\"];"<<endl; } break; } default: break; }; } dot<<GRAPH_LEGEND; dot<<"}"<<endl; dot.close(); return true; }