OpenCPN Partial API docs
SencManager.h
1 /***************************************************************************
2  *
3  * Project: OpenCPN
4  * Purpose: S57 Chart Object
5  * Author: David Register
6  *
7  ***************************************************************************
8  * Copyright (C) 2010 by David S. Register *
9  * *
10  * This program is free software; you can redistribute it and/or modify *
11  * it under the terms of the GNU General Public License as published by *
12  * the Free Software Foundation; either version 2 of the License, or *
13  * (at your option) any later version. *
14  * *
15  * This program is distributed in the hope that it will be useful, *
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18  * GNU General Public License for more details. *
19  * *
20  * You should have received a copy of the GNU General Public License *
21  * along with this program; if not, write to the *
22  * Free Software Foundation, Inc., *
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
24  **************************************************************************/
25 
26 #ifndef __SENCMGR_H__
27 #define __SENCMGR_H__
28 
29 #include <vector>
30 
31 // ----------------------------------------------------------------------------
32 // Useful Prototypes
33 // ----------------------------------------------------------------------------
34 
35 //----------------------------------------------------------------------------
36 // Constants
37 //----------------------------------------------------------------------------
38 
39 //----------------------------------------------------------------------------
40 // Fwd Defns
41 //----------------------------------------------------------------------------
42 
43 class s57chart;
44 class SENCBuildThread;
45 
46 typedef enum {
47  THREAD_INACTIVE = 0,
48  THREAD_PENDING,
49  THREAD_STARTED,
50  THREAD_FINISHED
51 } SENCThreadStatus;
52 
53 typedef enum {
54  SENC_BUILD_INACTIVE = 0,
55  SENC_BUILD_PENDING,
56  SENC_BUILD_STARTED,
57  SENC_BUILD_DONE_NOERROR,
58  SENC_BUILD_DONE_ERROR,
59 } EVENTSENCResult;
60 
61 extern const wxEventType wxEVT_OCPN_BUILDSENCTHREAD;
62 
63 //----------------------------------------------------------------------------
64 // s57 Chart Thread based SENC job ticket
65 //----------------------------------------------------------------------------
67 public:
68  SENCJobTicket();
69  ~SENCJobTicket() {}
70 
71  s57chart *m_chart;
72  wxString m_FullPath000;
73  wxString m_SENCFileName;
74  double ref_lat, ref_lon;
75  double m_LOD_meters;
76 
77  SENCBuildThread *m_thread;
78 
79  SENCThreadStatus m_status;
80  EVENTSENCResult m_SENCResult;
81 };
82 
83 //----------------------------------------------------------------------------
84 // s57 Chart Thread based SENC creator status message
85 //----------------------------------------------------------------------------
86 class OCPN_BUILDSENC_ThreadEvent : public wxEvent {
87 public:
88  OCPN_BUILDSENC_ThreadEvent(wxEventType commandType = wxEVT_NULL, int id = 0);
90 
91  // required for sending with wxPostEvent()
92  wxEvent *Clone() const;
93 
94  int stat;
95  EVENTSENCResult type;
96  SENCJobTicket *m_ticket;
97 
98 private:
99 };
100 
101 //----------------------------------------------------------------------------
102 // s57 Chart Thread based SENC creator
103 //----------------------------------------------------------------------------
104 class SENCThreadManager : public wxEvtHandler {
105 public:
108 
109  void OnEvtThread(OCPN_BUILDSENC_ThreadEvent &event);
110 
111  SENCThreadStatus ScheduleJob(SENCJobTicket *ticket);
112  void FinishJob(SENCJobTicket *ticket);
113  void StartTopJob();
114  bool IsChartInTicketlist(s57chart *chart);
115  bool SetChartPointer(s57chart *chart, void *new_ptr);
116  int GetJobCount();
117 
118  int m_max_jobs;
119 
120  std::vector<SENCJobTicket *> ticket_list;
121 };
122 
123 //----------------------------------------------------------------------------
124 // s57 Chart Thread based SENC creator
125 //----------------------------------------------------------------------------
126 class SENCBuildThread : public wxThread {
127 public:
129  void *Entry();
130 
131  wxString m_FullPath000;
132  wxString m_SENCFileName;
133  s57chart *m_chart;
134  SENCThreadManager *m_manager;
135  SENCJobTicket *m_ticket;
136 };
137 
138 #endif