Version: 0.6.0
tskmngr.h
1 /******************************************************************************
2  * Project: wxGIS
3  * Purpose: wxGISTaskManager - class to communicate with task manager server
4  * Author: Dmitry Baryshnikov (aka Bishop), polimax@mail.ru
5  ******************************************************************************
6 * Copyright (C) 2012-2013 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/net/netfactory.h"
24 #include "wxgis/net/netevent.h"
25 
26 class WXDLLIMPEXP_GIS_GP wxGISTaskManagerEvent;
27 
28 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_GIS_GP, wxGISTASKMNGR_CONNECT, wxGISTaskManagerEvent);
29 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_GIS_GP, wxGISTASKMNGR_DISCONNECT, wxGISTaskManagerEvent);
30 
34 class WXDLLIMPEXP_GIS_GP wxGISTaskManagerEvent : public wxEvent
35 {
36 public:
37  wxGISTaskManagerEvent(wxEventType eventType = wxGISTASKMNGR_CONNECT) : wxEvent(wxNOT_FOUND, eventType)
38  {
39  }
40  //wxGISTaskManagerEvent(const wxGISTaskManagerEvent& event) : wxEvent(event)
41  //{
42  //}
43  virtual wxEvent *Clone() const { return new wxGISTaskManagerEvent(*this); }
44 private:
45  DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxGISTaskManagerEvent)
46 };
47 
48 typedef void (wxEvtHandler::*wxGISTaskManagerEventFunction)(wxGISTaskManagerEvent&);
49 
50 #define wxGISTaskManagerEventHandler(func) \
51  wxEVENT_HANDLER_CAST(wxGISTaskManagerEventFunction, func)
52 
53 #define EVT_GISTASKMNGR_CONNECT(func) wx__DECLARE_EVT0(wxGISTASKMNGR_CONNECT, wxGISTaskManagerEventHandler(func))
54 #define EVT_GISTASKMNGR_DISCONNECT(func) wx__DECLARE_EVT0(wxGISTASKMNGR_DISCONNECT, wxGISTaskManagerEventHandler(func))
55 
56 
62  public INetConnection
63 {
64  DECLARE_CLASS(wxGISLocalClientConnection)
65  enum{
66  // id for sockets
67  SOCKET_ID = 111
68  };
69 public:
71  virtual ~wxGISLocalClientConnection(void);
72  //INetConnection
73  virtual bool Connect(void);
74  virtual bool Disconnect(void);
75  virtual wxString GetLastError(void) const;
76 protected:
77  //events
78  virtual void OnSocketEvent(wxSocketEvent& event);
79 private:
80  DECLARE_EVENT_TABLE()
81 };
82 
83 class wxGISTaskCategory;
84 WX_DECLARE_STRING_HASH_MAP(wxGISTaskCategory*, wxGISTaskCategoryMap);
85 
89 class WXDLLIMPEXP_GIS_GP wxGISTaskManager :
90  public wxEvtHandler,
92  public wxGISPointer
93 {
94  DECLARE_CLASS(wxGISTaskManager)
95  enum
96  {
97  TIMER_ID = 1015
98  };
99  friend wxGISTaskCategory;
100 public:
101  wxGISTaskManager(void);
102  virtual ~wxGISTaskManager(void);
103  virtual wxGISTaskCategory* const GetCategory(const wxString& sName);
104  virtual bool CreateCategory(const wxString& sName);
105  virtual bool DeleteCategory(const wxString& sName);
106  virtual wxString GetLastError(void) const;
107  virtual bool SetMaxTaskExec(int nMaxExecTaskCount);
108  virtual bool SetExecState(wxGISNetCommandState eExitState);
109  virtual bool IsValid(void) const;//the manager app is started and connected via tcp/ip
110 protected:
111  virtual void StartTaskManagerServer(void);
112  virtual void ClearCategories(void);
113  virtual void DeleteCategory(wxGISTaskCategory* pCategory);
114  virtual void NetNote(const wxNetMessage &msg);
115  virtual void NetCommand(const wxNetMessage &msg);
116  virtual void FillDetails(const wxJSONValue &val);
117  virtual void SendNetMessageAsync(const wxNetMessage& msg);
118  virtual wxNetMessage SendNetMessageSync(const wxNetMessage& msg);
119  //events
120  virtual void OnGISNetEvent(wxGISNetEvent & event);
121  virtual void OnTimer( wxTimerEvent & event);
122 protected:
123  wxGISTaskCategoryMap m_omCategories;
125  long m_nConnectionPointConnCookie;
126  wxTimer m_timer;
127  int m_nMaxExecTasks;
128  wxGISNetCommandState m_eExitState;
129  bool m_bDetailesFilled;
130  wxString m_sLastError;
131 private:
132  DECLARE_EVENT_TABLE()
133 };
134 
139 WXDLLIMPEXP_GIS_GP wxGISTaskManager* const GetTaskManager(void);
The JSON value class implementation.
Definition: jsonval.h:91
Task Manager Server communicate class.
Definition: tskmngr.h:89
Definition: pointer.h:55
Definition: pointer.h:34
Definition: tskmngr.h:34
Definition: network.h:74
The connection to communicate with local Task Manager Server.
Definition: tskmngr.h:61
Definition: message.h:42
Definition: task.h:252
Definition: netevent.h:34