OpenCPN Partial API docs
Loading...
Searching...
No Matches
ocpn_app.h
1/***************************************************************************
2 *
3 * Project: OpenCPN
4 * Purpose: OpenCPN Main wxWidgets Program
5 * Author: David Register
6 *
7 ***************************************************************************
8 * Copyright (C) 2022 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 _OCPN_APP_H
27#define _OCPN_APP_H
28
29#include <wx/wxprec.h>
30
31#ifndef WX_PRECOMP
32#include <wx/app.h>
33#include <wx/cmdline.h>
34#include <wx/event.h>
35#endif // precompiled headers
36
37#include "model/instance_check.h"
38
39#include "model/comm_bridge.h"
40#include "model/local_api.h"
41#include "model/rest_server.h"
43#include "data_monitor.h"
44
45class Track;
46
47class MyApp : public wxApp {
48public:
49 MyApp();
50 ~MyApp() {};
51
52 bool OnInit() override;
53 int OnExit() override;
54#ifndef __ANDROID__
55 void OnInitCmdLine(wxCmdLineParser& parser) override;
56 bool OnCmdLineHelp(wxCmdLineParser& parser) override;
57 bool OnCmdLineParsed(wxCmdLineParser& parser) override;
58#endif
59 int OnRun() override;
60
61 void OnActivateApp(wxActivateEvent& event);
62 bool OpenFile(const std::string& path);
63
64#ifdef LINUX_CRASHRPT
66 void OnFatalException();
67#endif
68
69#ifdef __WXMSW__
70 // Catch malloc/new fail exceptions
71 // All the rest will be caught be CrashRpt
72 bool OnExceptionInMainLoop();
73#endif
74
75 InstanceCheck& m_checker;
76 CommBridge m_comm_bridge;
77
78 RestServer m_rest_server;
79 UsbWatchDaemon& m_usb_watcher;
80
81 DECLARE_EVENT_TABLE()
82private:
84 struct ParsedCmdline {
85 CmdlineAction action;
86 std::string arg;
87 ParsedCmdline(CmdlineAction a, const std::string& s) : action(a), arg(s) {}
88 ParsedCmdline() : ParsedCmdline(CmdlineAction::Skip, "") {}
89 ParsedCmdline(CmdlineAction a) : ParsedCmdline(a, "") {}
90 };
91
92 ParsedCmdline m_parsed_cmdline;
93 int m_exitcode;
94
95 void InitRestListeners();
96 ObsListener rest_activate_listener;
97 ObsListener rest_reverse_listener;
98};
99
100wxDECLARE_APP(MyApp);
101#endif
Common interface for all instance checkers.
Define an action to be performed when a KeyProvider is notified.
Definition observable.h:228
AbstractRestServer implementation and interface to underlying IO thread.
Represents a track, which is a series of connected track points.
Definition track.h:111
Listen to hardware events and notifies SystemEvents when new devices are plugged in.
New NMEA Debugger successor main window.
The local API has a server side handling commands and a client part issuing commands.
Generic hardware events interface.