lixioayao vor 6 Jahren
Ursprung
Commit
52c4cd6ba1
24 geänderte Dateien mit 156 neuen und 392165 gelöschten Zeilen
  1. 0 388908
      1222.raw
  2. 0 589
      IniFile.cpp
  3. 0 100
      IniFile.h
  4. 7 34
      Makefile
  5. 3 7
      Makefile.am
  6. 5 32
      Makefile.in
  7. BIN
      a.out
  8. 50 0
      area.cpp
  9. 4 52
      area.h
  10. 19 19
      autom4te.cache/requests
  11. 0 178
      c2.cpp
  12. 13 3
      card.cpp
  13. 1 0
      card.h
  14. 0 1181
      config.log
  15. 0 1057
      config.status
  16. BIN
      db_api.tar
  17. 8 0
      main.cpp
  18. 5 0
      message.h
  19. BIN
      tar.tar.gz
  20. BIN
      visit
  21. 5 1
      worker.cpp
  22. 5 2
      write-copy.h
  23. 1 0
      zloop.h
  24. 30 2
      znet.cpp

Datei-Diff unterdrückt, da er zu groß ist
+ 0 - 388908
1222.raw


+ 0 - 589
IniFile.cpp

@@ -1,589 +0,0 @@
-#include <assert.h>
-#include <fstream>
-#include <cstring>
-#include <algorithm>
-#include <stdio.h>
-#include "IniFile.h"
-
-#if _MSC_VER >=1400
-	const std::wstring to_wcs( const std::string& src )
-	{
-		std::string prev = setlocale(LC_CTYPE,NULL);	// 保存原来的locale
-		setlocale( LC_CTYPE, "chs" );					// 设置当前locale为chs,这在非简体中文平台上不可缺少
-
-		size_t count1 = mbstowcs(NULL, src.c_str(), 0); // 计算新字符串长度
-		std::wstring des(count1, L' ');
-		size_t count2 = mbstowcs(&des[0], src.c_str(), count1 ); // 转化
-		assert(count1 == count2);
-
-		setlocale( LC_CTYPE, prev.c_str()); // 恢复到原来的locale
-		return des;
-	}
-#endif
-
-	IniFile::IniFile()
-	{
-		m_prevInsertIt = m_lines.end();
-	}
-
-	IniFile::~IniFile (void)
-	{
-		clear();
-	}
-
-	bool IniFile::open(const char* filename)
-	{
-		assert(filename);
-
-		clear();
-#if _MSC_VER >=1400
-		std::wstring wcsfile = to_wcs(filename);
-		std::ifstream fin(wcsfile.c_str());	
-#else
-		std::ifstream fin(filename);
-#endif
-		if(fin.is_open())
-		{
-			while(!fin.eof()) 
-			{
-				std::string tmp;
-				getline(fin, tmp, '\n');
-				
-				if(fin.eof() && tmp.empty())
-					break;
-
-				// if *NIX file format, remove the CR
-				if(tmp.length() >= 1 && tmp[tmp.length()-1] == '\r')
-				{
-					tmp.resize(tmp.length()-1);
-				}
-				parseLine(tmp);
-			}
-			makeIndex();
-			return true;
-		}
-		return false;
-	}
-
-	bool IniFile::save(const char* filename)
-	{
-		assert(filename);
-#if _MSC_VER >=1400
-		std::wstring wcsfile = to_wcs(filename);
-		std::ofstream fout(wcsfile.c_str());
-#else
-		std::ofstream fout(filename);
-#endif
-		if(fout.is_open())
-		{
-			std::list<LineFrame*>::iterator it = m_lines.begin();
-			for(; it != m_lines.end(); ++it)
-			{
-				LineFrame* frame = *it;
-				switch(frame->m_type) 
-				{
-				case TYPE_COMMENT:
-					fout << frame->m_comment << std::endl;
-					break;
-				case TYPE_SECTION:
-					fout << "[" << frame->m_section << "]" << frame->m_comment << std::endl;
-					break;
-				case TYPE_KEYVALUE:
-					{
-						if(frame->m_valueHasComment)
-							fout << frame->m_key << "=\"" << frame->m_value << "\"" << frame->m_comment << std::endl;
-						else
-							fout << frame->m_key << "=" << frame->m_value << frame->m_comment << std::endl;
-						
-					}
-					break;
-				default:
-					break;
-				}
-			}
-			return true;
-		}
-		return false;
-	}
-
-	void IniFile::clear()
-	{
-		std::list<LineFrame*>::iterator it = m_lines.begin();
-		for(; it != m_lines.end(); ++it)
-			delete *it;
-		m_lines.clear();
-		m_lineindex.clear();
-	}
-
-	bool IniFile::readBool(const char* section, const char* key, bool dft)
-	{
-		assert(section);
-		assert(key);
-
-		LineFrame *frame = findNotEmptyFrame(section, key);
-		if(frame)
-		{
-			if(ignoreCaseCompare(frame->m_value,"true"))
-				return true;
-            else if(ignoreCaseCompare(frame->m_value,"false"))
-				return false;
-			else
-				return dft;
-		}
-		return dft;
-	}
-
-	int IniFile::readInt(const char* section, const char* key, int dft)
-	{
-		assert(section);
-		assert(key);
-
-		LineFrame *frame = findNotEmptyFrame(section, key);
-		if(frame)
-		{
-			if ( frame->m_value.length() > 2 && frame->m_value[0] == '0' && frame->m_value[1] == 'x' )
-			{
-				int value = dft;
-				sscanf(frame->m_value.c_str(), "0x%x", &value );
-				return value;
-			}
-			else if ( frame->m_value.length() > 2 && frame->m_value[0] == '0' && frame->m_value[1] == 'X' )
-			{
-				int value = dft;
-				sscanf(frame->m_value.c_str(), "0X%x", &value );
-				return value;
-			}
-			else
-			{
-				int value = dft;
-				sscanf(frame->m_value.c_str(), "%u", &value );
-				return value;
-			}
-		}
-		else
-		{
-			return dft;
-		}
-	}
-
-	double IniFile::readDouble(const char* section, const char* key, double dft)
-	{
-		assert(section);
-		assert(key);
-
-		LineFrame *frame = findNotEmptyFrame(section, key);
-		if(frame)
-		{
-			return atof(frame->m_value.c_str());			
-		}
-		else
-		{
-			return dft;
-		}
-	}
-
-	const char* IniFile::readString(const char* section, const char* key, const char* dft)
-	{
-		assert(section);
-		assert(key);
-
-		LineFrame *frame = findFrame(section, key);
-		if(frame)
-		{
-			return frame->m_value.c_str();
-		}
-		else
-		{
-			return dft;
-		}
-	}
-
-	void IniFile::writeBool(const char* section, const char* key, bool val)
-	{
-		assert(section);
-		assert(key);
-
-		if(val)
-			writeString(section, key, "true");
-		else
-			writeString(section, key, "false");
-	}
-	void IniFile::writeInt(const char* section, const char* key, int val)
-	{
-		assert(section);
-		assert(key);
-
-		char tmp[32];
-		sprintf(tmp, "%d", val);
-		writeString(section, key, tmp);
-	}
-
-	void IniFile::writeHex(const char* section, const char* key, uint32_t val)
-	{
-		assert(section);
-		assert(key);
-
-		char tmp[32];
-		sprintf(tmp, "0x%X", val);
-		writeString(section, key, tmp);
-	}
-
-	void IniFile::writeDouble(const char* section, const char* key, double val)
-	{
-		assert(section);
-		assert(key);
-
-		char tmp[32];
-		sprintf(tmp, "%g", val);
-		writeString(section, key, tmp);
-	}
-
-	void IniFile::writeString(const char* section, const char* key, const char* val)
-	{
-		assert(section);
-		assert(key);
-		assert(val);
-        
-		LineFrame *frame = findFrame(section, key);
-		if(frame)
-		{
-			// already exist, update it!
-			frame->m_value = val;
-			frame->m_valueHasComment = hasComment(val);
-		}
-		else
-		{	
-			std::list<LineFrame*>::iterator it;
-			// try cache, if failed then locate the end of this section
-			if(m_prevSection == section && m_prevInsertIt != m_lines.end())
-				it = m_prevInsertIt;
-			else
-				it = findSectionEnd(section);
-			 
-			// new key insert into near by section, it will speed up all write method;
-			// std::list<LineFrame*>::iterator it = findSection(section);
-			if(it != m_lines.end())
-			{
-				frame = new LineFrame;
-				frame->m_type = TYPE_KEYVALUE;
-				frame->m_key = key;
-				frame->m_value = val;
-				frame->m_valueHasComment = hasComment(val);
-				m_lines.insert(++it, frame);
-
-				m_prevSection = section;
-				m_prevInsertIt = --it;
-			}
-			else
-			{
-				// no section yet! create it!
-				frame = new LineFrame;
-				frame->m_type = TYPE_SECTION;
-				frame->m_section = section;
-				m_lines.push_back(frame);
-
-				frame = new LineFrame;
-				frame->m_type = TYPE_KEYVALUE;
-				frame->m_key = key;
-				frame->m_value = val;
-				frame->m_valueHasComment = hasComment(val);
-				m_lines.push_back(frame);
-			}
-			// update index
-			m_lineindex[section][key] = frame;
-		}
-	}
-
-	bool IniFile::hasSection(const char* section)
-	{
-		return m_lineindex.find(section) != m_lineindex.end();
-	}
-
-	bool IniFile::deleteSection(const char* section)
-	{
-		m_lineindex.erase(section);
-
-		std::list<LineFrame*>::iterator it = findSection(section);
-		if(it != m_lines.end())
-		{
-			// delete the section at first
-			delete *it;
-			m_lines.erase(it++);
-			// and delete all key-value until occurs next section(or end of file)
-			while(it != m_lines.end() && (*it)->m_type != TYPE_SECTION)
-			{
-				delete *it;
-				m_lines.erase(it++);
-			}
-			return true;
-		}
-		return false;
-	}
-	bool IniFile::deleteKey(const char* section, const char* key)
-	{
-		assert(section);
-		assert(key);
-
-		std::list<LineFrame*>::iterator it = findSection(section);
-		if (it == m_lines.end())
-		{
-			return false;
-		}
-		// find from next line
-		++it;
-		for( ; it != m_lines.end(); ++it)
-		{
-			if((*it)->m_type == TYPE_SECTION)
-			{	// occur next section
-				break;
-			}
-			if((*it)->m_type == TYPE_KEYVALUE &&
-                ignoreCaseCompare((*it)->m_key,key))
-			{
-				m_lineindex[section].erase(key);
-				delete *it;
-				m_lines.erase(it);
-				return true;
-			}
-		}
-		return false;
-	}
-
-	void IniFile::readSection(const char* section, std::map<std::string, std::string>& kvset)
-	{
-		assert(section);
-
-		std::list<LineFrame*>::iterator it = findSection(section);
-		if(it != m_lines.end())
-			++it;
-		for( ; it != m_lines.end(); ++it)
-		{
-			if((*it)->m_type == TYPE_SECTION)
-			{	// occur next section
-				break;
-			}
-			if((*it)->m_type == TYPE_KEYVALUE)
-			{
-				kvset.insert(std::make_pair((*it)->m_key, (*it)->m_value));
-			}
-		}
-	}
-
-	void IniFile::parseLine(const std::string& line) 
-	{
-		LineFrame* frame = new LineFrame;
-		m_lines.push_back(frame);
-		frame->m_type = TYPE_COMMENT; // dft is comment
-
-		// 1. check full commented line 
-		if(isCommentLine(line))
-		{
-			frame->m_type = TYPE_COMMENT;
-			frame->m_comment = line;
-			return ;
-		}
-
-		// 2. try the find section
-		std::string::size_type first = line.find('[');
-		std::string::size_type last = line.rfind(']');;
-
-		if(first != std::string::npos && last != std::string::npos && first != last+1)
-		{
-			frame->m_section = line.substr(first+1,last-first-1);
-			if(hasComment(frame->m_section))
-			{
-				frame->m_type = TYPE_COMMENT;
-				frame->m_comment = line;
-			}
-			else
-			{
-				frame->m_type = TYPE_SECTION;
-				// remember the possible comments
-				frame->m_comment = line.substr(last+1);
-			}
-			return ;
-		}
-
-		// 3. find key-value pattern
-		first = line.find('=');
-		if(first == std::string::npos)
-			return ;
-
-		std::string strtmp1 = line.substr(0, first);
-		if(hasComment(strtmp1))
-		{
-			// such case
-			// something # key=value
-			// we consider such meaningless line as comment
-			frame->m_type = TYPE_COMMENT;
-			frame->m_comment = line;
-			return ;
-		}
-
-		std::string key = constTrim(strtmp1);
-		if(key.empty())
-		{
-			// such case
-			// = value
-			frame->m_type = TYPE_COMMENT;
-			frame->m_comment = line;
-			return ;
-		}
-
-		frame->m_type = TYPE_KEYVALUE;
-		// remember the original form
-		frame->m_key = key;
-		std::string strtmp2 = line.substr(first+1);
-		std::string::size_type comment = findComment(strtmp2);
-		std::string value = constTrim(strtmp2.substr(0, comment));
-	
-		if(value.size()>1 && value[0] == '\"' && value[value.size()-1] == '\"')
-		{
-			frame->m_value = value.substr(1, value.size()-2);
-			frame->m_valueHasComment = true;
-		}
-		else
-		{
-			frame->m_value = value;
-		}
-
-		if(comment != std::string::npos)
-			frame->m_comment = constTrim(strtmp2.substr(comment));
-
-		return ;
-	}
-
-	std::string::size_type IniFile::findComment(const std::string& line)
-	{
-		bool inString = false;
-		for(size_t i=0; i<line.size(); i++)
-		{
-			if(line[i] == '\"')
-			{
-				inString = true;
-			}
-			
-			if(inString)
-				continue;
-
-			if(line[i] == '/')
-			{
-				// "//"
-				if(i+1 != line.length() && line[i+1] == '/')
-					return i;
-			}
-			else if(line[i] == '#' || line[i] == ';')
-			{
-				return i;
-			}
-		}
-		return std::string::npos;
-
-	}
-
-	bool IniFile::isCommentLine(const std::string& line)
-	{
-		// skip the space and tab chars
-		std::string::size_type charBegin = line.find_first_not_of("\t ");
-		return charBegin != std::string::npos && charBegin == findComment(line);
-	}
-
-	bool IniFile::hasComment(const std::string& line)
-	{
-		return findComment(line) != std::string::npos;
-	}
-
-	std::list<LineFrame*>::iterator IniFile::findSection(const char* section)
-	{
-		std::list<LineFrame*>::iterator it = m_lines.begin();
-		for( ; it != m_lines.end(); ++it)
-		{
-			LineFrame* frame = *it;
-			if(frame->m_type == TYPE_SECTION 
-				&& ignoreCaseCompare(frame->m_section,section))
-			{
-				break;
-			}
-		}
-		return it;
-	}
-	
-	std::list<LineFrame*>::iterator IniFile::findSectionEnd(const char* section)
-	{
-		std::list<LineFrame*>::iterator it = findSection(section);
-		if(it != m_lines.end())
-		{
-			// find from next line
-			++it;
-			while(it != m_lines.end() && (*it)->m_type != TYPE_SECTION)
-			{
-				++it;
-			}
-			// the end of section is one step back of next section line(or end())
-			--it;
-		}
-		return it;
-	}
-
-	LineFrame* IniFile::findFrame(const char*section, const char* key)
-	{
-		KeyValueIndex::iterator it = m_lineindex.find(section);
-		if(it != m_lineindex.end())
-		{
-			KeyValueMap::iterator it2 = it->second.find(key);
-			if(it2 != it->second.end())
-				return it2->second;
-		}
-		return 0;
-	}
-
-	LineFrame* IniFile::findNotEmptyFrame(const char*section, const char* key)
-	{
-		LineFrame* frame = findFrame(section, key);
-		if(frame && !frame->m_value.empty())
-			return frame;
-		else
-			return 0;
-	}
-
-	void IniFile::makeIndex()
-	{
-		std::list<LineFrame*>::iterator it = m_lines.begin();
-		LineFrame* frame = NULL;
-		KeyValueIndex::iterator kvmit = m_lineindex.end();
-		while(it != m_lines.end())
-		{
-			frame = *it;
-			++it;
-
-			// 找到了一个SECTION的开始
-			if(frame->m_type == TYPE_SECTION)
-			{
-				kvmit = (m_lineindex.insert(std::make_pair(frame->m_section, KeyValueMap()))).first;
-			}
-			else if(frame->m_type == TYPE_KEYVALUE && kvmit != m_lineindex.end())
-			{
-				(kvmit->second)[frame->m_key]= frame;
-			}
-		}
-	}
-#ifdef __TEST
-int main()
-{
-    IniFile ini;
-    ini.open("config.ini");
-    std::string host = ini.readString("db","host","");
-    std::string url = ini.readString("serversetting","web1","");
-    if(!host.empty())
-      printf("%s\n",host.c_str());
-    printf("%s\n",url.c_str());
-    ini.writeInt("dbdb","timeout",123);
-    ini.writeInt("db","a",123123);
-    ini.writeInt("db01","a",123);
-    ini.writeString("xxxx","name","lemon");
-    printf("tol:%d\n",ini.readInt("serversetting","timeout",0));
-    //clear all
-    //ini.clear(); 
-    ini.save("config.ini");
-}
-#endif

