- char key[INSTR_DEFAULT_STR_SIZE];
- snprintf(key, INSTR_DEFAULT_STR_SIZE, "%s-%s-%s", name, source->getId(), dest->getId());
- Type* ret = new Type(name, key, "", TYPE_LINK, father);
- XBT_DEBUG("LinkType %s(%s), child of %s(%s) %s(%s)->%s(%s)", ret->getCname(), ret->getId(), father->getCname(),
- father->getId(), source->getCname(), source->getId(), dest->getCname(), dest->getId());
- LogLinkTypeDefinition(ret, source, dest);
+Type* Type::by_name(const std::string& name)
+{
+ Type* ret = nullptr;
+ for (auto const& elm : children_) {
+ if (elm.second->name_ == name) {
+ if (ret != nullptr) {
+ throw TracingError(XBT_THROW_POINT, "there are two children types with the same name?");
+ } else {
+ ret = elm.second.get();
+ }
+ }
+ }
+ if (ret == nullptr)
+ throw TracingError(XBT_THROW_POINT, xbt::string_printf("type with name (%s) not found in father type (%s)",
+ name.c_str(), get_cname()));