| 69 | } |
| 70 | |
| 71 | void FeatureXMLFile::store(const String& filename, const FeatureMap& feature_map) |
| 72 | { |
| 73 | |
| 74 | if (!FileHandler::hasValidExtension(filename, FileTypes::FEATUREXML)) |
| 75 | { |
| 76 | throw Exception::UnableToCreateFile(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, filename, "invalid file extension, expected '" + FileTypes::typeToName(FileTypes::FEATUREXML) + "'"); |
| 77 | } |
| 78 | |
| 79 | if (Size invalid_unique_ids = feature_map.applyMemberFunction(&UniqueIdInterface::hasInvalidUniqueId)) |
| 80 | { |
| 81 | |
| 82 | // TODO Take care *outside* that this does not happen. |
| 83 | // We can detect this here but it is too late to fix the problem; |
| 84 | // there is no straightforward action to be taken in all cases. |
| 85 | // Note also that we are given a const reference. |
| 86 | OPENMS_LOG_INFO << String("FeatureXMLHandler::store(): found ") + invalid_unique_ids + " invalid unique ids" << std::endl; |
| 87 | } |
| 88 | |
| 89 | // This will throw if the unique ids are not unique, |
| 90 | // so we never create bad files in this respect. |
| 91 | try |
| 92 | { |
| 93 | feature_map.updateUniqueIdToIndex(); |
| 94 | } |
| 95 | catch (Exception::Postcondition& e) |
| 96 | { |
| 97 | OPENMS_LOG_FATAL_ERROR << e.getName() << ' ' << e.what() << std::endl; |
| 98 | throw; |
| 99 | } |
| 100 | |
| 101 | Internal::FeatureXMLHandler handler(feature_map, filename); |
| 102 | handler.setOptions(options_); |
| 103 | handler.setLogType(getLogType()); |
| 104 | save_(filename, &handler); |
| 105 | } |
| 106 | |
| 107 | FeatureFileOptions& FeatureXMLFile::getOptions() |
| 108 | { |
no test coverage detected