OpenCPN Partial API docs
Loading...
Searching...
No Matches
senc_manager.h
Go to the documentation of this file.
1/***************************************************************************
2 * Copyright (C) 2010 by David S. Register *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, see <https://www.gnu.org/licenses/>. *
16 **************************************************************************/
17
24#ifndef SENCMGR_H_
25#define SENCMGR_H_
26
27#include <vector>
28
29#include <wx/event.h>
30#include <wx/string.h>
31#include <wx/thread.h>
32
33#include "s57chart.h"
34
35class SENCThreadManager; // forward
38extern const wxEventType wxEVT_OCPN_BUILDSENCTHREAD;
40class SENCBuildThread; // forward
41
42typedef enum {
43 THREAD_INACTIVE = 0,
44 THREAD_PENDING,
45 THREAD_STARTED,
46 THREAD_FINISHED
47} SENCThreadStatus;
48
49typedef enum {
50 SENC_BUILD_INACTIVE = 0,
51 SENC_BUILD_PENDING,
52 SENC_BUILD_STARTED,
53 SENC_BUILD_DONE_NOERROR,
54 SENC_BUILD_DONE_ERROR,
55} EVENTSENCResult;
56
57//----------------------------------------------------------------------------
58// s57 Chart Thread based SENC job ticket
59//----------------------------------------------------------------------------
61public:
64
65 s57chart *m_chart;
66 wxString m_FullPath000;
67 wxString m_SENCFileName;
68 double ref_lat, ref_lon;
69 double m_LOD_meters;
70
71 SENCThreadStatus m_status;
72 EVENTSENCResult m_SENCResult;
73 bool m_completion_posted;
74};
75
76//----------------------------------------------------------------------------
77// s57 Chart Thread based SENC creator status message
78//----------------------------------------------------------------------------
79class OCPN_BUILDSENC_ThreadEvent : public wxEvent {
80public:
81 OCPN_BUILDSENC_ThreadEvent(wxEventType commandType = wxEVT_NULL, int id = 0);
83
84 // required for sending with wxPostEvent()
85 wxEvent *Clone() const;
86
87 int stat;
88 EVENTSENCResult type;
89 SENCJobTicket *m_ticket;
90
91private:
92};
93
104class SENCThreadManager : public wxEvtHandler {
105public:
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 void InvalidateChartPointer(s57chart *chart);
117 void ReleaseCompletedTicket(SENCJobTicket *ticket);
118 void ClearJobList();
119 int GetJobCount();
120 int GetRunningJobCount();
121 bool IsShuttingDown() const;
122
123 int m_max_jobs;
124
125 std::vector<SENCJobTicket *> ticket_list;
126
127private:
128 void UpdateAlertString();
129 void NotifyFrame(OCPN_BUILDSENC_ThreadEvent &event);
130
131 std::vector<SENCJobTicket *> completing_list;
132 wxCriticalSection m_list_mutex;
133 bool m_shutting_down;
134};
135
136//----------------------------------------------------------------------------
137// s57 Chart Thread based SENC creator
138//----------------------------------------------------------------------------
139class SENCBuildThread : public wxThread {
140public:
142 void *Entry();
143
144 wxString m_FullPath000;
145 wxString m_SENCFileName;
146 SENCThreadManager *m_manager;
147 SENCJobTicket *m_ticket;
148};
149
150#endif // SENCMGR_H_
Manager for S57 chart SENC creation threads.
Represents an S57 format electronic navigational chart in OpenCPN.
Definition s57chart.h:90
S57 Chart Object.
const wxEventType wxEVT_OCPN_BUILDSENCTHREAD
Global instance.
SENCThreadManager * g_SencThreadManager
Global instance.