QString RelationData::get_name(BrowserRelation * cl) const { static QString result; if (cl == start) { if (!a.role.isEmpty()) { const char * role = a.role; const char * tName = get_name(); result = QString(role + QString(" (") + tName + ")"); return result; } } else if (cl == end) { if (!b.role.isEmpty()) { QLOG_INFO() << "Returning name for relation: " << QString((const char *) b.role) + " (" + get_name() + ")"; const char * role = b.role; const char * tName = get_name(); result = QString(role + QString(" (") + tName + ")"); return QString(role + QString(" (") + tName + ")"); } } bool nameIsNotADefaultType = this->name != default_name(type); if (nameIsNotADefaultType) result = ("(" + this->name + ")").operator QString(); else result = this->name.operator QString(); //QLOG_INFO() << "Returning name for relation: " << relationName; return result; }
void RelationData::save(QTextStream & st, bool ref, QString & warning) const { if (ref) st << "relation_ref " << get_ident() << " // " << (name); else { nl_indent(st); st << "relation " << get_ident() << " " << stringify(type); if (name != default_name(type)) { st << " name "; save_string(name, st); } indent(+1); BasicData::save(st, warning); if (original_id != 0) { nl_indent(st); st << "oid " << original_id; } bool assoc = isa_association(type); nl_indent(st); indent(+1); st << "a "; save_role(a, assoc, st, warning); start->save(st, TRUE, warning); indent(-1); nl_indent(st); indent(+1); st << "b"; if (!RelationData::uni_directional(type)) { st << " "; save_role(b, assoc, st, warning); end->save(st, TRUE, warning); } else { if (!b.multiplicity.isEmpty()) { st << " multiplicity "; save_string(b.multiplicity, st); } st << " parent "; end_removed_from->save(st, TRUE, warning); } indent(-1); if ((association.type != 0) || !association.explicit_type.isEmpty()) { nl_indent(st); association.save(st, warning, "association_type ", "association_explicit_type "); } indent(-1); } }
static void* __acquire_category(const char* &name, char *buf, _Locale_name_hint* hint, loc_extract_name_func_t extract_name, loc_create_func_t create_obj, loc_default_name_func_t default_name, Category_Map ** M, int *__err_code) { typedef Category_Map::iterator Category_iterator; pair<Category_iterator, bool> result; *__err_code = _STLP_LOC_UNDEFINED; // Find what name to look for. Be careful if user requests the default. if (name[0] == 0) { name = default_name(buf); if (name == 0 || name[0] == 0) name = "C"; } else { const char* cname = extract_name(name, buf, hint, __err_code); if (cname == 0) { return 0; } name = cname; } Category_Map::value_type __e(name, pair<void*,size_t>((void*)0,size_t(0))); _STLP_auto_lock sentry(category_hash_mutex()); if (!*M) *M = new Category_Map(); // Look for an existing entry with that name. result = (*M)->insert_noresize(__e); if (result.second) { // There was no entry in the map already. Create the category. (*result.first).second.first = create_obj(name, hint, __err_code); if (!(*result.first).second.first) { (*M)->erase(result.first); #if defined (_STLP_LEAKS_PEDANTIC) if ((*M)->empty()) { delete *M; *M = 0; } #endif return 0; } } // Increment the reference count. ++((*result.first).second.second); return (*result.first).second.first; }
RelationData::RelationData(UmlCode e, int id) : Labeled<RelationData>(all, id), is_deleted(FALSE), is_unconsistent(FALSE), type(e) { a.isa_class_relation = b.isa_class_relation = FALSE; a.isa_volatile_relation = b.isa_volatile_relation = FALSE; a.isa_const_relation = b.isa_const_relation = FALSE; a.is_derived = b.is_derived = FALSE; a.is_derivedunion = b.is_derivedunion = FALSE; a.is_ordered = b.is_ordered = FALSE; a.is_unique = b.is_unique = FALSE; a.uml_visibility = b.uml_visibility = UmlDefaultVisibility; a.cpp_virtual_inheritance = b.cpp_virtual_inheritance = FALSE; a.cpp_visibility = b.cpp_visibility = UmlDefaultVisibility; a.cpp_mutable = b.cpp_mutable = FALSE; a.java_transient = b.java_transient = FALSE; a.idl_truncatable_inheritance = b.idl_truncatable_inheritance = FALSE; a.idl_case = b.idl_case = 0; name = default_name(e); start = end = 0; end_removed_from = 0; original_id = 0; }
RelationData * RelationData::read(char *& st, char *& k, BrowserRelation *& unconsistent) { unconsistent = 0; RelationData * result; int id; if (!strcmp(k, "relation_ref")) { if ((result = all[id = read_id(st)]) == 0) result = new RelationData(UmlRelations/*!!*/, id); k = read_keyword(st); return result; } else if (!strcmp(k, "relation")) { if ((result = all[id = read_id(st)]) == 0) result = new RelationData(relation_type(read_keyword(st)), id); else if (result->type != UmlRelations) { // shared identifier result->set_unconsistent(); unconsistent = result->start; result = new RelationData(relation_type(read_keyword(st)), id); result->set_unconsistent(); } else { result->type = relation_type(read_keyword(st)); result->name = default_name(result->type); if (result->start != 0) { // Created by RelationData::read_ref() // invalidate start/end to not delete result // when start/end will be deleted result->start->invalidate(); result->end->invalidate(); } } k = read_keyword(st); if (!strcmp(k, "name")) { result->name = read_string(st); k = read_keyword(st); } result->BasicData::read(st, k); // updates k if (in_lib_import()) { result->original_id = id; if (! strcmp(k, "oid")) { // a sub lib is imported as a part of the imported lib (void) read_id(st); k = read_keyword(st); } } else if (! strcmp(k, "oid")) { result->original_id = read_id(st); k = read_keyword(st); } bool assoc = isa_association(result->type); if (strcmp(k, "a")) wrong_keyword(k, "a"); read_role(result->a, assoc, st, k, result); // updates k result->start = BrowserRelation::read_ref(st, k); read_keyword(st, "b"); if (!RelationData::uni_directional(result->type)) { read_role(result->b, assoc, st, k, result); // updates k result->end = BrowserRelation::read_ref(st, k); // 'end' may be read before 'start' : relation's type was unknown result->end->set_name(0); result->end->set_name(result->name); } else { k = read_keyword(st); if (!strcmp(k, "multiplicity")) { result->b.multiplicity = read_string(st); k = read_keyword(st); } else result->b.multiplicity = 0; if (strcmp(k, "parent")) wrong_keyword(k, "parent"); result->end_removed_from = BrowserClass::read_ref(st); result->b.uml_visibility = ((BrowserNode *) result->end_removed_from->parent())->get_visibility(UmlRelations); connect(result->end_removed_from->get_data(), SIGNAL(deleted()), result, SLOT(end_deleted())); result->end = 0; // manage old declarations switch (result->type) { case UmlRealize: case UmlGeneralisation: if (result->a.cpp_decl == "Generated") result->a.cpp_decl = "${type}"; if (result->a.java_decl == "Generated") result->a.java_decl = "${type}"; if (result->a.idl_decl == "Generated") result->a.idl_decl = "${type}"; break; case UmlDependency: if (!result->a.cpp_decl.isEmpty()) { if (result->stereotype == "friend") result->a.cpp_decl = "${type}"; else if ((result->a.cpp_decl == "Generated") || (result->a.cpp_decl == "${type}")) result->a.cpp_decl = "#include in header"; else if ((result->a.cpp_decl == "#include in source") && (read_file_format() < 56)) IncludeToHeaderIfExternal.append(result); } break; default: break; } } k = read_keyword(st); AType t; if (!strcmp(k, "association_type") || !strcmp(k, "association_explicit_type")) { t.read(st, "association_type", "association_explicit_type", k); result->set_association(t); k = read_keyword(st); } return result; } else return 0; }