OpenCPN Partial API docs
Loading...
Searching...
No Matches
ocpn_app.h
Go to the documentation of this file.
1/**************************************************************************
2 * Copyright (C) 2022 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 _OCPN_APP_H
25#define _OCPN_APP_H
26
27#include <string>
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/comm_bridge.h"
39#include "model/local_api.h"
40#include "model/rest_server.h"
41#include "model/track.h"
43
44#include "data_monitor.h"
45
46class MyApp : public wxApp {
47public:
48 MyApp();
49 ~MyApp() {};
50
51 bool OnInit() override;
52 void BuildMainFrame();
53 void LoadChartDatabase();
54
55 void OnMainFrameReady();
56 int OnExit() override;
57#ifndef __ANDROID__
58 void OnInitCmdLine(wxCmdLineParser& parser) override;
59 bool OnCmdLineHelp(wxCmdLineParser& parser) override;
60 bool OnCmdLineParsed(wxCmdLineParser& parser) override;
61#endif
62 int OnRun() override;
63
64 void OnActivateApp(wxActivateEvent& event);
65 bool OpenFile(const std::string& path);
66 void OnUnhandledException() override;
67
68#ifdef LINUX_CRASHRPT
70 void OnFatalException();
71#endif
72
73#ifdef __WXMSW__
74 // Catch malloc/new fail exceptions
75 // All the rest will be caught be CrashRpt
76 bool OnExceptionInMainLoop();
77#endif
78
79 InstanceCheck& m_checker;
80 CommBridge m_comm_bridge;
81
82 RestServer m_rest_server;
83 UsbWatchDaemon& m_usb_watcher;
84
85 DECLARE_EVENT_TABLE()
86private:
88 struct ParsedCmdline {
89 CmdlineAction action;
90 std::string arg;
91 ParsedCmdline(CmdlineAction a, const std::string& s) : action(a), arg(s) {}
92 ParsedCmdline() : ParsedCmdline(CmdlineAction::Skip, "") {}
93 ParsedCmdline(CmdlineAction a) : ParsedCmdline(a, "") {}
94 };
95
96 ParsedCmdline m_parsed_cmdline;
97 int m_exitcode;
98
99 void InitRestListeners();
100 ObsListener rest_activate_listener;
101 ObsListener rest_reverse_listener;
102};
103
104wxDECLARE_APP(MyApp);
105#endif
Process incoming messages.
Definition comm_bridge.h:89
Common interface for all instance checkers.
void BuildMainFrame()
bool OnInit() override
Definition ocpn_app.cpp:717
void OnMainFrameReady()
int OnExit() override
Define an action to be performed when a KeyProvider is notified.
Definition observable.h:257
AbstractRestServer implementation and interface to underlying IO thread.
Listen to hardware events and notifies SystemEvents when new devices are plugged in.
CommBridge class and helpers.
New NMEA Debugger successor main window.
Instance check interface.
The local API has a server side handling commands and a client part issuing commands.
REST API server.
Recorded track abstraction.
Generic hardware events interface.