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 int OnExit() override;
53#ifndef __ANDROID__
54 void OnInitCmdLine(wxCmdLineParser& parser) override;
55 bool OnCmdLineHelp(wxCmdLineParser& parser) override;
56 bool OnCmdLineParsed(wxCmdLineParser& parser) override;
57#endif
58 int OnRun() override;
59
60 void OnActivateApp(wxActivateEvent& event);
61 bool OpenFile(const std::string& path);
62
63#ifdef LINUX_CRASHRPT
65 void OnFatalException();
66#endif
67
68#ifdef __WXMSW__
69 // Catch malloc/new fail exceptions
70 // All the rest will be caught be CrashRpt
71 bool OnExceptionInMainLoop();
72#endif
73
74 InstanceCheck& m_checker;
75 CommBridge m_comm_bridge;
76
77 RestServer m_rest_server;
78 UsbWatchDaemon& m_usb_watcher;
79
80 DECLARE_EVENT_TABLE()
81private:
83 struct ParsedCmdline {
84 CmdlineAction action;
85 std::string arg;
86 ParsedCmdline(CmdlineAction a, const std::string& s) : action(a), arg(s) {}
87 ParsedCmdline() : ParsedCmdline(CmdlineAction::Skip, "") {}
88 ParsedCmdline(CmdlineAction a) : ParsedCmdline(a, "") {}
89 };
90
91 ParsedCmdline m_parsed_cmdline;
92 int m_exitcode;
93
94 void InitRestListeners();
95 ObsListener rest_activate_listener;
96 ObsListener rest_reverse_listener;
97};
98
99wxDECLARE_APP(MyApp);
100#endif
Process incoming messages.
Definition comm_bridge.h:89
Common interface for all instance checkers.
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.