+ 0 - 100
IniFile.h

@@ -1,100 +0,0 @@
-#ifndef INCLUDED_CACTI_UTIL_INIFILE_H
-#define INCLUDED_CACTI_UTIL_INIFILE_H
-
-#include <string>
-#include <list>
-#include <map>
-#include <functional>
-
-    enum LINETYPE {
-        TYPE_SECTION    = 1,
-        TYPE_KEYVALUE   = 2,
-        TYPE_COMMENT    = 3,
-    };
-
-    class LineFrame
-    {
-        public:
-            LineFrame()
-                : m_valueHasComment(false)
-            {}
-            LINETYPE m_type;
-            std::string m_section;		// when TYPE_SECTION
-            std::string m_key;			// when TYPE_KEYVALUE
-            std::string m_value;		// when TYPE_KEYVALUE
-            bool m_valueHasComment;		// value 字段是否包含有注释字符,用引号引住的value可以包含注释字符
-            std::string m_comment; 		// all case
-    };
-    typedef std::map<std::string, LineFrame*> KeyValueMap; // key--->frame
-    typedef std::map<std::string, KeyValueMap> KeyValueIndex;
-    class IniFile
-    {		
-        public:
-            IniFile();
-            ~IniFile(void);
-            bool open(const char* filename);
-            bool save(const char* filename);
-            void clear();
-
-            bool readBool(const char* section, const char* key, bool dft);
-            int readInt(const char* section, const char* key, int dft);
-            double readDouble(const char* section, const char* key, double dft);
-            const char* readString(const char* section, const char* key, const char* dft);
-
-            void writeBool(const char* section, const char* key, bool val);
-            void writeInt(const char* section, const char* key, int val);
-            void writeDouble(const char* section, const char* key, double val);
-            void writeString(const char* section, const char* key, const char* val);
-            void writeHex(const char* section, const char* key, std::uint32_t val);
-
-            bool hasSection(const char* section);
-            bool deleteSection(const char* section);
-            bool deleteKey(const char* section, const char* key);
-            void readSection(const char* section, std::map<std::string, std::string>& kvset);
-        private:
-            void parseLine(const std::string& line);
-            std::string::size_type findComment(const std::string& line);
-            std::string::size_type findValueComment(const std::string& line);
-            bool isCommentLine(const std::string& line);
-            bool hasComment(const std::string& line);
-            std::list<LineFrame*>::iterator findSection(const char* section);
-            std::list<LineFrame*>::iterator findSectionEnd(const char* section);
-            LineFrame* findFrame(const char*section, const char* key);
-            LineFrame* findNotEmptyFrame(const char*section, const char* key);
-            void makeIndex();
-            std::string constTrim(const std::string& s) 
-            {
-                if(s.empty())
-                  return s;
-                std::string::size_type b = s.find_first_not_of(" \t");
-                if(b == std::string::npos) // No non-spaces
-                  return "";
-                std::string::size_type e = s.find_last_not_of(" \t");
-                return std::string(s, b, e - b + 1);
-            }
-            bool ignoreCaseCompare(const std::string& left, const std::string& right)
-            {
-                std::string tmpleft = constTrim(left);
-                std::string tmpright= constTrim(right);
-                toUpper(tmpleft);
-                toUpper(tmpright);
-                return tmpleft == tmpright;
-            }
-            void toUpper(std::string& str)
-            {
-                for(size_t i=0; i<str.length(); i++)
-                  str[i] = ::toupper(str[i]);
-            }
-
-            void toLower(std::string& str)
-            {
-                for(size_t i=0; i<str.length(); i++)
-                  str[i] = ::tolower(str[i]);
-            }
-        private:
-            std::list<LineFrame*> m_lines;
-            KeyValueIndex m_lineindex;		// section --> KeyValueMap
-            std::string m_prevSection;
-            std::list<LineFrame*>::iterator m_prevInsertIt;
-    };
-#endif // INCLUDED_CACTI_UTIL_INIFILE_H

