mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 02:50:04 +00:00 
			
		
		
		
	Update alert signal to include message index, so messages aren't missed
This commit is contained in:
		
							parent
							
								
									5784abc117
								
							
						
					
					
						commit
						1c5e0d51b7
					
				
					 4 changed files with 16 additions and 12 deletions
				
			
		|  | @ -40,17 +40,17 @@ public: | |||
| TextEventManager::TextEventManager() : p(std::make_unique<Impl>(this)) {} | ||||
| TextEventManager::~TextEventManager() = default; | ||||
| 
 | ||||
| std::list<std::shared_ptr<awips::TextProductMessage>> | ||||
| std::vector<std::shared_ptr<awips::TextProductMessage>> | ||||
| TextEventManager::message_list(const types::TextEventKey& key) const | ||||
| { | ||||
|    std::list<std::shared_ptr<awips::TextProductMessage>> messageList {}; | ||||
|    std::vector<std::shared_ptr<awips::TextProductMessage>> messageList {}; | ||||
| 
 | ||||
|    std::shared_lock lock(p->textEventMutex_); | ||||
| 
 | ||||
|    auto it = p->textEventMap_.find(key); | ||||
|    if (it != p->textEventMap_.cend()) | ||||
|    { | ||||
|       messageList = it->second; | ||||
|       messageList.assign(it->second.begin(), it->second.end()); | ||||
|    } | ||||
| 
 | ||||
|    return messageList; | ||||
|  | @ -109,14 +109,16 @@ void TextEventManager::Impl::HandleMessage( | |||
|    // Find a matching event in the event map
 | ||||
|    auto&               vtecString = segments[0]->header_->vtecString_; | ||||
|    types::TextEventKey key {vtecString[0].pVtec_}; | ||||
|    auto                it      = textEventMap_.find(key); | ||||
|    bool                updated = false; | ||||
|    size_t              messageIndex = 0; | ||||
|    auto                it           = textEventMap_.find(key); | ||||
|    bool                updated      = false; | ||||
| 
 | ||||
|    if (it == textEventMap_.cend()) | ||||
|    { | ||||
|       // If there was no matching event, add the message to a new event
 | ||||
|       textEventMap_.emplace(key, std::list {message}); | ||||
|       updated = true; | ||||
|       messageIndex = 0; | ||||
|       updated      = true; | ||||
|    } | ||||
|    else if (std::find_if(it->second.cbegin(), | ||||
|                          it->second.cend(), | ||||
|  | @ -128,6 +130,7 @@ void TextEventManager::Impl::HandleMessage( | |||
|       // If there was a matching event, and this message has not been stored
 | ||||
|       // (WMO header equivalence check), add the updated message to the existing
 | ||||
|       // event
 | ||||
|       messageIndex = it->second.size(); | ||||
|       it->second.push_back(message); | ||||
|       updated = true; | ||||
|    }; | ||||
|  | @ -136,7 +139,7 @@ void TextEventManager::Impl::HandleMessage( | |||
| 
 | ||||
|    if (updated) | ||||
|    { | ||||
|       emit self_->AlertUpdated(key); | ||||
|       emit self_->AlertUpdated(key, messageIndex); | ||||
|    } | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -23,7 +23,7 @@ public: | |||
|    explicit TextEventManager(); | ||||
|    ~TextEventManager(); | ||||
| 
 | ||||
|    std::list<std::shared_ptr<awips::TextProductMessage>> | ||||
|    std::vector<std::shared_ptr<awips::TextProductMessage>> | ||||
|    message_list(const types::TextEventKey& key) const; | ||||
| 
 | ||||
|    void LoadFile(const std::string& filename); | ||||
|  | @ -31,7 +31,7 @@ public: | |||
|    static TextEventManager& Instance(); | ||||
| 
 | ||||
| signals: | ||||
|    void AlertUpdated(const types::TextEventKey& key); | ||||
|    void AlertUpdated(const types::TextEventKey& key, size_t messageIndex); | ||||
| 
 | ||||
| private: | ||||
|    class Impl; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat