]> git.stg.codes - stg.git/blobdiff - stglibs/pinger.lib/pinger.h
Fix some prefix increments to postfix and code cleanup
[stg.git] / stglibs / pinger.lib / pinger.h
index 4349eb07ab929165c803efabe7753b8f19752311..f1f442e136eafacfe8c70eabb4487754b4be4d90 100644 (file)
@@ -7,9 +7,8 @@
 #ifndef PINGER_H
 #define PINGER_H
 
-#include <time.h>
+#include <ctime>
 #include <string>
-#include <vector>
 #include <list>
 #include <map>
 
@@ -30,8 +29,6 @@
 
 #include "os_int.h"
 
-using namespace std;
-
 //-----------------------------------------------------------------------------
 struct ICMP_HDR
 {
@@ -94,15 +91,22 @@ public:
     int     Stop();
     void    AddIP(uint32_t ip);
     void    DelIP(uint32_t ip);
-    int     GetPingIPNum();
-    void    GetAllIP(vector<PING_IP_TIME> * ipTime);
+    int     GetPingIPNum() const;
     void    PrintAllIP();
-    int     GetIPTime(uint32_t ip, time_t * t);
-    void    SetDelayTime(time_t delay);
-    time_t  GetDelayTime();
-    string  GetStrError();
+    int     GetIPTime(uint32_t ip, time_t * t) const;
+    void    SetDelayTime(time_t d) { delay = d; }
+    time_t  GetDelayTime() const { return delay; }
+    const std::string & GetStrError() const { return errorStr; }
 
 private:
+    uint16_t    PingCheckSum(void * data, int len);
+    int         SendPing(uint32_t ip);
+    uint32_t    RecvPing();
+    void        RealAddIP();
+    void        RealDelIP();
+
+    static void * RunSendPing(void * d);
+    static void * RunRecvPing(void * d);
 
     int         delay;
     bool        nonstop;
@@ -116,24 +120,13 @@ private:
     PING_MESSAGE pmSend;
     uint32_t    pid;
 
-    uint16_t    PingCheckSum(void * data, int len);
-    int         SendPing(uint32_t ip);
-    uint32_t    RecvPing();
-    void        RealAddIP();
-    void        RealDelIP();
-
-    static void * RunSendPing(void * d);
-    static void * RunRecvPing(void * d);
-
-    string      errorStr;
+    std::string errorStr;
 
-    multimap<uint32_t, time_t>   pingIP;
-    list<uint32_t>          ipToAdd;
-    list<uint32_t>          ipToDel;
+    std::multimap<uint32_t, time_t> pingIP;
+    std::list<uint32_t>          ipToAdd;
+    std::list<uint32_t>          ipToDel;
 
-    pthread_mutex_t mutex;
+    mutable pthread_mutex_t mutex;
 };
 //-----------------------------------------------------------------------------
 #endif
-
-