+ 7 - 34
Makefile

@@ -49,8 +49,7 @@ NORMAL_UNINSTALL = :
 PRE_UNINSTALL = :
 POST_UNINSTALL = :
 bin_PROGRAMS = yals$(EXEEXT)
-noinst_PROGRAMS = client$(EXEEXT) async$(EXEEXT) test$(EXEEXT) \
-	visit$(EXEEXT)
+noinst_PROGRAMS = client$(EXEEXT) async$(EXEEXT) test$(EXEEXT)
 subdir = .
 DIST_COMMON = $(am__configure_deps) $(srcdir)/Makefile.am \
 	$(srcdir)/Makefile.in $(top_srcdir)/configure COPYING INSTALL \
@@ -82,11 +81,6 @@ test_OBJECTS = $(am_test_OBJECTS)
 test_LDADD = $(LDADD)
 test_LINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(test_LDFLAGS) \
 	$(LDFLAGS) -o $@
-am_visit_OBJECTS = visit-visit.$(OBJEXT)
-visit_OBJECTS = $(am_visit_OBJECTS)
-visit_LDADD = $(LDADD)
-visit_LINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(visit_LDFLAGS) \
-	$(LDFLAGS) -o $@
 am__objects_1 = yals-singleton_test_class1.$(OBJEXT) \
 	yals-wsClient.$(OBJEXT) yals-wsClientMgr.$(OBJEXT) \
 	yals-wsTimerThread.$(OBJEXT) yals-CDBConnect.$(OBJEXT) \
