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"
43class Track;
44
45class MyApp : public wxApp {
46public:
47 MyApp();
48 ~MyApp() {};
49
50 bool OnInit() override;
51 int OnExit() override;
52#ifndef __ANDROID__
53 void OnInitCmdLine(wxCmdLineParser& parser) override;
54 bool OnCmdLineHelp(wxCmdLineParser& parser) override;
55 bool OnCmdLineParsed(wxCmdLineParser& parser) override;
56#endif
57 int OnRun() override;
58
59 void OnActivateApp(wxActivateEvent& event);
60 bool OpenFile(const std::string& path);
61
62#ifdef LINUX_CRASHRPT
64 void OnFatalException();
65#endif
66
67#ifdef __WXMSW__
68 // Catch malloc/new fail exceptions
69 // All the rest will be caught be CrashRpt
70 bool OnExceptionInMainLoop();
71#endif
72
73 InstanceCheck& m_checker;
74 CommBridge m_comm_bridge;
75
76 RestServer m_rest_server;
77 UsbWatchDaemon& m_usb_watcher;
78
79 DECLARE_EVENT_TABLE()
80private:
82 struct ParsedCmdline {
83 CmdlineAction action;
84 std::string arg;
85 ParsedCmdline(CmdlineAction a, const std::string& s) : action(a), arg(s) {}
86 ParsedCmdline() : ParsedCmdline(CmdlineAction::Skip, "") {}
87 ParsedCmdline(CmdlineAction a) : ParsedCmdline(a, "") {}
88 };
89
90 ParsedCmdline m_parsed_cmdline;
91 int m_exitcode;
92
93 void InitRestListeners();
94 ObsListener rest_activate_listener;
95 ObsListener rest_reverse_listener;
96};
97
98wxDECLARE_APP(MyApp);
99#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:78
Listen to hardware events and notifies SystemEvents when new devices are plugged in.
The local API has a server side handling commands and a client part issuing commands.
Generic hardware events interface.