bool componentFollowsFromInTypeInstanceHierarchy(const CyPhyML::DesignEntity& selectedCom, const CyPhyML::DesignEntity& rootChild) { if(selectedCom == rootChild) return true; if(selectedCom.isInstance() || selectedCom.isSubtype()) { CyPhyML::DesignEntity parentType = selectedCom.Archetype(); return componentFollowsFromInTypeInstanceHierarchy(parentType, rootChild); } return false; }
void CDSERootSelDialog::FillDSETree(CyPhyML::DesignContainer &cyphy_con, HTREEITEM parent) { std::string iname = (std::string)cyphy_con.name() + " [" + (std::string)cyphy_con.ContainerType()+"]"; HTREEITEM dse_node = m_dstree.InsertItem(utf82cstring(iname.c_str()), parent, TVI_LAST); dseTreeMap[dse_node] = cyphy_con; set<CyPhyML::DesignEntity> entities = cyphy_con.DesignEntity_kind_children(); for(set<CyPhyML::DesignEntity>::iterator i=entities.begin();i!=entities.end();++i) { CyPhyML::DesignEntity entity = *i; if(!Uml::IsDerivedFrom(entity.type(), CyPhyML::DesignContainer::meta)) continue; FillDSETree((CyPhyML::DesignContainer::Cast(entity)), dse_node); } m_dstree.SortChildren(dse_node); m_dstree.Expand(dse_node,TVE_EXPAND); }
void traverseContainerForMorphMatrix(CyPhyML::DesignContainer &container, MorphMatrix& morphMatrix, set<CyPhyML::DesignEntity>& allEntities) { set<CyPhyML::DesignEntity> entities = container.DesignEntity_kind_children(); // First, populate the Morph Matrix set<CyPhyML::DesignEntity>* curEntities = 0; MorphMatrix::iterator pos; try { pos = morphMatrix.find(config); } catch (...) { // shouldn't normally occur pos = morphMatrix.end(); } if(pos==morphMatrix.end()) { curEntities = new set<CyPhyML::DesignEntity>(); // FIXME: need to delete this morphMatrix.insert(MorphMatrix::value_type(config, curEntities)); } else { curEntities = morphMatrix[config]; } // Continue with configurations if((std::string)container.ContainerType()!="Compound") { map<int, int>::iterator pos = alternativeMap.find(container.ID()); if(pos==alternativeMap.end()) return; //get object by id int altId = (*pos).second; if(altId<=0) return; CyPhyML::DesignEntity selectedCom; for(set<CyPhyML::DesignEntity>::iterator i=entities.begin();i!=entities.end();++i) { if((*i).ID() == altId) { selectedCom = *i; break; } } if(selectedCom == Udm::null) { char buffer[10]; _itoa(altId, buffer, 10); std::string err = "Cannot find the Component with ID: "+(std::string)buffer+" in DesignContainer: "+(std::string)container.name(); throw udm_exception(err.c_str()); } addSelectedEntity(allEntities, curEntities, selectedCom, container); //if(Uml::IsDerivedFrom(selectedCom.type(), CyPhyML::DesignContainer::meta)) if((std::string)selectedCom.type().name()=="DesignContainer") { traverseContainerForMorphMatrix(CyPhyML::DesignContainer::Cast(selectedCom), morphMatrix, allEntities); } } else { for(set<CyPhyML::DesignEntity>::iterator i=entities.begin();i!=entities.end();++i) { const CyPhyML::DesignEntity &com = *i; addSelectedEntity(allEntities, curEntities, com, container); //if(Uml::IsDerivedFrom(com.type(), CyPhyML::DesignContainer::meta)) if((std::string)com.type().name()=="DesignContainer") { traverseContainerForMorphMatrix(CyPhyML::DesignContainer::Cast(com), morphMatrix, allEntities); } } } }