@@ -121,9 +115,9 @@ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
 CCLD = $(CC)
 LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
 SOURCES = $(async_SOURCES) $(client_SOURCES) $(test_SOURCES) \
-	$(visit_SOURCES) $(yals_SOURCES)
+	$(yals_SOURCES)
 DIST_SOURCES = $(async_SOURCES) $(client_SOURCES) $(test_SOURCES) \
-	$(visit_SOURCES) $(yals_SOURCES)
+	$(yals_SOURCES)
 am__can_run_installinfo = \
   case $$AM_UPDATE_INFO_DIR in \
     n|no|NO) false;; \
@@ -158,12 +152,12 @@ AUTOMAKE = ${SHELL} /home/lemon/resource/ya-serv/missing --run automake-1.12
 AWK = gawk
 CC = gcc
 CCDEPMODE = depmode=gcc3
-CFLAGS = -g 
+CFLAGS = -g -O2
 CPP = gcc -E
 CPPFLAGS = 
 CXX = g++
 CXXDEPMODE = depmode=gcc3
-CXXFLAGS = -g 
+CXXFLAGS = -g -O2
 CYGPATH_W = echo
 DEFS = 
 DEPDIR = .deps
@@ -247,8 +241,8 @@ crc.cpp crc.h io_buf.h line.h loc_tool.cpp loc_tool.h message.cpp \
 message_file.h message.h net-service.cpp net-service.h point.cpp point.h tdoa_sync.cpp tdoa_sync.h \
 worker.cpp worker.h zio.h zloop.h znet.cpp znet.h zstream.h site_area.cpp  site_area.h area.h area.cpp
 
-AM_CPPFLAGS = -Wall -pthread -m64 -std=c++11 -fPIC -I${prefix}/include -I./src -I$(prefix)/mysql/include -I../include/websocketpp -I../include
-AM_LDFLAGS = -Wall -pthread -m64 -std=c++11 -fPIC -L${prefix}/lib  -L$(prefix)/mysql/lib
+AM_CPPFLAGS = -Wall -pthread -m64 -std=c++11 -fPIC -I${prefix}/include -I./src -I/usr/local/mysql/include -I../include/websocketpp -I../include
+AM_LDFLAGS = -Wall -pthread -m64 -std=c++11 -fPIC -L${prefix}/lib  -L/usr/local/mysql/lib
 yals_SOURCES = ${AM_SOURCES} main.cpp 
 yals_CPPFLAGS = ${AM_CPPFLAGS} 
 yals_LDFLAGS = ${AM_LDFLAGS}  -lzlog -lrt -lboost_system -lboost_thread -lmysqlclient
@@ -261,9 +255,6 @@ client_LDFLAGS = ${AM_LDFLAGS}  -L. -lzlog
 test_SOURCES = test.cpp base64.cpp
 test_CPPFLAGS = ${AM_CPPFLAGS}
 test_LDFLAGS = ${AM_LDFLAGS}  -L. -lzlog -lrt
-visit_SOURCES = visit.cpp 
-visit_CPPFLAGS = ${AM_CPPFLAGS} -D_TEST_
-visit_LDFLAGS = ${AM_LDFLAGS}  
 EXTRA_DIST = message_file.h
 all: all-am
 
