PingThread.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. ** Command & Conquer Generals Zero Hour(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. ////////////////////////////////////////////////////////////////////////////////
  19. // //
  20. // (c) 2001-2003 Electronic Arts Inc. //
  21. // //
  22. ////////////////////////////////////////////////////////////////////////////////
  23. // FILE: PingThread.h //////////////////////////////////////////////////////
  24. // Generals ping thread class interface
  25. // Author: Matthew D. Campbell, August 2002
  26. // Note: adapted from WOLAPI
  27. #pragma once
  28. #ifndef __PINGTHREAD_H__
  29. #define __PINGTHREAD_H__
  30. // this class encapsulates a request for the thread
  31. class PingRequest
  32. {
  33. public:
  34. std::string hostname;
  35. Int repetitions;
  36. Int timeout;
  37. };
  38. //-------------------------------------------------------------------------
  39. // this class encapsulates a response from the thread
  40. class PingResponse
  41. {
  42. public:
  43. std::string hostname;
  44. Int avgPing;
  45. Int repetitions;
  46. };
  47. //-------------------------------------------------------------------------
  48. // this is the actual message queue used to pass messages between threads
  49. class PingerInterface
  50. {
  51. public:
  52. virtual ~PingerInterface() {}
  53. virtual void startThreads( void ) = 0;
  54. virtual void endThreads( void ) = 0;
  55. virtual Bool areThreadsRunning( void ) = 0;
  56. virtual void addRequest( const PingRequest& req ) = 0;
  57. virtual Bool getRequest( PingRequest& resp ) = 0;
  58. virtual void addResponse( const PingResponse& resp ) = 0;
  59. virtual Bool getResponse( PingResponse& resp ) = 0;
  60. static PingerInterface* createNewPingerInterface( void );
  61. virtual Bool arePingsInProgress( void ) = 0;
  62. virtual Int getPing( AsciiString hostname ) = 0;
  63. virtual void clearPingMap( void ) = 0;
  64. virtual AsciiString getPingString( Int timeout ) = 0;
  65. };
  66. extern PingerInterface *ThePinger;
  67. #endif // __PINGTHREAD_H__