summaryrefslogtreecommitdiff
path: root/src/eHostInfoMgr.h
blob: 01603ba3b0f04002999ecd7567375e3883b96f28 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
 * eHostInfoMgr.h
 *
 *  Created on: 2013. 11. 14.
 *      Author: kos
 */

#ifndef EHOSTINFOMGR_H_
#define EHOSTINFOMGR_H_

#include <vector>
#include <string>

#include "uPosixSharedMemory.h"
//-------------------------------------------------------------------------------

typedef struct host_info_t {
	int pid;
	char ip[16];
} eHostInfo;
//-------------------------------------------------------------------------------

class eHostInfoMgr : public uPosixSharedMemory<eHostInfo>
{
private:
	int mInfoCount;
protected:
	void Erease(int aPid);
	bool IsTerminated(std::vector<int>& aList, int aPid);
public:
	eHostInfoMgr(std::string aName, int aInfoCount);
	virtual ~eHostInfoMgr();
	bool Init();
	bool Register(std::string aIpAddr, int aPid);
	void Unregister(std::string aIpAddr);
	void Update(std::string aIpAddr, int aPid);
	int IsExist(std::string aIpAddr);
#ifdef DEBUG_LOG
	void Dump(const char* aMessage);
#endif

	static std::string GetHostAddr();
	std::vector<int> FindPid(std::string aProcName, int aMyPid);
};
//-------------------------------------------------------------------------------

#endif /* EHOSTINFOMGR_H_ */