@@ -355,9 +346,6 @@ client$(EXEEXT): $(client_OBJECTS) $(client_DEPENDENCIES) $(EXTRA_client_DEPENDE
 test$(EXEEXT): $(test_OBJECTS) $(test_DEPENDENCIES) $(EXTRA_test_DEPENDENCIES) 
 	@rm -f test$(EXEEXT)
 	$(test_LINK) $(test_OBJECTS) $(test_LDADD) $(LIBS)
-visit$(EXEEXT): $(visit_OBJECTS) $(visit_DEPENDENCIES) $(EXTRA_visit_DEPENDENCIES) 
-	@rm -f visit$(EXEEXT)
-	$(visit_LINK) $(visit_OBJECTS) $(visit_LDADD) $(LIBS)
 yals$(EXEEXT): $(yals_OBJECTS) $(yals_DEPENDENCIES) $(EXTRA_yals_DEPENDENCIES) 
 	@rm -f yals$(EXEEXT)
 	$(yals_LINK) $(yals_OBJECTS) $(yals_LDADD) $(LIBS)
@@ -373,7 +361,6 @@ include ./$(DEPDIR)/client-client.Po
 include ./$(DEPDIR)/client-message_file.Po
 include ./$(DEPDIR)/test-base64.Po
 include ./$(DEPDIR)/test-test.Po
-include ./$(DEPDIR)/visit-visit.Po
 include ./$(DEPDIR)/yals-CDBConnPool.Po
 include ./$(DEPDIR)/yals-CDBConnect.Po
 include ./$(DEPDIR)/yals-CDBHelper.Po
@@ -489,20 +476,6 @@ test-base64.obj: base64.cpp
 #	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \
 #	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o test-base64.obj `if test -f 'base64.cpp'; then $(CYGPATH_W) 'base64.cpp'; else $(CYGPATH_W) '$(srcdir)/base64.cpp'; fi`
 
-visit-visit.o: visit.cpp
-	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(visit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT visit-visit.o -MD -MP -MF $(DEPDIR)/visit-visit.Tpo -c -o visit-visit.o `test -f 'visit.cpp' || echo '$(srcdir)/'`visit.cpp
-	$(am__mv) $(DEPDIR)/visit-visit.Tpo $(DEPDIR)/visit-visit.Po
-#	source='visit.cpp' object='visit-visit.o' libtool=no \
-#	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \
-#	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(visit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o visit-visit.o `test -f 'visit.cpp' || echo '$(srcdir)/'`visit.cpp
-
-visit-visit.obj: visit.cpp
-	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(visit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT visit-visit.obj -MD -MP -MF $(DEPDIR)/visit-visit.Tpo -c -o visit-visit.obj `if test -f 'visit.cpp'; then $(CYGPATH_W) 'visit.cpp'; else $(CYGPATH_W) '$(srcdir)/visit.cpp'; fi`
-	$(am__mv) $(DEPDIR)/visit-visit.Tpo $(DEPDIR)/visit-visit.Po
-#	source='visit.cpp' object='visit-visit.obj' libtool=no \
-#	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \
-#	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(visit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o visit-visit.obj `if test -f 'visit.cpp'; then $(CYGPATH_W) 'visit.cpp'; else $(CYGPATH_W) '$(srcdir)/visit.cpp'; fi`
-
 yals-singleton_test_class1.o: websocket/singleton_test_class1.cpp
 	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(yals_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT yals-singleton_test_class1.o -MD -MP -MF $(DEPDIR)/yals-singleton_test_class1.Tpo -c -o yals-singleton_test_class1.o `test -f 'websocket/singleton_test_class1.cpp' || echo '$(srcdir)/'`websocket/singleton_test_class1.cpp
 	$(am__mv) $(DEPDIR)/yals-singleton_test_class1.Tpo $(DEPDIR)/yals-singleton_test_class1.Po

+ 3 - 7
Makefile.am

@@ -1,5 +1,5 @@
 bin_PROGRAMS=yals 
-noinst_PROGRAMS=client async test visit
+noinst_PROGRAMS=client async test 
 
 SRC_IN= websocket/singleton_test_class1.cpp  websocket/wsClient.cpp websocket/wsClientMgr.cpp websocket/wsTimerThread.cpp db_api/CDBConnect.cpp db_api/CDBConnPool.cpp db_api/CDBHelper.cpp db_api/CDBResultSet.cpp websocket/jsonBuilder.cpp websocket/jsonBuilder.h websocket/thread_safe_map.h
 
@@ -9,8 +9,8 @@ crc.cpp crc.h io_buf.h line.h loc_tool.cpp loc_tool.h message.cpp \
 message_file.h message.h net-service.cpp net-service.h point.cpp point.h tdoa_sync.cpp tdoa_sync.h \
 worker.cpp worker.h zio.h zloop.h znet.cpp znet.h zstream.h site_area.cpp  site_area.h area.h area.cpp
 
-AM_CPPFLAGS=-Wall -pthread -m64 -std=c++11 -fPIC -I${prefix}/include -I./src -I$(prefix)/mysql/include -I../include/websocketpp -I../include
-AM_LDFLAGS= -Wall -pthread -m64 -std=c++11 -fPIC -L${prefix}/lib  -L$(prefix)/mysql/lib
+AM_CPPFLAGS=-Wall -pthread -m64 -std=c++11 -fPIC -I${prefix}/include -I./src -I/usr/local/mysql/include -I../include/websocketpp -I../include
+AM_LDFLAGS= -Wall -pthread -m64 -std=c++11 -fPIC -L${prefix}/lib  -L/usr/local/mysql/lib
 
 yals_SOURCES=${AM_SOURCES} main.cpp 
 yals_CPPFLAGS=${AM_CPPFLAGS} 
@@ -28,10 +28,6 @@ test_SOURCES=test.cpp base64.cpp
 test_CPPFLAGS=${AM_CPPFLAGS}
 test_LDFLAGS=${AM_LDFLAGS}  -L. -lzlog -lrt
 
-visit_SOURCES=visit.cpp 
-visit_CPPFLAGS=${AM_CPPFLAGS} -D_TEST_
-visit_LDFLAGS=${AM_LDFLAGS}  
-
 DEFS= 
 EXTRA_DIST=message_file.h
 

+ 5 - 32
Makefile.in

@@ -49,8 +49,7 @@ NORMAL_UNINSTALL = :
 PRE_UNINSTALL = :
 POST_UNINSTALL = :
 bin_PROGRAMS = yals$(EXEEXT)
-noinst_PROGRAMS = client$(EXEEXT) async$(EXEEXT) test$(EXEEXT) \
-	visit$(EXEEXT)
+noinst_PROGRAMS = client$(EXEEXT) async$(EXEEXT) test$(EXEEXT)
 subdir = .
 DIST_COMMON = $(am__configure_deps) $(srcdir)/Makefile.am \
 	$(srcdir)/Makefile.in $(top_srcdir)/configure COPYING INSTALL \
@@ -82,11 +81,6 @@ test_OBJECTS = $(am_test_OBJECTS)
 test_LDADD = $(LDADD)
 test_LINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(test_LDFLAGS) \
 	$(LDFLAGS) -o $@
-am_visit_OBJECTS = visit-visit.$(OBJEXT)
-visit_OBJECTS = $(am_visit_OBJECTS)
-visit_LDADD = $(LDADD)
-visit_LINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(visit_LDFLAGS) \
-	$(LDFLAGS) -o $@
 am__objects_1 = yals-singleton_test_class1.$(OBJEXT) \
 	yals-wsClient.$(OBJEXT) yals-wsClientMgr.$(OBJEXT) \
 	yals-wsTimerThread.$(OBJEXT) yals-CDBConnect.$(OBJEXT) \
@@ -121,9 +115,9 @@ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
 CCLD = $(CC)
 LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
 SOURCES = $(async_SOURCES) $(client_SOURCES) $(test_SOURCES) \
-	$(visit_SOURCES) $(yals_SOURCES)
+	$(yals_SOURCES)
 DIST_SOURCES = $(async_SOURCES) $(client_SOURCES) $(test_SOURCES) \
-	$(visit_SOURCES) $(yals_SOURCES)
+	$(yals_SOURCES)
 am__can_run_installinfo = \
   case $$AM_UPDATE_INFO_DIR in \
     n|no|NO) false;; \
@@ -247,8 +241,8 @@ crc.cpp crc.h io_buf.h line.h loc_tool.cpp loc_tool.h message.cpp \
 message_file.h message.h net-service.cpp net-service.h point.cpp point.h tdoa_sync.cpp tdoa_sync.h \
 worker.cpp worker.h zio.h zloop.h znet.cpp znet.h zstream.h site_area.cpp  site_area.h area.h area.cpp
 
-AM_CPPFLAGS = -Wall -pthread -m64 -std=c++11 -fPIC -I${prefix}/include -I./src -I$(prefix)/mysql/include -I../include/websocketpp -I../include
-AM_LDFLAGS = -Wall -pthread -m64 -std=c++11 -fPIC -L${prefix}/lib  -L$(prefix)/mysql/lib
+AM_CPPFLAGS = -Wall -pthread -m64 -std=c++11 -fPIC -I${prefix}/include -I./src -I/usr/local/mysql/include -I../include/websocketpp -I../include
+AM_LDFLAGS = -Wall -pthread -m64 -std=c++11 -fPIC -L${prefix}/lib  -L/usr/local/mysql/lib
 yals_SOURCES = ${AM_SOURCES} main.cpp 
 yals_CPPFLAGS = ${AM_CPPFLAGS} 
 yals_LDFLAGS = ${AM_LDFLAGS}  -lzlog -lrt -lboost_system -lboost_thread -lmysqlclient
@@ -261,9 +255,6 @@ client_LDFLAGS = ${AM_LDFLAGS}  -L. -lzlog
 test_SOURCES = test.cpp base64.cpp
 test_CPPFLAGS = ${AM_CPPFLAGS}
 test_LDFLAGS = ${AM_LDFLAGS}  -L. -lzlog -lrt
-visit_SOURCES = visit.cpp 
-visit_CPPFLAGS = ${AM_CPPFLAGS} -D_TEST_
-visit_LDFLAGS = ${AM_LDFLAGS}  
 EXTRA_DIST = message_file.h
 all: all-am
 
@@ -355,9 +346,6 @@ client$(EXEEXT): $(client_OBJECTS) $(client_DEPENDENCIES) $(EXTRA_client_DEPENDE
 test$(EXEEXT): $(test_OBJECTS) $(test_DEPENDENCIES) $(EXTRA_test_DEPENDENCIES) 
 	@rm -f test$(EXEEXT)
 	$(test_LINK) $(test_OBJECTS) $(test_LDADD) $(LIBS)
-visit$(EXEEXT): $(visit_OBJECTS) $(visit_DEPENDENCIES) $(EXTRA_visit_DEPENDENCIES) 
-	@rm -f visit$(EXEEXT)
-	$(visit_LINK) $(visit_OBJECTS) $(visit_LDADD) $(LIBS)
 yals$(EXEEXT): $(yals_OBJECTS) $(yals_DEPENDENCIES) $(EXTRA_yals_DEPENDENCIES) 
 	@rm -f yals$(EXEEXT)
 	$(yals_LINK) $(yals_OBJECTS) $(yals_LDADD) $(LIBS)
@@ -373,7 +361,6 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/client-message_file.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-base64.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-test.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/visit-visit.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/yals-CDBConnPool.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/yals-CDBConnect.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/yals-CDBHelper.Po@am__quote@
@@ -489,20 +476,6 @@ test-base64.obj: base64.cpp
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o test-base64.obj `if test -f 'base64.cpp'; then $(CYGPATH_W) 'base64.cpp'; else $(CYGPATH_W) '$(srcdir)/base64.cpp'; fi`
 
-visit-visit.o: visit.cpp
-@am__fastdepCXX_TRUE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(visit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT visit-visit.o -MD -MP -MF $(DEPDIR)/visit-visit.Tpo -c -o visit-visit.o `test -f 'visit.cpp' || echo '$(srcdir)/'`visit.cpp
-@am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/visit-visit.Tpo $(DEPDIR)/visit-visit.Po
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='visit.cpp' object='visit-visit.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(visit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o visit-visit.o `test -f 'visit.cpp' || echo '$(srcdir)/'`visit.cpp
-
-visit-visit.obj: visit.cpp
-@am__fastdepCXX_TRUE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(visit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT visit-visit.obj -MD -MP -MF $(DEPDIR)/visit-visit.Tpo -c -o visit-visit.obj `if test -f 'visit.cpp'; then $(CYGPATH_W) 'visit.cpp'; else $(CYGPATH_W) '$(srcdir)/visit.cpp'; fi`
-@am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/visit-visit.Tpo $(DEPDIR)/visit-visit.Po
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='visit.cpp' object='visit-visit.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(visit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o visit-visit.obj `if test -f 'visit.cpp'; then $(CYGPATH_W) 'visit.cpp'; else $(CYGPATH_W) '$(srcdir)/visit.cpp'; fi`
-
 yals-singleton_test_class1.o: websocket/singleton_test_class1.cpp
 @am__fastdepCXX_TRUE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(yals_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT yals-singleton_test_class1.o -MD -MP -MF $(DEPDIR)/yals-singleton_test_class1.Tpo -c -o yals-singleton_test_class1.o `test -f 'websocket/singleton_test_class1.cpp' || echo '$(srcdir)/'`websocket/singleton_test_class1.cpp
 @am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/yals-singleton_test_class1.Tpo $(DEPDIR)/yals-singleton_test_class1.Po

BIN
a.out


+ 50 - 0
area.cpp

@@ -44,3 +44,53 @@ std::vector<std::shared_ptr<area>> area_list::get_area(const point&pt)
 	return std::move(ret);
 }
 
+
+void area_tool::on_point(int64_t card_id,const point&pt,double speed)
+{
+	std::vector<std::shared_ptr<area>> areas=area_list::instance()->get_area(pt);//找出所有的区域
+	std::sort(areas.begin(),areas.end(),[](std::shared_ptr<area>&l,std::shared_ptr<area>&r){
+			return l->id()<r->id();
+			});
+
+	auto c1=m_clist.begin(),ce=m_clist.end();
+	auto a1=areas.begin() ,ae=areas.end();
+
+	std::vector<std::shared_ptr<area_hover>> nlist;
+
+	while (c1!=ce && a1!=ae)
+	{
+		if ((*c1)->id()<(*a1)->id()) 
+		{ 
+			do_leave_biz(card_id,*c1,speed);
+			++c1;
+		}
+		else if ((*a1)->id()<(*c1)->id()) 
+		{
+			nlist.push_back(std::make_shared<area_hover>(*a1,pt,speed));
+			do_enter_biz(card_id,nlist.back(),speed);
+			++a1;
+		}
+		else 
+		{ 
+			nlist.push_back(*c1);
+			do_hover_biz(card_id,nlist.back(),speed);
+			++c1,++a1;
+		}
+	}
+
+	while(c1!=ce)
+	{
+		do_leave_biz(card_id,*c1,speed);
+		++c1;
+	}
+
+	while(a1!=ae)
+	{
+		nlist.push_back(std::make_shared<area_hover>(*a1,pt,speed));
+		do_enter_biz(card_id,nlist.back(),speed);
+		++a1;
+	}
+
+	m_clist=std::move(nlist);
+}
+

+ 4 - 52
area.h

@@ -43,7 +43,7 @@ struct area_list:single_base<area_list,int,std::shared_ptr<area>>
 	area_list();
 
 	std::vector<std::shared_ptr<area>> get_area(const point&pt);
-	static void init_from_db()
+	void init_from_db()
 	{
 	}
 };
@@ -86,55 +86,7 @@ struct area_hover
 struct area_tool
 {
 	std::vector<std::shared_ptr<area_hover>> m_clist;
-	void on_point(int card_id,const point&pt,double speed)
-	{
-		std::vector<std::shared_ptr<area>> areas=area_list::instance()->get_area(pt);//找出所有的区域
-        std::sort(areas.begin(),areas.end(),[](std::shared_ptr<area>l,std::shared_ptr<area>r){
-			return l->id()<r->id();
-		});
-
-		auto c1=m_clist.begin(),ce=m_clist.end();
-		auto a1=areas.begin() ,ae=areas.end();
-
-		std::vector<std::shared_ptr<area_hover>> nlist;
-
-		while (c1!=ce && a1!=ae)
-		{
-			if ((*c1)->id()<(*a1)->id()) 
-			{ 
-				do_leave_biz(card_id,*c1,speed);
-				++c1;
-			}
-			else if ((*a1)->id()<(*c1)->id()) 
-			{
-				nlist.push_back(std::make_shared<area_hover>(*a1,pt,speed));
-				do_enter_biz(card_id,nlist.back(),speed);
-				++a1;
-			}
-			else 
-			{ 
-				nlist.push_back(*c1);
-				do_hover_biz(card_id,nlist.back(),speed);
-				++c1,++a1;
-			}
-		}
-
-		while(c1!=ce)
-		{
-			do_leave_biz(card_id,*c1,speed);
-			++c1;
-		}
-
-		while(a1!=ae)
-		{
-			nlist.push_back(std::make_shared<area_hover>(*a1,pt,speed));
-			do_enter_biz(card_id,nlist.back(),speed);
-			++a1;
-		}
-
-		m_clist=std::move(nlist);
-	}
-
+	void on_point(int64_t card_id,const point&pt,double speed);
 
 	//检测是否超时
     void on_timer(int64_t card_id)
@@ -147,12 +99,12 @@ struct area_tool
 		a->m_area->on_hover(card_id,a,speed);
 	}
 
-    void do_enter_biz(int64_t card_id,std::shared_ptr<area_hover> a,double speed)
+    void do_enter_biz(int64_t card_id,std::shared_ptr<area_hover>&a,double speed)
 	{
 		a->m_area->on_enter(card_id,a,speed);
 	}
 
-    void do_leave_biz(int64_t card_id,std::shared_ptr<area_hover> a,double speed)
+    void do_leave_biz(int64_t card_id,std::shared_ptr<area_hover>&a,double speed)
 	{
 		a->m_area->on_leave(card_id,a,speed);
 	}

+ 19 - 19
autom4te.cache/requests

@@ -81,58 +81,58 @@
                         'configure.ac'
                       ],
                       {
-                        'AM_PROG_F77_C_O' => 1,
                         '_LT_AC_TAGCONFIG' => 1,
-                        'm4_pattern_forbid' => 1,
+                        'AM_PROG_F77_C_O' => 1,
                         'AC_INIT' => 1,
-                        '_AM_COND_IF' => 1,
+                        'm4_pattern_forbid' => 1,
                         'AC_CANONICAL_TARGET' => 1,
-                        'AC_SUBST' => 1,
+                        '_AM_COND_IF' => 1,
                         'AC_CONFIG_LIBOBJ_DIR' => 1,
-                        'AC_FC_SRCEXT' => 1,
+                        'AC_SUBST' => 1,
                         'AC_CANONICAL_HOST' => 1,
+                        'AC_FC_SRCEXT' => 1,
                         'AC_PROG_LIBTOOL' => 1,
                         'AM_PROG_MKDIR_P' => 1,
                         'AM_INIT_AUTOMAKE' => 1,
-                        'AM_PATH_GUILE' => 1,
                         'AC_CONFIG_SUBDIRS' => 1,
+                        'AM_PATH_GUILE' => 1,
                         'AM_AUTOMAKE_VERSION' => 1,
                         'LT_CONFIG_LTDL_DIR' => 1,
-                        'AC_CONFIG_LINKS' => 1,
                         'AC_REQUIRE_AUX_FILE' => 1,
-                        'm4_sinclude' => 1,
+                        'AC_CONFIG_LINKS' => 1,
                         'LT_SUPPORTED_TAG' => 1,
+                        'm4_sinclude' => 1,
                         'AM_MAINTAINER_MODE' => 1,
                         'AM_NLS' => 1,
                         'AC_FC_PP_DEFINE' => 1,
                         'AM_GNU_GETTEXT_INTL_SUBDIR' => 1,
-                        'AM_MAKEFILE_INCLUDE' => 1,
                         '_m4_warn' => 1,
+                        'AM_MAKEFILE_INCLUDE' => 1,
                         'AM_PROG_CXX_C_O' => 1,
-                        '_AM_MAKEFILE_INCLUDE' => 1,
                         '_AM_COND_ENDIF' => 1,
+                        '_AM_MAKEFILE_INCLUDE' => 1,
                         'AM_ENABLE_MULTILIB' => 1,
                         'AM_PROG_MOC' => 1,
                         'AM_SILENT_RULES' => 1,
                         'AC_CONFIG_FILES' => 1,
-                        'LT_INIT' => 1,
                         'include' => 1,
-                        'AM_GNU_GETTEXT' => 1,
+                        'LT_INIT' => 1,
                         'AM_PROG_AR' => 1,
+                        'AM_GNU_GETTEXT' => 1,
                         'AC_LIBSOURCE' => 1,
-                        'AM_PROG_FC_C_O' => 1,
                         'AC_CANONICAL_BUILD' => 1,
+                        'AM_PROG_FC_C_O' => 1,
                         'AC_FC_FREEFORM' => 1,
-                        'AH_OUTPUT' => 1,
                         'AC_FC_PP_SRCEXT' => 1,
-                        'AC_CONFIG_AUX_DIR' => 1,
+                        'AH_OUTPUT' => 1,
                         '_AM_SUBST_NOTMAKE' => 1,
-                        'm4_pattern_allow' => 1,
-                        'sinclude' => 1,
+                        'AC_CONFIG_AUX_DIR' => 1,
                         'AM_PROG_CC_C_O' => 1,
-                        'AM_XGETTEXT_OPTION' => 1,
-                        'AC_CANONICAL_SYSTEM' => 1,
+                        'sinclude' => 1,
+                        'm4_pattern_allow' => 1,
                         'AM_CONDITIONAL' => 1,
+                        'AC_CANONICAL_SYSTEM' => 1,
+                        'AM_XGETTEXT_OPTION' => 1,
                         'AC_CONFIG_HEADERS' => 1,
                         'AC_DEFINE_TRACE_LITERAL' => 1,
                         'AM_POT_TOOLS' => 1,

+ 0 - 178
c2.cpp

@@ -1,178 +0,0 @@
-
-struct area
-{
-	uint32_t    m_id;
-	std::string m_name;
-	std::atomic<int> m_card_count;
-
-	int id();
-	std::string name();
-	int  get_card_count();
-
-	double get_limit_speed();
-	double get_limit_time_second();
-	double get_limit_card_count();
-
-
-	virtual int type()=0;//site:0,normal:1
-
-	void inc_card_count(int deta)
-	{
-	}
-
-	virtual void on_hover(int card_id,const point&pt)=0;
-	virtual void on_enter(int card_id,std::shared_ptr<area> prev,const point&pt)=0;
-	virtual void on_leave(int card_id,std::shared_ptr<area> next,const point&pt)=0;
-
-	virtual ~area(){}
-};
-
-struct normal_area:area
-{
-	std::vector<point> m_bound;
-};
-
-struct site_area:area
-{
-	int32_t   m_site_id;
-};
-
-struct area_main
-{
-	std::vector<std::shared_ptr<area>> m_normal_list,m_site_list;
-
-	std::shared_ptr<area> get_site_area(int site_id);
-
-	std::shared_ptr<area> get_normal_area(int id);
-	std::vector<std::shared_ptr<area>> get_normal_area(const point&pt);
-
-	static std::shared_ptr<area_main> instance();
-};
-
-struct area_hover
-{
-	std::shared_ptr<area>  m_area;
-	time_t m_enter_time,m_last_time;
-
-	void reset()
-	{
-		m_last_time=time(0);
-	}
-
-	void reset(std::shared_ptr<area> a, time_t enter_time=0)
-	{
-		m_area=a;
-		if(enter_time) 
-		{
-			m_enter_time=m_last_time=enter_time;
-		}
-		else
-		{
-			m_last_time=time(0);
-		}
-	}
-
-	bool operator == (const area_hover&o)const
-	{
-		return m_area->id()==o->m_area->id();
-	}
-	bool operator < (const area_hover&o)const
-	{
-		return m_area->id()<o->m_area->id();
-	}
-};
-
-struct card_area_tool
-{
-	area_hover m_site;
-	std::vector<area_hover> m_normal;
-	point  m_last_point;
-
-	void on_point(int card_id,int site_id,const point&pt,double speed)
-	{
-		//处理分站类型的区域
-		std::shared_ptr<area> a=area_main::instance()->get_site_area(site_id);
-		if(pt.empty())//解算前
-		{
-			if(m_site==nullptr)
-			{
-				a->on_enter(card_id,nullptr);
-			}
-			else
-			{
-				if(*m_site==*a) { }
-				else//离开分站范围,进入新的分站范围
-				{
-					m_site->on_leave(card_id,a);
-					a->on_enter(card_id,m_site);
-					m_site=a;
-				}
-			}
-			return;
-		}
-
-
-		std::vector<std::shared_ptr<area>> areas=get_normal_area(pt);//找出所有的区域
-		for(a:m_site-areas)//离开的区域
-		{
-			a.on_leave();
-			
-
-
-
-			area *a=area_main_inst->get_normal_area(pt);
-			on_site_area_point(a,card_id);
-		}
-	}
-
-	//插入进入新分站记录 //离开分站时更新记录//本版本只在数据库生成记录
-	void on_site_area_point(a,card_id,site_id,speed)
-	{
-		if(enter) do_att_biz(a,card_id);
-	}
-
-	//人卡考勤
-	void do_att_biz(a,card_id)
-	{
-	
-	
-	}
-
-	//生成卡进入区域、在区域活跃和离开区域的调用
-	void on_normal_area_point(a,card_id,pt,speed)
-	{
-		if(hover) do_hover_biz(a,card_id,pt,speed);
-		if(enter) do_enter_biz(a,card_id,pt,speed);
-	}
-
-	//检测是否超时
-	void on_timer(card_id)
-	{
-	
-	}
-
-	void do_hover_biz(a,card_id,pt,speed)
-	{
-		//区域超时超时检测
-		//区域超速检测
-		//电子围栏检测
-	}
-
-	void do_enter_biz(a,card_id,pt,speed)
-	{
-		//当前区域超员检测
-		//车卡考勤逻辑检测
-		//电子围栏检测
-	}
-};
-
-struct person_card:card
-{
-	card_area_tool*m_area_tool;
-
-	void on_point(int site_id,const point&pt,double speed)
-	{
-		m_area_tool->on_point(m_id,site_id,pt,speed);
-	}
-};
-

+ 13 - 3
card.cpp

@@ -132,6 +132,14 @@ struct card_message_handle
 		}
 	}
 
+	~card_message_handle()
+	{
+		for(auto&it:m_ct_list)
+		{
+			delete it;
+		}
+	}
+
 	void on_message(zloop<task*> * loop,const message_locinfo&loc,bool is_history)
 	{
 		if(is_history)
@@ -139,6 +147,7 @@ struct card_message_handle
 			log_warn("%s","当前代码没有处理历史消息记录。");
 			return;
 		}
+
         if(loc.m_batty_status == 2) 
         {
             m_card->do_status(STA_TYPE::STATUS_LOW_POWER);
@@ -147,6 +156,7 @@ struct card_message_handle
         {
             m_card->do_status(STA_TYPE::STATUS_HELP);
         }
+
 		m_ct_list[loc.m_card_ct&(m_ct_list.size()-1)]->on_message(loop,loc);
 	}
 };
@@ -162,16 +172,17 @@ struct person:card_location_base,card_area
 	person(std::string type,uint32_t cardid,uint16_t needdisplay,int16_t t)
         :card_location_base(type,cardid,needdisplay,t)
 	{
-        m_message_handle = new  card_message_handle(this);
+        m_message_handle=new  card_message_handle(this);
 	}
 	~person(){}
 };
+
 struct car:card_location_base,card_area
 {
 	car(std::string type,uint32_t cardid,uint16_t needdisplay,int16_t t)
         :card_location_base(type,cardid,needdisplay,t)
     {
-        m_message_handle = new  card_message_handle(this);
+        m_message_handle=new  card_message_handle(this);
     }
 	~car(){}
 };
@@ -323,7 +334,6 @@ void card_list::on_message(zloop<task*> *loop,const message_locinfo&loc,bool is_
 		log_warn("数据库中未定义该卡的信息,card_id=%d", loc.m_card_id);
 		return;
 	}
-
 	log_info("card message:site=%d,ant=%d,card=%d,tof=%lld,rav=%02X,acc=%02X,rssi=%d,stamp=%llu",
 			loc.m_site_id,loc.m_ant_id,loc.m_card_id,loc.m_tof,loc.m_rav,loc.m_acc,loc.m_rssi,loc.m_time_stamp);
 

+ 1 - 0
card.h

@@ -67,3 +67,4 @@ struct card_list:single_base<card_list,uint64_t,std::shared_ptr<card_location_ba
 
 #endif
 
+

Datei-Diff unterdrückt, da er zu groß ist
+ 0 - 1181
config.log


Datei-Diff unterdrückt, da er zu groß ist
+ 0 - 1057
config.status


BIN
db_api.tar


+ 8 - 0
main.cpp

@@ -1,3 +1,4 @@
+#include <ev++.h>
 #include <log.h>
 #include <net-service.h>
 #include "db_api/CDBConnPool.h"
@@ -77,6 +78,12 @@ struct Init_Setting
 	
 };
 
