константными, добавлена инициализация членов класса в конструкторе
//-----------------------------------------------------------------------------
STG_PINGER::STG_PINGER(time_t d)
//-----------------------------------------------------------------------------
STG_PINGER::STG_PINGER(time_t d)
+ : delay(d),
+ nonstop(false),
+ isRunningRecver(false),
+ isRunningSender(false),
+ sendSocket(-1),
+ recvSocket(-1),
+ pid(0)
pthread_mutex_init(&mutex, NULL);
pthread_mutex_init(&mutex, NULL);
}
//-----------------------------------------------------------------------------
STG_PINGER::~STG_PINGER()
}
//-----------------------------------------------------------------------------
STG_PINGER::~STG_PINGER()
ipToDel.erase(ipToDel.begin(), ipToDel.end());
}
//-----------------------------------------------------------------------------
ipToDel.erase(ipToDel.begin(), ipToDel.end());
}
//-----------------------------------------------------------------------------
-int STG_PINGER::GetPingIPNum()
+int STG_PINGER::GetPingIPNum() const
{
return pingIP.size();
}
//-----------------------------------------------------------------------------
{
return pingIP.size();
}
//-----------------------------------------------------------------------------
-void STG_PINGER::GetAllIP(vector<PING_IP_TIME> *)
+/*void STG_PINGER::GetAllIP(vector<PING_IP_TIME> *) const
{
//STG_LOCKER lock(&mutex, __FILE__, __LINE__);
{
//STG_LOCKER lock(&mutex, __FILE__, __LINE__);
//-----------------------------------------------------------------------------
void STG_PINGER::PrintAllIP()
{
//-----------------------------------------------------------------------------
void STG_PINGER::PrintAllIP()
{
}
//-----------------------------------------------------------------------------
}
//-----------------------------------------------------------------------------
-int STG_PINGER::GetIPTime(uint32_t ip, time_t * t)
+int STG_PINGER::GetIPTime(uint32_t ip, time_t * t) const
{
STG_LOCKER lock(&mutex, __FILE__, __LINE__);
{
STG_LOCKER lock(&mutex, __FILE__, __LINE__);
- multimap<uint32_t, time_t>::iterator treeIter;
+ multimap<uint32_t, time_t>::const_iterator treeIter;
treeIter = pingIP.find(ip);
if (treeIter == pingIP.end())
treeIter = pingIP.find(ip);
if (treeIter == pingIP.end())
delay = d;
}
//-----------------------------------------------------------------------------
delay = d;
}
//-----------------------------------------------------------------------------
-time_t STG_PINGER::GetDelayTime()
+time_t STG_PINGER::GetDelayTime() const
{
return delay;
}
//-----------------------------------------------------------------------------
{
return delay;
}
//-----------------------------------------------------------------------------
-string STG_PINGER::GetStrError()
+string STG_PINGER::GetStrError() const
return NULL;
}
//-----------------------------------------------------------------------------
return NULL;
}
//-----------------------------------------------------------------------------
#ifndef PINGER_H
#define PINGER_H
#ifndef PINGER_H
#define PINGER_H
#include <string>
#include <vector>
#include <list>
#include <string>
#include <vector>
#include <list>
int Stop();
void AddIP(uint32_t ip);
void DelIP(uint32_t ip);
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 GetAllIP(vector<PING_IP_TIME> * ipTime) const;
- int GetIPTime(uint32_t ip, time_t * t);
+ int GetIPTime(uint32_t ip, time_t * t) const;
void SetDelayTime(time_t delay);
void SetDelayTime(time_t delay);
- time_t GetDelayTime();
- string GetStrError();
+ time_t GetDelayTime() const;
+ string GetStrError() const;
+ 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);
PING_MESSAGE pmSend;
uint32_t pid;
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;
multimap<uint32_t, time_t> pingIP;
list<uint32_t> ipToAdd;
list<uint32_t> ipToDel;
string errorStr;
multimap<uint32_t, time_t> pingIP;
list<uint32_t> ipToAdd;
list<uint32_t> ipToDel;
+ mutable pthread_mutex_t mutex;
};
//-----------------------------------------------------------------------------
#endif
};
//-----------------------------------------------------------------------------
#endif