Version: 0.6.0
process.h
1 /******************************************************************************
2  * Project: wxGIS (GIS Catalog)
3  * Purpose: external process common classes.
4  * Author: Dmitry Baryshnikov (aka Bishop), polimax@mail.ru
5  ******************************************************************************
6 * Copyright (C) 2010-2012 Dmitry Baryshnikov
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  ****************************************************************************/
21 #pragma once
22 
23 #include "wxgis/core/core.h"
24 
25 #include <wx/process.h>
26 #include <wx/thread.h>
27 
28 class WXDLLIMPEXP_GIS_CORE wxGISProcess;
29 
34 {
35 public:
36  virtual ~IGISProcessParent(void){};
37  virtual void OnFinish(wxGISProcess* pProcess, bool bHasErrors) = 0;
38 };
39 
43 class WXDLLIMPEXP_GIS_CORE wxGISProcess :
44  public wxProcess,
45  public wxThreadHelper
46 {
47 public:
48  wxGISProcess(IGISProcessParent* pParent = NULL);
49  virtual ~wxGISProcess(void);
50  // wxProcess
51  virtual void OnTerminate(int pid, int status);
52  //wxGISProcess
53  virtual bool Start(void);
54  virtual void Stop(void);
55  //
56  virtual void ProcessInput(wxString & sInputData);
57  virtual void SetState(wxGISEnumTaskStateType nState){m_nState = nState;};
58  virtual wxGISEnumTaskStateType GetState(void) const {return m_nState;};
59  virtual wxDateTime GetStart(void) const {return m_dtBeg;};
60  virtual wxDateTime GetFinish(void) const {return m_dtEstEnd;};
61 
62 protected:
63  virtual wxThread::ExitCode Entry();
64  bool CreateAndRunReadThread(void);
65  void DestroyReadThread(void);
66  virtual long Execute(void) = 0;
67  virtual void UpdatePercent(const wxString &sPercentData);
68  virtual void AddInfo(wxGISEnumMessageType eType, const wxString &sInfoData) = 0;
69 protected:
70  IGISProcessParent* m_pParent;
71  wxCriticalSection m_ExitLock;
72  //
73  wxDateTime m_dtBeg;
74  wxDateTime m_dtEstEnd;
75  wxGISEnumTaskStateType m_nState;
76  double m_dfDone;
77  bool m_bKill;
78 };
79 
80 /*
84 /*
85 
86 class IProcess
87 {
88 public:
89  IProcess(wxString sCommand, wxArrayString saParams)
90  {
91  m_sCommand = sCommand;
92  m_saParams = saParams;
93  m_nState = enumGISTaskPaused;
94  }
95  virtual ~IProcess(void){};
96  virtual void Start(void) = 0;
97  virtual void Cancel(void) = 0;
98  virtual void SetState(wxGISEnumTaskStateType nState){m_nState = nState;};
99  virtual wxGISEnumTaskStateType GetState(void){return m_nState;};
100  virtual wxString GetCommand(void){return m_sCommand;};
101  virtual wxArrayString GetParameters(void){return m_saParams;};
102  virtual wxDateTime GetBeginTime(void){return m_dtBeg;};
103  virtual wxDateTime GetEndTime(void){return m_dtEstEnd;};
104 protected:
105  wxDateTime m_dtBeg;
106  wxDateTime m_dtEstEnd;
107  wxGISEnumTaskStateType m_nState;
108  wxString m_sCommand;
109  wxArrayString m_saParams;
110 };
111 
112 */
The wxGISProcess parent interface class.
Definition: process.h:33
The process class which stores the application execution data.
Definition: process.h:43