OpenCPN Partial API docs
Loading...
Searching...
No Matches
event.h
Go to the documentation of this file.
1/*************************************************************************
2 *
3 * Copyright (C) 2022 - 2025 Alec Leamas
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, see <https://www.gnu.org/licenses/>.
17 **************************************************************************/
18
27#ifndef OBSERVABLE_EVT_H // Guard also used in ocpn_plugin.h
28#define OBSERVABLE_EVT_H
29
30#include <memory>
31
32#include <wx/event.h>
33
35class ObservedEvt;
36
37wxDECLARE_EVENT(obsNOTIFY, ObservedEvt);
38
43class ObservedEvt : public wxCommandEvent {
44public:
45 explicit ObservedEvt(wxEventType commandType = obsNOTIFY, int id = 0)
46 : wxCommandEvent(commandType, id) {}
47
48 ObservedEvt(const ObservedEvt& event) : wxCommandEvent(event) {
49 this->m_shared_ptr = event.m_shared_ptr;
50 }
51
52 [[nodiscard]] wxEvent* Clone() const override{ return new ObservedEvt(*this); }
53
54 [[nodiscard]] std::shared_ptr<const void> GetSharedPtr() const { return m_shared_ptr; }
55
56 void SetSharedPtr(const std::shared_ptr<const void> p) { m_shared_ptr = p; }
57
58private:
59 std::shared_ptr<const void> m_shared_ptr;
60};
61
62#endif // OBSERVABLE_EVT_H
Custom event class for OpenCPN's notification system.
void SetSharedPtr(std::shared_ptr< const void > p)
Sets the event's payload data.
wxEvent * Clone() const
Creates a cloned copy of this event.
std::shared_ptr< const void > GetSharedPtr() const
Gets the event's payload data.