+
+void cleanup() 
+{ 
+	ev_loop_destroy(ev_default_loop());
+}
+
 int main()
 {
 	log_init("../etc/log.ini");
@@ -85,6 +92,7 @@ int main()
 	Init_Setting is;
 	is.init();
 	
+	atexit(&cleanup);
 
 	card_path::init();
 	net_service mh;

+ 5 - 0
message.h

@@ -26,6 +26,11 @@ struct message_locinfo
 
 	void zero_this();
     void load(zistream&is,bool tdoa);
+
+	int64_t long_id()const 
+	{
+		return (((int64_t)m_card_type)<<32)|m_card_id;
+	}
 };
 
 //tdoa分站同步数据

BIN
tar.tar.gz


BIN
visit


+ 5 - 1
worker.cpp

@@ -78,6 +78,10 @@ struct worker_impl:worker
 	std::atomic<int> m_init_flag{-2};
 	virtual void stop()
 	{
+		int exp=0;
+		if(!m_init_flag.compare_exchange_strong (exp,1))
+			return;
+
 		for(auto&thr:m_threads)
 			thr->stop();
 
@@ -116,7 +120,7 @@ struct worker_impl:worker
 worker_impl _worker_impl;
 worker*worker::instance()
 {
-	_worker_impl.init(4);
+	_worker_impl.init(1);
 	return &_worker_impl;
 }
 

+ 5 - 2
write-copy.h

@@ -18,17 +18,19 @@ struct write_copy_base:acceptor<V>
 			v.visit(me.second);
 		}
 	}
