| 364 | } |
| 365 | |
| 366 | bool mitk::MultiLabelIOHelper::PropertyFromXMLElement(std::string &key, |
| 367 | mitk::BaseProperty::Pointer &prop, |
| 368 | const tinyxml2::XMLElement *elem) |
| 369 | { |
| 370 | const char* typeC = elem->Attribute("type"); |
| 371 | std::string type = nullptr != typeC |
| 372 | ? typeC |
| 373 | : ""; |
| 374 | |
| 375 | const char* keyC = elem->Attribute("key"); |
| 376 | key = nullptr != keyC |
| 377 | ? keyC |
| 378 | : ""; |
| 379 | |
| 380 | // construct name of serializer class |
| 381 | std::string serializername(type); |
| 382 | serializername += "Serializer"; |
| 383 | |
| 384 | std::list<itk::LightObject::Pointer> allSerializers = |
| 385 | itk::ObjectFactoryBase::CreateAllInstance(serializername.c_str()); |
| 386 | if (allSerializers.size() < 1) |
| 387 | MITK_ERROR << "No serializer found for " << type << ". Skipping object"; |
| 388 | |
| 389 | if (allSerializers.size() > 1) |
| 390 | MITK_WARN << "Multiple deserializers found for " << type << "Using arbitrarily the first one."; |
| 391 | |
| 392 | for (auto iter = allSerializers.begin(); iter != allSerializers.end(); |
| 393 | ++iter) |
| 394 | { |
| 395 | if (auto *serializer = dynamic_cast<BasePropertySerializer *>(iter->GetPointer())) |
| 396 | { |
| 397 | try |
| 398 | { |
| 399 | prop = serializer->Deserialize(elem->FirstChildElement()); |
| 400 | } |
| 401 | catch (std::exception &e) |
| 402 | { |
| 403 | MITK_ERROR << "Deserializer " << serializer->GetNameOfClass() << " failed: " << e.what(); |
| 404 | return false; |
| 405 | } |
| 406 | break; |
| 407 | } |
| 408 | } |
| 409 | if (prop.IsNull()) |
| 410 | return false; |
| 411 | return true; |
| 412 | } |
| 413 | |
| 414 | int mitk::MultiLabelIOHelper::GetIntByKey(const itk::MetaDataDictionary& dic, const std::string& str) |
| 415 | { |
nothing calls this directly
no test coverage detected