void DialogMultisave::saveMultifile() { // check whether any of the numbered files already exists QStringList existingPaths; int n = multiplicity(); for (int i=0; i<n; ++i) { const QString fname = numberedPath(i, n+1); if (QFile{fname}.exists()) existingPaths << QFileInfo{fname}.fileName(); } if (existingPaths.size()) { if (!file_dialog::confirmOverwrite( // TODO correct question text for multiple files static_cast<QWidget*>(QWidget::parent()), abbreviateList(existingPaths,7,5))) return; } // save files one by one TakesLongTime progress("save diffractograms", multiplicity(), &progressBar); for (int i=0; i<n; ++i) { const QString fname = numberedPath(i, n+1); QFile file{fname}; if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { qWarning() << "Cannot open file for writing: " << fname; return; } QTextStream stream{&file}; writeOnefile(stream, i); progress.step(); } }
int TopologicalGraph::ExpandEdges() { int nadded=0; int morig=ne(); tedge e; int i; if (!Set(tedge()).exist(PROP_MULTIPLICITY)) return 0; Prop<int> multiplicity(Set(tedge()),PROP_MULTIPLICITY); for (e=1; e<=morig; e++) {for (i=2; i<=multiplicity[e]; ++i) NewEdge(e.firsttbrin(), e.secondtbrin()); nadded+=multiplicity[e]-1; } Set(tedge()).erase(PROP_MULTIPLICITY); // add loops if (!Set(tvertex()).exist(PROP_NLOOPS)) return nadded; tvertex v; Prop<int> nloops(Set(tvertex()),PROP_NLOOPS); for (v=1; v<=nv(); ++v) for (i=1; i<=nloops[v]; ++i) {++nadded; NewEdge(v,v); } Set(tvertex()).erase(PROP_NLOOPS); return nadded; }
void UmlRelation::uml2cpp(bool) { bool composition = FALSE; switch (relationKind()) { case aGeneralisation: case aRealization: set_CppDecl("${type}"); break; case aDependency: if (stereotype() == "friend") set_CppDecl("friend " + CppSettings::classStereotype(roleType()->stereotype()) + " ${type};"); else set_CppDecl("#include in source"); break; case anAggregationByValue: case aDirectionalAggregationByValue: composition = TRUE; // no break default: { Q3CString st = CppSettings::classStereotype(parent()->stereotype()); set_CppDecl(((st == "enum") || (st == "typedef") || (st == "ignored")) ? Q3CString("") : CppSettings::relationDecl(composition, multiplicity())); } } }
void UmlRelation::uml2Python(bool) { bool composition = FALSE; switch (relationKind()) { case aGeneralisation: case aRealization: case aDependency: set_PythonDecl("${type}"); break; case anAggregationByValue: case aDirectionalAggregationByValue: composition = TRUE; // no break default: { Q3CString st = PythonSettings::classStereotype(parent()->stereotype()); if ((st == "enum") || (st == "ignored")) set_PythonDecl(""); else set_PythonDecl(PythonSettings::relationDecl(composition, multiplicity())); } } }
int SmartState::getState(const PetriNet& net, MarkVal* marking, VarVal* valuation) const{ if(stored()){ memcpy(marking, _marking, sizeof(MarkVal) * net.numberOfPlaces()); memcpy(valuation, _valuation, sizeof(VarVal) * net.numberOfVariables()); return 0; } int depth = parent()->getState(net, marking, valuation); net.fireWithoutCheck(transition(), marking, valuation, marking, valuation, multiplicity()); return depth + 1; }
std::vector<unsigned int> SmartState::trace(){ SmartState* current = this; std::vector<unsigned int> trace; while(current->parent()){ for(unsigned int i = 0; i < multiplicity(); i++) trace.push_back(current->transition()); current = current->_parent; } std::reverse(trace.begin(), trace.end()); return trace; }
void UmlActivityParameter::write(FileOut & out) { // write parameter def out.indent(); out << "<ownedParameter name=\""; out.quote(name()); out << '"'; out.id(this); write_dir(out); write_effect(out); write_flags(out); out << ">\n"; out.indent(+1); write_description_properties(out); write_multiplicity(out, multiplicity(), this); write_default_value(out, defaultValue(), this); UmlItem::write_type(out, type()); out.indent(-1); out.indent(); out << "</ownedParameter>\n"; //write parameter node out.indent(); out << "<node xmi:type=\"uml:ActivityParameterNode\" name =\""; out.quote(name()); out << '"'; out.id_prefix(this, "PARAMETER_NODE_"); if (isControlType()) out << " isControlType=\"true\""; write_ordering(out); write_selection(out); write_in_state(out); out << ">\n"; out.indent(+1); UmlItem::write_type(out, type()); const Q3PtrVector<UmlItem> ch = children(); unsigned n = ch.size(); for (unsigned i = 0; i != n; i += 1) ch[i]->write(out); out.indent(-1); out.indent(); out << "</node>\n"; unload(); }
void UmlRelation::uml2idl(bool) { switch (relationKind()) { case aGeneralisation: case aRealization: case aDependency: set_IdlDecl("${type}"); break; default: { QCString st = IdlSettings::classStereotype(parent()->stereotype()); if ((st == "enum") || (st == "typedef") || (st == "ignored")) set_IdlDecl(""); else if (st == "union") set_IdlDecl(IdlSettings::unionRelationDecl(multiplicity())); else if (st == "valuetype") set_IdlDecl(IdlSettings::valuetypeRelationDecl(multiplicity())); else set_IdlDecl(IdlSettings::relationDecl(multiplicity())); } } }
void UmlActivityObject::write(FileOut & out) { const char * k = (parent()->kind() == anActivity) ? "node" : "containedNode"; out.indent(); out << '<' << k << " xmi:type=\"uml:"; WrapperStr st = stereotype(); if (st == "datastore") out << "DataStoreNode"; else if (st == "centralBuffer") out << "CentralBufferNode"; else out << "ObjectNode"; out << "\" name=\""; out.quote(name()); out << '"'; out.id(this); if (isControlType()) out << " isControlType=\"true\""; write_ordering(out); write_selection(out); write_in_state(out); out << ">\n"; out.indent(+1); write_description_properties(out); write_multiplicity(out, multiplicity(), this); UmlItem::write_type(out, type()); const QVector<UmlItem*> ch = children(); unsigned n = ch.size(); for (unsigned i = 0; i != n; i += 1) ch[i]->write(out); write_incoming_flows(out); out.indent(-1); out.indent(); out << "</" << k << ">\n"; unload(); }
bool Wreath::monomialLess(const Monomial & first,const Monomial & second) const { bool result = false; Monomial FIRST, SECOND; vector<AdmissibleOrder *>::const_reverse_iterator w = d_ords.rbegin(); for(int m = multiplicity();m>=1;--m,++w) { FIRST = grabAtLevel(m,first); SECOND = grabAtLevel(m,second); if(FIRST!=SECOND) { result = (*w)->monomialLess(FIRST,SECOND); break; }; }; return result; };
void DialogMultisave::save() { ASSERT(multiplicity()>0); switch(currentSaveModeIdx.val()) { case 0: saveCurrent(); break; case 1: saveJointfile(); break; case 2: saveMultifile(); break; default: qFatal("impossible case %d in DialogMultisave::save()", currentSaveModeIdx.val()); } }
void UmlRelation::uml2java(bool) { switch (relationKind()) { case aGeneralisation: case aRealization: set_JavaDecl("${type}"); break; case aDependency: break; default: { QCString st = JavaSettings::classStereotype(parent()->stereotype()); set_JavaDecl(((st == "enum") || (st == "ignored")) ? QCString("") : JavaSettings::relationDecl(multiplicity())); } } }
void UmlRelation::gen_uml_decl() { if (isClassMember()) fw.write("static, "); write(visibility()); writeq(roleName()); fw.write(" : "); roleType()->write(); QByteArray s; s = defaultValue(); if (!s.isEmpty()) { if (s[0] != '=') fw.write(" = "); writeq(s); } s = multiplicity(); if (!s.isEmpty()) { fw.write(", multiplicity : "); writeq(s); } if (isDerived()) fw.write((isDerivedUnion()) ? ", derived union" : ", derived"); if (isReadOnly()) fw.write(", read only"); if (isOrdered()) fw.write(", ordered"); if (isUnique()) fw.write(", unique"); }
void UmlActivityObject::importMultiplicity(FileIn & in, Token & token, bool upper) { QCString s = token.valueOf("value"); if (!s.isEmpty() && (s != "Unspecified")) { // VP QCString m = multiplicity(); if (m.isEmpty()) m = s; else if (m != s) { if (upper) m += ".." + s; else m = s + ".." + m; } set_Multiplicity(m); } if (! token.closed()) in.finish(token.what()); }
void Spline::cutOffEdges() { uint numberOfKnots = m_knots.size(); int m = m_degree - multiplicity(lowerDomainKnotIndex()); if(m < 0) { std::cerr << "ERROR! In Spline::cutOffEdges() a negative multiplicity was recognized!" << std::endl; return; } else if(m == 0) { return; } refineAt(lowerDomainLimit(), (uint)m); if(numberOfKnots != m_knots.size()) { m_knots.erase(m_knots.begin(), m_knots.begin() + (m_degree - 1)); m_controlPoints.erase(m_controlPoints.begin(), m_controlPoints.begin() + (m_degree - 1)); } numberOfKnots = m_knots.size(); refineAt(upperDomainLimit(0.000001), m_degree); if(numberOfKnots != m_knots.size()) { m_knots.erase(m_knots.end() - m_degree, m_knots.end()); m_controlPoints.erase(m_controlPoints.end() - m_degree, m_controlPoints.end()); } checkTornToEdges(); }
template<class BASE> void pod_simulate<BASE>::init(input_map& inmap, void *gin) { std::string filename,keyword,linebuff; std::ostringstream nstr; std::istringstream instr; int i; /* Initialize base class */ /* If restart is not equal to 0, this will load DNS data */ BASE::init(inmap,gin); inmap.getwdefault(BASE::gbl->idprefix + "_groups",pod_id,0); nstr.str(""); nstr << "pod" << pod_id << "_nmodes"; if (!inmap.get(nstr.str(),nmodes)) inmap.getwdefault("nmodes",nmodes,5); nstr.clear(); vsi ugstore; ugstore.v.reference(BASE::ugbd(0).v); ugstore.s.reference(BASE::ugbd(0).s); ugstore.i.reference(BASE::ugbd(0).i); modes.resize(nmodes); for(i=0;i<nmodes;++i) { nstr.str(""); nstr << i << std::flush; filename = "mode" +nstr.str(); nstr.clear(); modes(i).v.resize(BASE::maxpst,BASE::NV); modes(i).s.resize(BASE::maxpst,BASE::sm0,BASE::NV); modes(i).i.resize(BASE::maxpst,BASE::im0,BASE::NV); BASE::ugbd(0).v.reference(modes(i).v); BASE::ugbd(0).s.reference(modes(i).s); BASE::ugbd(0).i.reference(modes(i).i); BASE::input(filename, BASE::binary); } BASE::ugbd(0).v.reference(ugstore.v); BASE::ugbd(0).s.reference(ugstore.s); BASE::ugbd(0).i.reference(ugstore.i); #ifdef POD_BDRY pod_ebdry.resize(BASE::nebd); /* Count how many boundary modes there are so we can size arrays before initializing boundaries */ /* For each mesh block that is part of this pod block need to know /* # of pod boundaries, ids, and # of pod modes for each unique id */ /* First need to know what block # I am and how many total blocks there are in this pod group */ int localid = sim::blks.allreduce_local_id(pod_id,BASE::gbl->idnum); int npodblk = sim::blks.allreduce_nmember(pod_id); Array<int,1> binfo(npodblk),binfo_recv(npodblk); binfo = 0; for (int i=0;i<BASE::nebd;++i) { /* Not going to initialize until I can resize coeffs & rsdls arrays to accomodate boundary modes */ pod_ebdry(i) = new pod_sim_edge_bdry<BASE>(*this,*BASE::ebdry(i)); keyword = pod_ebdry(i)->base.idprefix +"_pod"; inmap.getwdefault(keyword,pod_ebdry(i)->active,false); if (!pod_ebdry(i)->active) { pod_ebdry(i)->nmodes = 0; continue; } binfo(localid)++; keyword = pod_ebdry(i)->base.idprefix + "_pod_id"; inmap.getwdefault(keyword,pod_ebdry(i)->pod_id,pod_ebdry(i)->base.idnum); nstr.str(""); nstr << "bdry_pod" << pod_ebdry(i)->pod_id << "_nmodes"; if (!inmap.get(nstr.str(),pod_ebdry(i)->nmodes)) inmap.getwdefault("bdry_nmodes",pod_ebdry(i)->nmodes,nmodes); nstr.clear(); } /* Send number of pod boundaries belonging to each block of pod group */ sim::blks.allreduce(binfo.data(), binfo_recv.data(), npodblk,blocks::int_msg, blocks::sum, pod_id); /* Second thing is to pass id, nmodes for each active boundary */ /* Count # of pod_boundaries before this block and total # of pod boundaries in pod group */ int nbefore = 0; for (int i=0;i<localid;++i) { nbefore += binfo_recv(i); } int ntotal = nbefore; for (int i=localid;i<npodblk;++i) { ntotal += binfo_recv(i); } binfo.resize(ntotal*2); binfo_recv.resize(ntotal*2); nbefore *= 2; binfo = 0; for (int i=0;i<BASE::nebd;++i) { if (!pod_ebdry(i)->active) continue; binfo(nbefore++) = pod_ebdry(i)->pod_id; binfo(nbefore++) = pod_ebdry(i)->nmodes; } sim::blks.allreduce(binfo.data(), binfo_recv.data(), ntotal*2,blocks::int_msg, blocks::sum, pod_id); /* Now make a map from pod_id to number of modes & multiplicity */ std::map<int,bd_str> pod_bdry_map; tmodes = nmodes; for (int i=0;i<2*ntotal;i+=2) { if (pod_bdry_map.find(binfo_recv(i)) != pod_bdry_map.end()) { ++pod_bdry_map[binfo_recv(i)].multiplicity; } else { pod_bdry_map[binfo_recv(i)] = bd_str(); pod_bdry_map[binfo_recv(i)].multiplicity = 1; pod_bdry_map[binfo_recv(i)].nmodes = binfo_recv(i+1); tmodes += binfo_recv(i+1); } } *BASE::gbl->log << "#There are " << tmodes << " total modes on pod block " << pod_id << std::endl; multiplicity.resize(tmodes); #else tmodes = nmodes; #endif coeffs.resize(tmodes); rsdls.resize(tmodes); rsdls0.resize(tmodes); rsdls_recv.resize(tmodes); jacobian.resize(tmodes,tmodes); ipiv.resize(tmodes); #ifdef POD_BDRY /* Count total number of boundary modes */ /* and make map be an accrual of previous modes */ multiplicity = 1.0; int bindex = nmodes; for (std::map<int,bd_str>::iterator mi = pod_bdry_map.begin(); mi != pod_bdry_map.end(); ++mi) { int n = mi->second.nmodes; mi->second.nmodes = bindex; multiplicity(Range(bindex,bindex+n-1)) = mi->second.multiplicity; bindex += n; } #endif int load_coeffs; inmap.getwdefault("load_coeffs",load_coeffs,0); if (load_coeffs) { /* This is the old way */ /* This loads coefficient vector made by pod_generate for this timestep */ nstr.str(""); nstr << load_coeffs << std::flush; filename = "coeff" +nstr.str() +"_" +BASE::gbl->idprefix +".bin"; binifstream bin; bin.open(filename.c_str()); if (bin.error()) { *BASE::gbl->log << "couldn't open coefficient input file " << filename << std::endl; sim::abort(__LINE__,__FILE__,BASE::gbl->log); } bin.setFlag(binio::BigEndian,bin.readInt(1)); bin.setFlag(binio::FloatIEEE,bin.readInt(1)); /* CONSTRUCT INITIAL SOLUTION DESCRIPTION */ BASE::ug.v(Range(0,BASE::npnt-1)) = 0.; BASE::ug.s(Range(0,BASE::nseg-1)) = 0.; BASE::ug.i(Range(0,BASE::ntri-1)) = 0.; for (int l=0;l<nmodes;++l) { coeffs(l) = bin.readFloat(binio::Double); BASE::ug.v(Range(0,BASE::npnt-1)) += coeffs(l)*modes(l).v(Range(0,BASE::npnt-1)); BASE::ug.s(Range(0,BASE::nseg-1)) += coeffs(l)*modes(l).s(Range(0,BASE::nseg-1)); BASE::ug.i(Range(0,BASE::ntri-1)) += coeffs(l)*modes(l).i(Range(0,BASE::ntri-1)); } bin.close(); } else { /* THIS IS TO CHANGE THE WAY SNAPSHOT MATRIX ENTRIES ARE FORMED */ scaling.resize(BASE::NV); scaling = 1; if (inmap.getline(BASE::gbl->idprefix + "_scale_vector",linebuff) || inmap.getline("scale_vector",linebuff)) { instr.str(linebuff); for(i=0;i<BASE::NV;++i) instr >> scaling(i); } /* This is the new way */ calc_coeffs(); /* CONSTRUCT INITIAL SOLUTION DESCRIPTION */ BASE::ug.v(Range(0,BASE::npnt-1)) = 0.; BASE::ug.s(Range(0,BASE::nseg-1)) = 0.; BASE::ug.i(Range(0,BASE::ntri-1)) = 0.; for (int l=0;l<nmodes;++l) { BASE::ug.v(Range(0,BASE::npnt-1)) += coeffs(l)*modes(l).v(Range(0,BASE::npnt-1)); BASE::ug.s(Range(0,BASE::nseg-1)) += coeffs(l)*modes(l).s(Range(0,BASE::nseg-1)); BASE::ug.i(Range(0,BASE::ntri-1)) += coeffs(l)*modes(l).i(Range(0,BASE::ntri-1)); } }
void UmlRelation::write_relation_as_attribute(FileOut & out) { UmlRelation * first = side(TRUE); Q3CString s; UmlClass * base; if ((first->parent()->stereotype() == "stereotype") && (first->roleType()->stereotype() == "metaclass")) { if (this != first) return; base = first->roleType(); s = "base_" + base->name(); } else { base = 0; switch (_lang) { case Uml: s = roleName(); break; case Cpp: if (cppDecl().isEmpty()) return; s = true_name(roleName(), cppDecl()); break; default: // Java if (javaDecl().isEmpty()) return; s = true_name(roleName(), javaDecl()); } } out.indent(); out << "<ownedAttribute xmi:type=\"uml:Property\" name=\"" << s << '"'; out.id(this); if (base != 0) out.ref(first, "association", "EXT_"); else { write_visibility(out); write_scope(out); if (isReadOnly()) out << " isReadOnly=\"true\""; if (isDerived()) { out << " isDerived=\"true\""; if (isDerivedUnion()) out << " isDerivedUnion=\"true\""; } if (isOrdered()) out << " isOrdered=\"true\""; if (isUnique()) out << " isUnique=\"true\""; if (first->_assoc_class != 0) out.ref(first->_assoc_class, "association"); else out.ref(first, "association", "ASSOC_"); out << " aggregation=\""; if (this == first) { parent()->memo_relation(this); if (_gen_eclipse) { switch (relationKind()) { case anAggregation: case aDirectionalAggregation: out << "shared"; break; case anAggregationByValue: case aDirectionalAggregationByValue: out << "composite"; break; default: out << "none"; } } else out << "none"; } else if (_gen_eclipse) out << "none"; else { switch (relationKind()) { case anAggregation: case aDirectionalAggregation: out << "shared"; break; case anAggregationByValue: case aDirectionalAggregationByValue: out << "composite"; break; default: out << "none"; } } out << '"'; } out << ">\n"; out.indent(+1); out.indent(); out << "<type xmi:type=\"uml:Class\""; if (base != 0) { if (! base->propertyValue("metaclassPath", s)) s = (_uml_20) ? "http://schema.omg.org/spec/UML/2.0/uml.xml" : "http://schema.omg.org/spec/UML/2.1/uml.xml"; out << " href=\"" << s << '#' << base->name() << '"'; } else out.idref(roleType()); out << "/>\n"; write_multiplicity(out, multiplicity(), this); write_default_value(out, defaultValue(), this); write_constraint(out); write_annotation(out); write_description_properties(out); out.indent(-1); out.indent(); out << "</ownedAttribute>\n"; unload(); }
void UmlAttribute::generate_def(QTextOStream & f, Q3CString indent, bool h, Q3CString templates, Q3CString cl_names, Q3CString, Q3CString) { if (isClassMember() && !cppDecl().isEmpty()) { UmlClass * cl = (UmlClass *) parent(); if ((!templates.isEmpty() || ((cl->name().find('<') != -1))) ? h : !h) { const char * p = cppDecl(); const char * pp = 0; while ((*p == ' ') || (*p == '\t')) p += 1; bool re_template = !templates.isEmpty() && insert_template(p, f, indent, templates); if (*p != '#') f << indent; const char * pname = name_spec(p); for (;;) { if (*p == 0) { if (pp == 0) break; // comment management done p = pp; pp = 0; if (re_template) f << templates; if (*p == 0) break; f << indent; } if (*p == '\n') { f << *p++; if (*p && (*p != '#')) f << indent; } else if (*p == '@') manage_alias(p, f); else if (*p != '$') { if (p == pname) f << cl_names << "::"; f << *p++; } else if (!strncmp(p, "${comment}", 10)) { if (!manage_comment(p, pp, CppSettings::isGenerateJavadocStyleComment()) && re_template) f << templates; } else if (!strncmp(p, "${description}", 14)) { if (!manage_description(p, pp) && re_template) f << templates; } else if (!strncmp(p, "${name}", 7)) { if (*pname == '$') f << cl_names << "::"; p += 7; f << name(); } else if (!strncmp(p, "${multiplicity}", 15)) { p += 15; const Q3CString & m = multiplicity(); if (!m.isEmpty() && (*((const char *) m) == '[')) f << m; else f << '[' << m << ']'; } else if (!strncmp(p, "${stereotype}", 13)) { p += 13; f << CppSettings::relationAttributeStereotype(stereotype()); } else if (!strncmp(p, "${value}", 8)) { if (!defaultValue().isEmpty()) { if (need_equal(p, defaultValue())) f << " = "; f << defaultValue(); } p += 8; } else if (!strncmp(p, "${h_value}", 10)) p += 10; else if (!strncmp(p, "${static}", 9)) { p += 9; } else if (!strncmp(p, "${const}", 8)) { p += 8; if (isReadOnly()) f << "const "; } else if (!strncmp(p, "${volatile}", 11)) { p += 11; if (isVolatile()) f << "volatile "; } else if (!strncmp(p, "${mutable}", 10)) { p += 10; } else if (!strncmp(p, "${type}", 7)) { p += 7; UmlClass::write(f, type()); //f << CppSettings::Type(Type().Type()); } else // strange f << *p++; } f << '\n'; } } }
void UmlRelation::gen_java_decl(QByteArray s, bool descr) { const char * p = bypass_comment(s); while (*p) { if (!strncmp(p, "${comment}", 10)) p += 10; else if (!strncmp(p, "${description}", 14)) p += 14; else if (!strncmp(p, "${visibility}", 13)) { p += 13; write(visibility(), javaLanguage); fw.write(' '); } else if (!strncmp(p, "${static}", 9)) { p += 9; if (isClassMember()) fw.write("static "); } else if (!strncmp(p, "${transient}", 12)) { p += 12; if (isJavaTransient()) fw.write("transient "); } else if (!strncmp(p, "${volatile}", 11)) { p += 11; if (isVolatile()) fw.write("volatile "); } else if (!strncmp(p, "${final}", 8)) { p += 8; if (isReadOnly()) fw.write("final "); } else if (!strncmp(p, "${type}", 7)) { p += 7; roleType()->write(); } else if (!strncmp(p, "${name}", 7)) { p += 7; writeq(roleName()); } else if (!strncmp(p, "${multiplicity}", 15)) { p += 15; QByteArray m = multiplicity(); if (! m.isEmpty()) { const char * s = m; if (*s != '[') fw.write("[]"); else { while (*s) { switch (*s++) { case '[': fw.write('['); break; case ']': fw.write(']'); default: break; } } } } } else if (!strncmp(p, "${stereotype}", 13)) { p += 13; writeq(JavaSettings::relationAttributeStereotype(stereotype())); } else if (!strncmp(p, "${value}", 8)) { p += 8; } else if (!strncmp(p, "${association}", 14)) { p += 14; write(association(), javaLanguage); } else if (!strncmp(p, "${@}", 4)) p += 4; else if (*p == '\r') p += 1; else if (*p == '\n') { if (descr) { fw.write("<br />"); p += 1; } else { fw.write(' '); do p += 1; while ((*p != 0) && (*p <= ' ')); } } else if (*p == ';') { if (descr) fw.write(*p++); else break; } else if (*p == '@') manage_alias(p); else writeq(*p++); } }
void UmlAttribute::generate_decl(aVisibility & current_visibility, QTextOStream & f_h, const Q3CString & cl_stereotype, Q3CString indent, BooL & first, bool last) { if (cl_stereotype == "typedef") { write_trace_header(); UmlCom::trace(" <font color=\"red\"><b>a <i>typedef</i> cannot have attribute</b></font><br>"); incr_warning(); return; } const char * p = cppDecl(); const char * pp = 0; bool in_enum = (cl_stereotype == "enum"); if (!in_enum) generate_visibility(current_visibility, f_h, first, indent); first = FALSE; while ((*p == ' ') || (*p == '\t')) indent += *p++; if (*p != '#') f_h << indent; for (;;) { if (*p == 0) { if (pp == 0) break; // comment management done p = pp; pp = 0; if (*p == 0) break; if (*p != '#') f_h << indent; } if (*p == '\n') { f_h << *p++; if (*p && (*p != '#')) f_h << indent; } else if (*p == '@') manage_alias(p, f_h); else if (*p != '$') f_h << *p++; else if (!strncmp(p, "${comment}", 10)) manage_comment(p, pp, CppSettings::isGenerateJavadocStyleComment()); else if (!strncmp(p, "${description}", 14)) manage_description(p, pp); else if (!strncmp(p, "${name}", 7)) { p += 7; f_h << name(); } else if (!strncmp(p, "${multiplicity}", 15)) { p += 15; const Q3CString & m = multiplicity(); if (!m.isEmpty() && (*((const char *) m) == '[')) f_h << m; else f_h << '[' << m << ']'; } else if (!strncmp(p, "${stereotype}", 13)) { p += 13; f_h << CppSettings::relationAttributeStereotype(stereotype()); } else if (!strncmp(p, "${value}", 8) || !strncmp(p, "${h_value}", 10)) { const char * pb = p; p += (p[2] == 'h') ? 10 : 8; if (in_enum) { if (!defaultValue().isEmpty()) { if (need_equal(pb, defaultValue())) f_h << " = "; f_h << defaultValue(); } if (last) { if (*p == ',') p += 1; } else if (*p != ',') f_h << ','; } else if ((p[-8] == 'h') && isClassMember() && !defaultValue().isEmpty()) { if (need_equal(pb, defaultValue())) f_h << " = "; f_h << defaultValue(); } } else if (in_enum) // strange f_h << *p++; else if (!strncmp(p, "${static}", 9)) { p += 9; if (isClassMember()) f_h << "static "; } else if (!strncmp(p, "${const}", 8)) { p += 8; if (isReadOnly()) f_h << "const "; } else if (!strncmp(p, "${volatile}", 11)) { p += 11; if (isVolatile()) f_h << "volatile "; } else if (!strncmp(p, "${mutable}", 10)) { p += 10; if (isCppMutable()) f_h << "mutable "; } else if (!strncmp(p, "${type}", 7)) { p += 7; UmlClass::write(f_h, type()); //f_h << CppSettings::Type(Type().Type()); } else // strange f_h << *p++; } f_h << '\n'; }
void UmlRelation::generate(QTextOStream & f, const Q3CString & cl_stereotype, Q3CString indent) { switch (relationKind()) { case aDependency: case aGeneralisation: case aRealization: break; default: if (!javaDecl().isEmpty()) { if (cl_stereotype == "enum_pattern") { write_trace_header(); UmlCom::trace(" <font color=\"red\"><b>an <i>enum_pattern</i> cannot have relation</b></font><br>"); incr_warning(); return; } const char * p = javaDecl(); const char * pp = 0; Q3CString s; while ((*p == ' ') || (*p == '\t')) indent += *p++; f << indent; for (;;) { if (*p == 0) { if (pp == 0) break; // comment management done p = pp; pp = 0; if (*p == 0) break; f << indent; } if (*p == '\n') { f << *p++; if (*p) f << indent; } else if (*p == '@') manage_alias(p, f); else if (*p != '$') f << *p++; else if (!strncmp(p, "${comment}", 10)) manage_comment(p, pp, JavaSettings::isGenerateJavadocStyleComment()); else if (!strncmp(p, "${description}", 14)) manage_description(p, pp); else if (!strncmp(p, "${visibility}", 13)) { p += 13; generate_visibility(f, cl_stereotype); } else if (!strncmp(p, "${static}", 9)) { p += 9; if (isClassMember()) f << "static "; } else if (!strncmp(p, "${final}", 8)) { p += 8; if (isReadOnly()) f << "final "; } else if (!strncmp(p, "${transient}", 12)) { p += 12; if (isJavaTransient()) f << "transient "; } else if (!strncmp(p, "${volatile}", 11)) { p += 11; if (isVolatile()) f << "volatile "; } else if (!strncmp(p, "${type}", 7)) { p += 7; roleType()->write(f); } else if (!strncmp(p, "${stereotype}", 13)) { p += 13; f << JavaSettings::relationAttributeStereotype(stereotype()); } else if (!strncmp(p, "${name}", 7)) { p += 7; f << roleName(); } else if (!strncmp(p, "${inverse_name}", 15)) { p += 15; switch (relationKind()) { case anAssociation: case anAggregation: case anAggregationByValue: f << side(side(TRUE) != this)->roleName(); default: break; } } else if (!strncmp(p, "${multiplicity}", 15)) { p += 15; Q3CString m = multiplicity(); if (*m != '[') f << "[]"; else { for (unsigned index = 0; index != m.length(); index += 1) { switch (m.at(index)) { case '[': f << '['; break; case ']': f << ']'; default: break; } } } } else if (!strncmp(p, "${value}", 8)) { if (!defaultValue().isEmpty()) { if (need_equal(p, defaultValue())) f << " = "; f << defaultValue(); } p += 8; } else if (!strncmp(p, "${association}", 14)) { p += 14; UmlClass::write(f, association()); } else if (!strncmp(p, "${@}", 4)) { p += 4; if (pp != 0) f << "${@}"; else if (! javaAnnotations().isEmpty()) { pp =p; p = javaAnnotations(); } } else // strange f << *p++; } f << '\n'; } } }
bool test_isomorphism() { { std::vector<invar1_value> invar1_array; BGL_FORALL_VERTICES_T(v, G1, Graph1) invar1_array.push_back(invariant1(v)); sort(invar1_array); std::vector<invar2_value> invar2_array; BGL_FORALL_VERTICES_T(v, G2, Graph2) invar2_array.push_back(invariant2(v)); sort(invar2_array); if (! equal(invar1_array, invar2_array)) return false; } std::vector<vertex1_t> V_mult; BGL_FORALL_VERTICES_T(v, G1, Graph1) V_mult.push_back(v); { std::vector<size_type> multiplicity(max_invariant, 0); BGL_FORALL_VERTICES_T(v, G1, Graph1) ++multiplicity[invariant1(v)]; sort(V_mult, compare_multiplicity(invariant1, &multiplicity[0])); } std::vector<default_color_type> color_vec(num_vertices(G1)); safe_iterator_property_map<std::vector<default_color_type>::iterator, IndexMap1 #ifdef BOOST_NO_STD_ITERATOR_TRAITS , default_color_type, default_color_type& #endif /* BOOST_NO_STD_ITERATOR_TRAITS */ > color_map(color_vec.begin(), color_vec.size(), index_map1); record_dfs_order dfs_visitor(dfs_vertices, ordered_edges); typedef color_traits<default_color_type> Color; for (vertex_iter u = V_mult.begin(); u != V_mult.end(); ++u) { if (color_map[*u] == Color::white()) { dfs_visitor.start_vertex(*u, G1); depth_first_visit(G1, *u, dfs_visitor, color_map); } } // Create the dfs_num array and dfs_num_map dfs_num_vec.resize(num_vertices(G1)); dfs_num = make_safe_iterator_property_map(dfs_num_vec.begin(), dfs_num_vec.size(), index_map1 #ifdef BOOST_NO_STD_ITERATOR_TRAITS , dfs_num_vec.front() #endif /* BOOST_NO_STD_ITERATOR_TRAITS */ ); size_type n = 0; for (vertex_iter v = dfs_vertices.begin(); v != dfs_vertices.end(); ++v) dfs_num[*v] = n++; sort(ordered_edges, edge_cmp(G1, dfs_num)); int dfs_num_k = -1; return this->match(ordered_edges.begin(), dfs_num_k); }
void UmlRelation::generate_decl(QTextStream & f, const WrapperStr & cl_stereotype, WrapperStr indent, bool) { if ((relationKind() != aGeneralisation) && (relationKind() != aRealization) && (relationKind() != aDependency)) { if (cl_stereotype == "enum") { write_trace_header(); UmlCom::trace(" <font color=\"red\"><b>an <i>enum</i> cannot have relation</b></font><br>"); incr_warning(); return; } if (cl_stereotype == "typedef") { write_trace_header(); UmlCom::trace(" <font color=\"red\"><b>a <i>typedef</i> cannot have relation</b></font><br>"); incr_warning(); return; } if (!idlDecl().isEmpty()) { const char * p = idlDecl(); const char * pp = 0; WrapperStr s; while ((*p == ' ') || (*p == '\t')) indent += *p++; if (*p != '#') f << indent; for (;;) { if (*p == 0) { if (pp == 0) break; // comment management done p = pp; pp = 0; if (*p == 0) break; if (*p != '#') f << indent; } if (*p == '\n') { f << *p++; if (*p && (*p != '#')) f << indent; } else if (*p == '@') manage_alias(p, f); else if (*p != '$') f << *p++; else if (!strncmp(p, "${comment}", 10)) manage_comment(p, pp); else if (!strncmp(p, "${description}", 14)) manage_description(p, pp); else if (!strncmp(p, "${readonly}", 11)) { p += 11; if (isReadOnly()) f << "readonly "; } else if (!strncmp(p, "${attribut}", 11)) { // old version p += 11; if (cl_stereotype == "interface") f << "attribute "; } else if (!strncmp(p, "${attribute}", 12)) { p += 12; if (cl_stereotype == "interface") f << "attribute "; } else if (!strncmp(p, "${visibility}", 13)) { p += 13; if (cl_stereotype == "valuetype") { switch (visibility()) { case PublicVisibility: case PackageVisibility: f << "public "; break; default: f << "private "; } } } else if (!strncmp(p, "${case}", 7)) { p += 7; WrapperStr idl_case = idlCase(); if (idl_case.isEmpty()) { write_trace_header(); UmlCom::trace(WrapperStr(" <font color=\"red\"><b>unspecified <i>case</i> for <i>") + name() + "</b></font><br>"); incr_error(); } else f << idlCase(); } else if (!strncmp(p, "${type}", 7)) { p += 7; roleType()->write(f); } else if (!strncmp(p, "${name}", 7)) { p += 7; f << roleName(); } else if (!strncmp(p, "${inverse_name}", 15)) { p += 15; switch (relationKind()) { case anAssociation: case anAggregation: case anAggregationByValue: f << side(side(TRUE) != this)->roleName(); default: break; } } else if (!strncmp(p, "${stereotype}", 13)) { p += 13; f << IdlSettings::relationAttributeStereotype(stereotype()); } else if (!strncmp(p, "${multiplicity}", 15)) { p += 15; f << multiplicity(); } else if (!strncmp(p, "${association}", 14)) { p += 14; f << IdlSettings::type(association().toString()); } else // strange f << *p++; } f << '\n'; } } }
void UmlRelation::generate_def(QTextStream & f, WrapperStr indent, bool h, WrapperStr templates, WrapperStr cl_names, WrapperStr, WrapperStr) { if (isClassMember() && !cppDecl().isEmpty()) { UmlClass * cl = (UmlClass *) parent(); if ((!templates.isEmpty() || (cl->name().find('<') != -1)) ? h : !h) { const char * p = cppDecl(); const char * pp = 0; while ((*p == ' ') || (*p == '\t')) p += 1; bool re_template = !templates.isEmpty() && insert_template(p, f, indent, templates); if (*p != '#') f << indent; const char * pname = name_spec(p); for (;;) { if (*p == 0) { if (pp == 0) break; // comment management done p = pp; pp = 0; if (re_template) f << templates; if (*p == 0) break; if (*p != '#') f << indent; } if (*p == '\n') { f << toLocale(p); if (*p && (*p != '#')) f << indent; } else if (*p == '@') manage_alias(p, f); else if (*p != '$') { if (p == pname) f << cl_names << "::"; f << toLocale(p); } else if (!strncmp(p, "${comment}", 10)) { if (!manage_comment(p, pp, CppSettings::isGenerateJavadocStyleComment()) && re_template) f << templates; } else if (!strncmp(p, "${description}", 14)) { if (!manage_description(p, pp) && re_template) f << templates; } else if (!strncmp(p, "${static}", 9)) { p += 9; } else if (!strncmp(p, "${const}", 8)) { p += 8; if (isReadOnly()) f << "const "; } else if (!strncmp(p, "${volatile}", 11)) { p += 11; if (isVolatile()) f << "volatile "; } else if (!strncmp(p, "${mutable}", 10)) { p += 10; } else if (!strncmp(p, "${type}", 7)) { p += 7; roleType()->write(f); } else if (!strncmp(p, "${name}", 7)) { p += 7; if (*pname == '$') f << cl_names << "::"; f << roleName(); } else if (!strncmp(p, "${inverse_name}", 15)) { p += 15; switch (relationKind()) { case anAssociation: case anAggregation: case anAggregationByValue: f << side(side(TRUE) != this)->roleName(); default: break; } } else if (!strncmp(p, "${multiplicity}", 15)) { p += 15; const WrapperStr & m = multiplicity(); if (!m.isEmpty() && (*((const char *) m) == '[')) f << m; else f << '[' << m << ']'; } else if (!strncmp(p, "${stereotype}", 13)) { p += 13; f << CppSettings::relationAttributeStereotype(stereotype()); } else if (!strncmp(p, "${value}", 8)) { if (!defaultValue().isEmpty()) { if (need_equal(p, defaultValue())) f << " = "; f << defaultValue(); } p += 8; } else if (!strncmp(p, "${h_value}", 10)) p += 10; else if (!strncmp(p, "${association}", 14)) { p += 14; UmlClass::write(f, association()); } else // strange f << toLocale(p); } f << '\n'; } } }
void UmlRelation::generate_decl(aVisibility & current_visibility, QTextStream & f_h, const WrapperStr & cl_stereotype, WrapperStr indent, BooL & first, bool) { switch (relationKind()) { case aDependency: if (stereotype() == "friend") { Q3ValueList<UmlFormalParameter> formals = roleType()->formals(); if (! formals.isEmpty()) { const char * sep = " template <"; Q3ValueList<UmlFormalParameter>::ConstIterator it; for (it = formals.begin(); it != formals.end(); ++it) { f_h << sep << (*it).type() << ' ' << (*it).name(); sep = ", "; } f_h << "> "; } else f_h << " "; f_h << "friend " << roleType()->cpp_stereotype() << " "; roleType()->write(f_h, FALSE); f_h << ";\n"; first = FALSE; } break; case aGeneralisation: case aRealization: break; default: if (!cppDecl().isEmpty()) { if (cl_stereotype == "enum") { write_trace_header(); UmlCom::trace(" <font color=\"red\"><b>an <i>enum</i> cannot have relation</b></font><br>"); incr_warning(); return; } if (cl_stereotype == "typedef") { write_trace_header(); UmlCom::trace(" <font color=\"red\"><b>a <i>typedef</i> cannot have relation</b></font><br>"); incr_warning(); return; } generate_visibility(current_visibility, f_h, first, indent); first = FALSE; const char * p = cppDecl(); const char * pp = 0; WrapperStr s; while ((*p == ' ') || (*p == '\t')) indent += toLocale(p); if (*p != '#') f_h << indent; for (;;) { if (*p == 0) { if (pp == 0) break; // comment management done p = pp; pp = 0; if (*p == 0) break; if (*p != '#') f_h << indent; } if (*p == '\n') { f_h << toLocale(p); if (*p && (*p != '#')) f_h << indent; } else if (*p == '@') manage_alias(p, f_h); else if (*p != '$') f_h << toLocale(p); else if (!strncmp(p, "${comment}", 10)) manage_comment(p, pp, CppSettings::isGenerateJavadocStyleComment()); else if (!strncmp(p, "${description}", 14)) manage_description(p, pp); else if (!strncmp(p, "${static}", 9)) { p += 9; if (isClassMember()) f_h << "static "; } else if (!strncmp(p, "${const}", 8)) { p += 8; if (isReadOnly()) f_h << "const "; } else if (!strncmp(p, "${volatile}", 11)) { p += 11; if (isVolatile()) f_h << "volatile "; } else if (!strncmp(p, "${mutable}", 10)) { p += 10; if (isCppMutable()) f_h << "mutable "; } else if (!strncmp(p, "${type}", 7)) { p += 7; roleType()->write(f_h); } else if (!strncmp(p, "${name}", 7)) { p += 7; f_h << roleName(); } else if (!strncmp(p, "${inverse_name}", 15)) { p += 15; switch (relationKind()) { case anAssociation: case anAggregation: case anAggregationByValue: f_h << side(side(TRUE) != this)->roleName(); default: break; } } else if (!strncmp(p, "${multiplicity}", 15)) { p += 15; const WrapperStr & m = multiplicity(); if (!m.isEmpty() && (*((const char *) m) == '[')) f_h << m; else f_h << '[' << m << ']'; } else if (!strncmp(p, "${stereotype}", 13)) { p += 13; f_h << CppSettings::relationAttributeStereotype(stereotype()); } else if (!strncmp(p, "${value}", 8)) p += 8; else if (!strncmp(p, "${h_value}", 10)) { if (!defaultValue().isEmpty() && isClassMember()) { if (need_equal(p, defaultValue())) f_h << " = "; f_h << defaultValue(); } p += 10; } else if (!strncmp(p, "${association}", 14)) { p += 14; UmlClass::write(f_h, association()); } else // strange f_h << toLocale(p); } f_h << '\n'; } } }
int TopologicalGraph::Simplify() // returns the # o multiple edges + # loops {if(Set().exist(PROP_SIMPLE))return 0; if(debug())DebugPrintf(" Executing Simplify"); // Remove Loops int n = RemoveLoops(); if(!ne()){Prop1<int> simple(Set(),PROP_SIMPLE);return n;} svector<tedge>link(0,ne()); link.clear(); link.SetName("TG:Simplify:link"); svector<tedge>top1(1,nv()); top1.clear(); top1.SetName("TG:Simplify:top1"); svector<tedge>top2(1,nv()); top2.clear(); top2.SetName("TG:Simplify:top2"); tvertex u,v,w; tedge e,e0,next; //First sort with respect to biggest label for(e = ne();e >= 1;e--) {v = (vin[e] < vin[-e]) ? vin[-e] : vin[e]; link[e] = top1[v];top1[v] = e; } // Then sort with respect to smallest label for(u = nv();u > 1;u--) {e = top1[u]; while(e!=0) {next = link[e]; //as link is modified v = (vin[e] < vin[-e]) ? vin[e] : vin[-e]; link[e] = top2[v]; top2[v] = e; e = next; } } // Erase Multiple edges, but backup multiplicity Prop<int> multiplicity(Set(tedge()),PROP_MULTIPLICITY); for (e=1; e<=ne(); ++e) multiplicity[e]=1; for(v = nv()-1;v >= 1;v--) {e0 = top2[v]; u = vin[e0];if(u == v)u = vin[-e0]; e=link[e0]; link[e0]=0; while(e!=0) {next=link[e]; w = vin[e];if(w == v)w = vin[-e]; if(u == w) {++n; ++multiplicity[e0]; link[e] = 1; } else {u=w; link[e0=e] = 0; } e=next; } } bool erased = false; for(e = ne();e >= 1;e--) if(link[e]!=0){DeleteEdge(e);erased = true;} if(!erased)Set(tedge()).erase(PROP_MULTIPLICITY); Prop1<int> simple(Set(),PROP_SIMPLE); return n; }
void UmlRelation::gen_cpp_decl(QByteArray s, bool descr) { const char * p; if (! descr) { write((cppVisibility() == DefaultVisibility) ? visibility() : cppVisibility(), cppLanguage); fw.write(": "); p = bypass_comment(s); } else p = s; while (*p) { if (!strncmp(p, "${comment}", 10)) p += 10; else if (!strncmp(p, "${description}", 14)) p += 14; else if (!strncmp(p, "${static}", 9)) { p += 9; if (isClassMember()) fw.write("static "); } else if (!strncmp(p, "${const}", 8)) { p += 8; if (isReadOnly()) fw.write("const "); } else if (!strncmp(p, "${mutable}", 10)) { p += 10; if (isCppMutable()) fw.write("mutable "); } else if (!strncmp(p, "${volatile}", 11)) { p += 11; if (isVolatile()) fw.write("volatile "); } else if (!strncmp(p, "${type}", 7)) { p += 7; roleType()->write(); } else if (!strncmp(p, "${name}", 7)) { p += 7; writeq(roleName()); } else if (!strncmp(p, "${multiplicity}", 15)) { p += 15; QByteArray m = multiplicity(); if (m.isEmpty() || (((const char *) m)[0] != '[')) { fw.write("["); writeq(m); fw.write("]"); } else writeq(m); } else if (!strncmp(p, "${stereotype}", 13)) { p += 13; writeq(CppSettings::relationAttributeStereotype(stereotype())); } else if (!strncmp(p, "${value}", 8) || !strncmp(p, "${h_value}", 10)) { break; } else if (!strncmp(p, "${association}", 14)) { p += 14; write(association(), cppLanguage); } else if (*p == '\r') p += 1; else if (*p == '\n') { if (descr) { fw.write("<br />"); p += 1; } else { fw.write(' '); do p += 1; while ((*p != 0) && (*p <= ' ')); } } else if (*p == ';') { if (descr) fw.write(*p++); else break; } else if (*p == '@') manage_alias(p); else writeq(*p++); } }
int SmartState::pathLength(){ if(_parent) return multiplicity() + _parent->pathLength(); else return 0; }