+
 	std::unordered_map<K,V> m_map;
 	write_copy_base()
 	{
 	
 	}
 
-	V	get(K k)const
+	V get(K k)const
 	{
 		return m_map[k];
 	}
-	V	get(K k)
+
+	V get(K k)
 	{
 		auto serch = m_map.find(k);
 		if(serch != m_map.end())
@@ -138,3 +140,4 @@ struct single_base:write_copy_base<T,K,V>
 
 #endif
 
+

+ 1 - 0
zloop.h

@@ -8,6 +8,7 @@
 #include <ev++.h>
 
 struct zloop_base:ev::dynamic_loop
+//struct zloop_base:ev::loop_ref
 {
 	std::atomic<bool>  m_stop_flag{false};
 	ev::async m_async;

+ 30 - 2
znet.cpp

@@ -15,6 +15,7 @@
 #include <znet.h>
 #include <zloop.h>
 #include <clock.h>
+#include <worker.h>
 
 #include "config_file.h"
 extern config_file config;
@@ -131,6 +132,29 @@ struct fd_io:ev::io
 	}
 };
 
+struct stdin_io:fd_io
+{
+	stdin_io(io_context&ic)
+		:fd_io(ic,0)
+	{}
+
+	virtual void operator()(ev::io &w, int)
+	{
+		char buf[256];
+		if(!gets(buf))
+			return;
+
+		if(strchr(buf,'X'))
+		{
+			log_info("stdin input 'X', exiting...");
+
+			worker::instance()->stop();
+			stop();
+			m_ic.stop();
+		}
+	}
+};
+
 struct sock_client:fd_io,client_ex
 {
 	io_context&m_ic;
@@ -442,9 +466,11 @@ struct signal_w:ev::sig
 
 	void operator()(ev::sig &w, int s)
 	{
-		stop();
 		log_info("recved signal %d",s);
-		m_ic.async_stop();
+
+		worker::instance()->stop();
+		stop();
+		m_ic.stop();
 	}
 };
 
@@ -466,6 +492,8 @@ struct main_loop:io_context
 
 		sock_listen _1(*this,fd);
 
+		stdin_io _2(*this);
+
 		block_sig(SIGPIPE);
 		signal_w sint(*this,SIGINT),term(*this,SIGTERM);
 		ev::dynamic_loop::run(0);