| 80 | } |
| 81 | |
| 82 | Int StreamHandler::registerStream(StreamType const type, const String & stream_name) |
| 83 | { |
| 84 | Int state = 1; |
| 85 | |
| 86 | if (name_to_stream_map_.count(stream_name) == 0) // this is an unknown stream .. register |
| 87 | { |
| 88 | name_to_stream_map_[stream_name] = createStream_(type, stream_name); |
| 89 | name_to_type_map_[stream_name] = type; |
| 90 | name_to_counter_map_[stream_name] = 1; |
| 91 | |
| 92 | // check stream |
| 93 | if (name_to_stream_map_[stream_name]->fail()) |
| 94 | { |
| 95 | state = 1; // indicate that something went wrong while creating this stream |
| 96 | } |
| 97 | } |
| 98 | else |
| 99 | { |
| 100 | // check type consistency |
| 101 | if (name_to_type_map_[stream_name] != type) |
| 102 | { |
| 103 | throw Exception::IllegalArgument(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "This stream was already registered with a different type."); |
| 104 | } |
| 105 | ++name_to_counter_map_[stream_name]; |
| 106 | } |
| 107 | |
| 108 | return state; |
| 109 | } |
| 110 | |
| 111 | bool StreamHandler::hasStream(const StreamType type, const String & stream_name) |
| 112 | { |
no test coverage detected