⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 scripting.h

📁 roadnav 内含一个基于wxWindows库的车载导航系统。编译后
💻 H
字号:
/*
 *  Roadnav
 *  Scripting.h
 *
 *  Copyright (c) 2004 - 2006 Richard L. Lynch <rllynch@users.sourceforge.net>
 *
 *  This program is free software; you can redistribute it and/or
 *  modify it under the terms of version 2 of the GNU General Public License
 *  as published by the Free Software Foundation.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */

//////////////////////////////////////////////////////////////////////////////
/// \file
///
/// Scripting functions
///
//////////////////////////////////////////////////////////////////////////////

#ifndef SCRIPTING_H
#define SCRIPTING_H

#ifdef USE_SCRIPTING

#include <wx/wx.h>
#include <wx/thread.h>
#include <wx/datetime.h>
#include <wx/stream.h>
#include <wx/socket.h>

#include <list>

#include "libroadnav/MapControl.h"

#define DEFAULT_SCRIPTING_TCP_PORT_NUMBER		12937

wxString GetScriptExportFilename();
bool GetScriptAppendMode();

class ScriptStream
{
	public:
		ScriptStream(wxInputStream * pInputStream, wxOutputStream * pOutputStream, wxSocketBase * pSocket);
		~ScriptStream();
		
		wxInputStream * m_pInputStream;
		wxString m_strInputBuffer;

		wxOutputStream * m_pOutputStream;
		
		wxSocketBase * m_pSocket;
		
		wxDateTime m_tLastRead;
};

class Scripting
{
	public:
		Scripting(MapControl * pctlMap);
		~Scripting();

		void Pump();
		
		bool RunFromFile(wxString strFilename);
		
		bool AddTCPServer(int iPort, bool bLocalConnectionsOnly);
		void DeleteAllTCPServers();
	
		static bool WriteWaypointToFile(wxString strFilename, bool bAppend, const MapMarker & cMarker);

	private:
		void PumpScripts();
		void PumpServers();

		void AddScript(wxInputStream * pInputStream, wxOutputStream * pOutputStream, wxSocketBase * pSocket);
		void AddServer(wxSocketServer * pServer);
		
		std::list<wxString> ExecuteCommand(wxString strCmdAndArgs);
		std::list<wxString> ExecuteCommand(std::list<wxString> vCmdAndArgs);
		
		std::list<wxString> CommandAddWaypoint(wxString strCmd, std::list<wxString> vArgs);
		std::list<wxString> CommandGetWaypoint(wxString strCmd, std::list<wxString> vArgs);
		std::list<wxString> CommandDeleteWaypoint(wxString strCmd, std::list<wxString> vArgs);
	
		static wxString CompileCommand(std::list<wxString> vCmdAndArgs);
		
		MapControl * m_pctlMap;
		
		std::vector<ScriptStream *> m_vScripts;
		wxMutex m_mtxScripts;

		std::vector<wxSocketServer *> m_vServers;
		wxMutex m_mtxServers;
};

#endif
#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -