scripting.h

来自「roadnav 内含一个基于wxWindows库的车载导航系统。编译后」· C头文件 代码 · 共 106 行

H
106
字号
/*
 *  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 + =
减小字号Ctrl + -
显示快捷键?