| 121 | } |
| 122 | |
| 123 | void StreamHandler::unregisterStream(StreamType const type, const String & stream_name) |
| 124 | { |
| 125 | if (name_to_stream_map_.count(stream_name) != 0) // check if we know this stream |
| 126 | { |
| 127 | if (name_to_counter_map_[stream_name] > 1) |
| 128 | { |
| 129 | // if there are still references left to this stream |
| 130 | // just decrease the number of references |
| 131 | --name_to_counter_map_[stream_name]; |
| 132 | } |
| 133 | else |
| 134 | { |
| 135 | // delete the stream |
| 136 | if (type == FILE) |
| 137 | { |
| 138 | // file streams need to be closed before |
| 139 | (static_cast<ofstream *>(name_to_stream_map_[stream_name]))->close(); |
| 140 | } |
| 141 | |
| 142 | delete name_to_stream_map_[stream_name]; |
| 143 | |
| 144 | // remove entry from the local registry |
| 145 | name_to_stream_map_.erase(stream_name); |
| 146 | name_to_counter_map_.erase(stream_name); |
| 147 | name_to_type_map_.erase(stream_name); |
| 148 | } |
| 149 | } |
| 150 | else |
| 151 | { |
| 152 | throw Exception::ElementNotFound(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, stream_name); |
| 153 | } |
| 154 | } |
| 155 | |
| 156 | std::ostream & operator<<(std::ostream & os, StreamHandler const & stream_handler) |
| 157 | { |
no test coverage detected