Advertisement
abagrintsev

PingProcess.h (new)

Sep 3rd, 2015
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.37 KB | None | 0 0
  1. #ifndef PINGPROCESS_H
  2. #define PINGPROCESS_H
  3.  
  4. #include <string>
  5. #include <boost/thread/mutex.hpp>
  6. #include <boost/asio.hpp>
  7. #include <boost/bind.hpp>
  8. #include <boost/asio/time_traits.hpp>
  9. #include <boost/date_time/posix_time/posix_time.hpp>
  10. #include <boost/asio/signal_set.hpp>
  11. #include <Logging_Controller.h>
  12. #include "Icmp_header.hpp"
  13. #include "Ipv4_header.hpp"
  14.  
  15. class Ping;
  16.  
  17. class PingProcess : public boost::noncopyable
  18. {
  19. friend Ping;
  20.  
  21. public:
  22.     const int timeout_to_fail = 1,
  23.         timeout_to_send_request = 60,
  24.         timeout_to_read_reply = 5;
  25.    
  26. private:
  27.    
  28.     Ping *parent;
  29.    
  30.     boost::asio::ip::icmp::endpoint m_destination;
  31.     unsigned short m_sequence_number;
  32.     boost::asio::ip::icmp::resolver *m_resolver;
  33.     boost::posix_time::ptime m_time_sent;
  34.     boost::asio::deadline_timer *m_timer;
  35.     boost::asio::streambuf *m_reply_buffer;
  36.     std::size_t m_num_replies;
  37.     boost::asio::ip::icmp::socket *m_socket;
  38.     int m_camera_availability;
  39.     boost::mutex m_synclock;
  40.     bool m_stop;
  41.    
  42.     void HandleTimeout();
  43.     void HandleReceive ( std::size_t length );
  44.     std::string UUID;
  45.     int m_ping_process_id;
  46.     int m_num_timeout;
  47.    
  48.     void StartSend();
  49.     void StartReceive();
  50.     bool Init();
  51.     bool Query ( std::string destination );
  52.    
  53. public:
  54.     PingProcess ( Ping *parent );
  55.     ~PingProcess();
  56.    
  57.     /*
  58.     PingProcess& operator=(const PingProcess& other);
  59.     PingProcess(const PingProcess& other);
  60.     bool operator==(const PingProcess& other) const;*/
  61.     //short unsigned int GetIdentidier();
  62.    
  63.     /**
  64.     * Установить ID для камеры или объекта
  65.     * @param uuid - идентификатор камеры
  66.     */
  67.     void SetUUID ( std::string uuid );
  68.     /**
  69.     * Пометить камеру как недоступную
  70.     * @param uuid - идентификатор камеры
  71.     */
  72.     void SetCameraUnavailable ( std::string uuid );
  73.     /**
  74.     * Пометить камеру как доступную
  75.     * @param uuid - идентификатор камеры
  76.     */
  77.     void SetCameraAvailable ( std::string uuid );
  78.     /**
  79.      * Идентификатор процесса пингера. Нужен, чтобы отличать пришедшие пакеты между процессами.
  80.     * @param ID - уникальное число
  81.     */
  82.     void SetPingProcessID ( int ID );
  83.     /**
  84.      * Что пингуем?
  85.      * @return - строка с IP
  86.      */
  87.     std::string GetIP();
  88. };
  89.  
  90. #endif // PINGPROCESS_H
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement