// realign to eps void realign::realignNow(vector <baseType> &along, baseType eps, meanVar dist) { baseType factor = eps / sqrt(dist.var); network::nodeIterator vi; queue <baseType> states; unsigned int i = 0; for (vi = vl->begin(); vi != vl->end();vi++) { // baseType stat = theNodes[*vi]->getState(); baseType diff = along[i] - node::theNodes[*vi]->getState() ; if (diff > 0.5) diff = diff - 1; else if (diff < -0.5) diff = diff + 1; diff = diff - dist.mean; diff = diff * factor; if (diff > 0.5 || diff < -0.5) throw "Fehler Abstand zu gro� f�r den Raum (evolveAlong)"; baseType n; if (diff > 0) { n = along[i] - diff; if (n < 0) n=n + 1; } else { n = along[i] - diff; if ( n > 1) n = n - 1; } states.push (n); i++; } boost::function<baseType () > r = boost::bind(&frontAndPop, &states); for (vi = vl->begin(); vi != vl->end();vi++) { ((dynNode*) node::theNodes[*vi]) -> randomizeState( r) ; } }
// need to compare the typestring bool isParameterRightType(const char* passedType, const char* expectedType, const char* methodNamespacePrefix, bool tryReverse) { if (strcmp(expectedType,passedType) == 0) return true; // well now things are a bit more complicated. We need to see if the passed type // is a subset of the overall type std::string et(expectedType); bool isPointer = (et[0] == 'p' && et[1] == '.'); std::string baseType(et,(isPointer ? 2 : 0)); // this may contain a namespace std::string ns(methodNamespacePrefix); // cut off trailing '::' if (ns.size() > 2 && ns[ns.size() - 1] == ':' && ns[ns.size() - 2] == ':') ns = ns.substr(0,ns.size()-2); bool done = false; while(! done) { done = true; // now we need to see if the expected type can be munged // into the passed type by tacking on the namespace of // of the method. std::string check(isPointer ? "p." : ""); check += ns; check += "::"; check += baseType; if (strcmp(check.c_str(),passedType) == 0) return true; // see if the namespace is nested. int posOfScopeOp = ns.find("::"); if (posOfScopeOp >= 0) { done = false; // cur off the outermost namespace ns = ns.substr(posOfScopeOp + 2); } } // so far we applied the namespace to the expected type. Now lets try // the reverse if we haven't already. if (tryReverse) return isParameterRightType(expectedType, passedType, methodNamespacePrefix, false); return false; }
//-***************************************************************************** //! Prints out relevant information about the TimeSamplingType instance std::ostream &operator<<( std::ostream &ostr, const TimeSamplingType &tst ) { std::string baseType( "" ); if ( tst.isUniform() ) { baseType = "Uniform"; } else if ( tst.isCyclic() ) { baseType = "Cyclic"; } else { baseType = "Acyclic"; } ostr << baseType << " time sampling"; if ( tst.isUniform() ) { ostr << " with " << tst.getTimePerCycle() << " chrono_ts/cycle"; } else if ( tst.isCyclic() ) { ostr << " with " << tst.getNumSamplesPerCycle() << " samps/cycle " << "and " << tst.getTimePerCycle() << " chrono_ts/cycle"; } return ostr; }
void UmlClass::write(FileOut & out) { QCString st = stereotype(); if (st == "metaclass") return; bool is_actor = (st == "actor"); bool is_enum = (st == "enum"); bool is_stereotype = (st == "stereotype") && (parent()->parent()->kind() == aPackage) && (parent()->parent()->stereotype() == "profile"); if (!is_actor) { switch (_lang) { case Cpp: if (cppDecl().isEmpty()) return; break; case Java: if (javaDecl().isEmpty()) return; default: break; } } const char * k = (parent()->kind() == aClass) ? "nestedClassifier" : ((!_uml_20) ? "packagedElement" : ((is_stereotype) ? "ownedStereotype" : "ownedMember")); bool is_assoc_class = (_assoc != 0); out.indent(); out << "<" << k << " xmi:type=\"uml:" << ((is_actor) ? "Actor" : ((is_assoc_class) ? "AssociationClass" : ((st == "interface") ? "Interface" : ((is_enum) ?"Enumeration" : ((is_stereotype) ? "Stereotype" : "Class"))))) << "\" name=\""; out.quote(name()); out << '"'; out.id(this); write_visibility(out); if (isAbstract()) out << " isAbstract=\"true\""; if (isActive()) out << " isActive=\"true\""; out << ">\n"; if (is_assoc_class) _assoc->write_ends(out); out.indent(+1); write_constraint(out); write_annotation(out); write_description_properties(out); if (_gen_extension && (st == "typedef")) { const UmlTypeSpec & base = baseType(); if ((base.type != 0) || !base.explicit_type.isEmpty()) { out.indent(); out << "<xmi:Extension extender=\"Bouml\">\n"; out.indent(); out << "\t<typedef>\n"; out.indent(+2); UmlItem::write_type(out, base, "base"); out.indent(-2); out.indent(); out << "\t</typedef>\n"; out.indent(); out << "</xmi:Extension>\n"; } } write_formals(out); write_actuals(out); const QVector<UmlItem> ch = children(); unsigned n = ch.size(); unsigned i; for (i = 0; i != n; i += 1) ch[i]->write(out); if (is_stereotype) { QCString path; if (propertyValue("stereotypeIconPath", path) && !path.isEmpty()) { out.indent(); out << "<icon xmi:type=\"uml:Image\""; out.id_prefix(this, "Icon_"); out << " location=\"" << path << "\"/>\n"; } } out.indent(-1); out.indent(); out << "</" << k << ">\n"; if (is_stereotype) for (i = 0; i != n; i += 1) if (ch[i]->kind() == aRelation) ((UmlRelation *) ch[i])->write_extension(out); unload(); }
/** * @retval true If this widget represents interface and DrawAsCircle * property is set. */ bool ClassifierWidget::shouldDrawAsCircle() const { return baseType() == WidgetBase::wt_Interface && visualProperty(DrawAsCircle) == true; }
void UmlClass::gen_cpp_decl(QCString s, bool descr) { const char * p = (descr) ? (const char *) s : (const char *) bypass_comment(s); while (*p) { if (!strncmp(p, "${comment}", 10)) p += 10; else if (!strncmp(p, "${description}", 14)) p += 14; else if (!strncmp(p, "${type}", 7)) { p += 7; bool find = FALSE; if (baseType().type != 0) { UmlClass * mother = baseType().type; const QVector<UmlItem> ch = children(); for (unsigned i = 0; i != ch.size(); i += 1) { if (ch[i]->kind() == aRelation) { UmlRelation * rel = (UmlRelation *) ch[i]; aRelationKind k = rel->relationKind(); if (((k == aGeneralisation) || (k == aRealization)) && (rel->roleType() == mother)) { rel->roleType()->write(); generate(actuals(), mother, TRUE); find = TRUE; break; } } } } if (! find) UmlItem::write(baseType(), cppLanguage); } else if (!strncmp(p, "${template}", 11)) { p += 11; generate(formals()); } else if (!strncmp(p, "${name}", 7)) { p += 7; writeq(name()); } else if (!strncmp(p, "${inherit}", 10)) { p += 10; const QVector<UmlItem> ch = children(); const char * sep = " : "; for (unsigned i = 0; i != ch.size(); i += 1) { if (ch[i]->kind() == aRelation) { UmlRelation * rel = (UmlRelation *) ch[i]; aRelationKind k = rel->relationKind(); if (((k == aGeneralisation) || (k == aRealization)) && !rel->cppDecl().isEmpty()) { fw.write(sep); // UmlItem::write else G++ call UmlClass::write(QCString) ! UmlItem::write((rel->cppVisibility() == DefaultVisibility) ? rel->visibility() : rel->cppVisibility(), cppLanguage); fw.write((rel->cppVirtualInheritance()) ? " virtual " : " "); rel->roleType()->write(); generate(actuals(), rel->roleType(), TRUE); sep = ", "; } } } } else if (*p == '{') { if (descr) fw.write(*p++); else break; } 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 == '@') manage_alias(p); else writeq(*p++); } }
void UmlClass::compute_dependency(Q3PtrList<CppRefType> & dependencies, const Q3CString &, bool all_in_h) { Q3PtrVector<UmlItem> ch = children(); const Q3CString stereotype = cpp_stereotype(); bool a_typedef = (stereotype == "typedef"); bool an_enum = (stereotype == "enum"); const Q3ValueList<UmlFormalParameter> formals = this->formals(); const Q3ValueList<UmlActualParameter> actuals = this->actuals(); if (!formals.isEmpty()) // template class, force depend in h all_in_h = TRUE; for (unsigned index = 0; index != ch.size(); index += 1) { if (ch[index]->kind() != aNcRelation) { UmlClassItem * it = (UmlClassItem *) ch[index]; if (! it->cppDecl().isEmpty()) it->compute_dependency(dependencies, stereotype, all_in_h); } } if (an_enum && (!formals.isEmpty() || !actuals.isEmpty())) { write_trace_header(); UmlCom::trace(" <font color=\"red\"><b><i>template enum</i></b></font><br>"); incr_warning(); } else if (a_typedef && !formals.isEmpty()) { write_trace_header(); UmlCom::trace(" <font color=\"red\"><b><i>template typedef</i></b></font><br>"); incr_warning(); } else { Q3ValueList<UmlFormalParameter>::ConstIterator itf; for (itf = formals.begin(); itf != formals.end(); ++itf) CppRefType::remove((*itf).name(), dependencies); Q3ValueList<UmlActualParameter>::ConstIterator ita; for (ita = actuals.begin(); ita != actuals.end(); ++ita) UmlClassMember::compute_dependency(dependencies, "${type}", (*ita).value(), all_in_h); if (a_typedef) { Q3CString decl = cppDecl(); int index; remove_comments(decl); if ((index = decl.find("${name}")) != -1) decl.remove((unsigned) index, 7); replace_alias(decl); UmlClassMember::compute_dependency(dependencies, decl, baseType(), all_in_h); } } if ((associatedArtifact() == 0) || (associatedArtifact()->associatedClasses().count() == 1)) CppRefType::remove(this, dependencies); else CppRefType::force_ref(this, dependencies); }
void UmlClass::generate_decl(QTextOStream & f_h, Q3CString indent) { context.append(this); bool removed = FALSE; Q3PtrVector<UmlItem> ch = children(); const unsigned sup = ch.size(); const Q3CString & stereotype = cpp_stereotype(); bool a_typedef = (stereotype == "typedef"); bool an_enum = (stereotype == "enum"); const Q3ValueList<UmlFormalParameter> formals = this->formals(); const Q3ValueList<UmlActualParameter> actuals = this->actuals(); unsigned index; const char * p = cppDecl(); const char * pp = 0; const char * sep; bool nestedp = parent()->kind() == aClass; if (nestedp) indent += " "; 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 != '#') && strncmp(p, "${members}", 10) && strncmp(p, "${items}", 8)) 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 (a_typedef) { if (!strncmp(p, "${type}", 7)) { p += 7; UmlClass::write(f_h, baseType(), FALSE); UmlClass * cl = baseType().type; if ((cl != 0) && !actuals.isEmpty()) { Q3ValueList<UmlActualParameter>::ConstIterator ita; BooL need_space = FALSE; for (ita = actuals.begin(); ita != actuals.end(); ++ita) if ((*ita).superClass() == cl) if (! (*ita).generate(f_h, need_space)) // no specified value break; if (need_space) f_h << " >"; else f_h << '>'; } } else // strange f_h << *p++; } else if (an_enum) { if (!strncmp(p, "${items}", 8)) { p += 8; // items declaration aVisibility current_visibility = DefaultVisibility; unsigned max = sup - 1; BooL first = TRUE; for (index = 0; index < sup; index += 1) { UmlItem * it = ch[index]; switch (it->kind()) { case aClass: case aNcRelation: break; default: if (! ((UmlClassItem *) it)->cppDecl().isEmpty()) ((UmlClassItem *) it)->generate_decl(current_visibility, f_h, stereotype, indent, first, index == max); } } if (*p == '}') f_h << indent; } else // strange f_h << *p++; } else if (! strncmp(p, "${template}", 11)) { p += 11; // template if (!formals.isEmpty()) { sep = "template<"; const char * sep2 = "<"; BooL need_space = FALSE; Q3ValueList<UmlFormalParameter>::ConstIterator itf; for (itf = formals.begin(); itf != formals.end(); ++itf) (*itf).generate(f_h, sep, sep2, need_space); f_h << ((need_space) ? " >\n" : ">\n"); if (nestedp) f_h << indent; } else if (name().find('<') != -1) { f_h << "template<>\n"; if (nestedp) f_h << indent; } } else if (! strncmp(p, "${inherit}", 10)) { p += 10; // inherit sep = " : "; for (index = 0; index != sup; index += 1) { UmlItem * x = ch[index]; if ((x->kind() == aRelation) && !((UmlRelation *) ch[index])->cppDecl().isEmpty()) ((UmlRelation *) x)->generate_inherit(sep, f_h, actuals, stereotype); } } else if (! strncmp(p, "${members}", 10)) { p += 10; // members declaration aVisibility current_visibility; current_visibility = ((stereotype == "struct") || (stereotype == "union")) ? PublicVisibility : DefaultVisibility; unsigned last = sup - 1; BooL first = TRUE; for (index = 0; index != sup; index += 1) { UmlItem * it = ch[index]; if ((it->kind() != aNcRelation) && ! ((UmlClassItem *) it)->cppDecl().isEmpty()) ((UmlClassItem *) it)->generate_decl(current_visibility, f_h, stereotype, indent, first, index == last); } if (*p == '}') f_h << indent; } else if (!strncmp(p, "${inlines}", 10)) { p += 10; context.removeLast(); removed = TRUE; if (! nestedp) { // inline operations definition // template class members Q3CString templates; Q3CString cl_names; Q3CString templates_tmplop; Q3CString cl_names_tmplop; spec(templates, cl_names, templates_tmplop, cl_names_tmplop); for (index = 0; index != sup; index += 1) if (ch[index]->kind() != aNcRelation) ((UmlClassItem *) ch[index]) ->generate_def(f_h, indent, TRUE, templates, cl_names, templates_tmplop, cl_names_tmplop); } if (*p == '\n') p += 1; } else // strange f_h << *p++; } if (! removed) context.removeLast(); }
void dynNetwork::startingConditionOpenWaveEndingMiddle() { queue<baseType> initialCond; unsigned int size = sqrt ( (baseType) node::theNodes.size() ); for ( unsigned int i = 0; i < size; i++ ) for ( unsigned int j = 0; j < size; j++ ) { if ( i< size/3 || i > 2*size/3 ) { initialCond.push ( -1.0 ); if ( node::theNodes[i + size *j]->getNodeInfo().theNodeKind & _dynNode_ ) for ( unsigned int n = 0; n > dynamic_cast<dynNode*>(node::theNodes[i+size*j] )->dimension() - 1; n = n + 1 ) initialCond.push ( 40.0 ); } else { if ( j < size/3 || j > 2*size/3 ) initialCond.push ( 0.0 ); else initialCond.push ( 100.0 ); if ( node::theNodes[i + size *j]->getNodeInfo().theNodeKind & _dynNode_ ) for ( unsigned int n = 0; n > dynamic_cast<dynNode*>( node::theNodes[i+size*j] )->dimension() - 1; n = n + 1 ) initialCond.push ( 0.0 ); } } boost::function<baseType () > r = bind ( &frontAndPop,&initialCond ); vector< node * >::iterator it; for ( it = node::theNodes.begin(); it != node::theNodes.end(); it++ ) { // if ( ( *it )->getNodeInfo().theNodeKind & _dynNode_ == 0 ) // continue; //// continue; // ( ( dynamic_cast<dynNode*>( ( *it ) )->state = r(); dynamic_cast<dynNode*>( ( *it ) )->randomizeState ( r ); } }
QString PointerType::toString() const { QString baseString = (baseType() ? baseType()->toString() : "<notype>"); return QString("%1*").arg(baseString) + AbstractType::toString(true); }