LCOV - code coverage report
Current view: top level - source/tools/atlas/GameInterface - MessagePasserImpl.cpp (source / functions) Hit Total Coverage
Test: 0 A.D. test coverage report Lines: 0 26 0.0 %
Date: 2023-01-19 00:18:29 Functions: 0 3 0.0 %

          Line data    Source code
       1             : /* Copyright (C) 2019 Wildfire Games.
       2             :  * This file is part of 0 A.D.
       3             :  *
       4             :  * 0 A.D. is free software: you can redistribute it and/or modify
       5             :  * it under the terms of the GNU General Public License as published by
       6             :  * the Free Software Foundation, either version 2 of the License, or
       7             :  * (at your option) any later version.
       8             :  *
       9             :  * 0 A.D. is distributed in the hope that it will be useful,
      10             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      11             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      12             :  * GNU General Public License for more details.
      13             :  *
      14             :  * You should have received a copy of the GNU General Public License
      15             :  * along with 0 A.D.  If not, see <http://www.gnu.org/licenses/>.
      16             :  */
      17             : 
      18             : #include "precompiled.h"
      19             : 
      20             : #include <cstdio>
      21             : 
      22             : #include "MessagePasserImpl.h"
      23             : #include "Messages.h"
      24             : #include "Handlers/MessageHandler.h"
      25             : 
      26             : #include "lib/timer.h"
      27             : #include "ps/CLogger.h"
      28             : 
      29             : using namespace AtlasMessage;
      30             : 
      31             : double last_user_activity = 0.0;
      32             : 
      33           0 : void MessagePasserImpl::Add(IMessage* msg)
      34             : {
      35           0 :     ENSURE(msg);
      36           0 :     ENSURE(msg->GetType() == IMessage::Message);
      37             : 
      38           0 :     if (m_Trace)
      39           0 :         debug_printf("%8.3f add message: %s\n", timer_Time(), msg->GetName());
      40             : 
      41           0 :     msgHandlers::const_iterator it = GetMsgHandlers().find(msg->GetName());
      42           0 :     if (it != GetMsgHandlers().end())
      43             :     {
      44           0 :         it->second(msg);
      45             :     }
      46             :     else
      47             :     {
      48           0 :         debug_warn(L"Unrecognised message");
      49             :         // CLogger might not be initialised, but this error will be sent
      50             :         // to the debug output window anyway so people can still see it
      51           0 :         LOGERROR("Unrecognised message (%s)", msg->GetName());
      52             :     }
      53             :     // Delete the object - we took ownership of it.
      54           0 :     AtlasMessage::ShareableDelete(msg);
      55           0 : }
      56             : 
      57           0 : void MessagePasserImpl::Query(QueryMessage* msg, void(* UNUSED(timeoutCallback) )())
      58             : {
      59           0 :     ENSURE(msg);
      60           0 :     ENSURE(msg->GetType() == IMessage::Query);
      61             : 
      62           0 :     if (m_Trace)
      63           0 :         debug_printf("%8.3f add query: %s\n", timer_Time(), msg->GetName());
      64             : 
      65           0 :     msgHandlers::const_iterator it = GetMsgHandlers().find(msg->GetName());
      66           0 :     if (it != GetMsgHandlers().end())
      67             :     {
      68           0 :         it->second(msg);
      69             :     }
      70             :     else
      71             :     {
      72           0 :         debug_warn(L"Unrecognised message");
      73             :         // CLogger might not be initialised, but this error will be sent
      74             :         // to the debug output window anyway so people can still see it
      75           0 :         LOGERROR("Unrecognised message (%s)", msg->GetName());
      76             :     }
      77           0 : }
      78             : 
      79           0 : void MessagePasserImpl::SetTrace(bool t)
      80             : {
      81           0 :     m_Trace = t;
      82           0 : }

Generated by: LCOV version 1.13