OpenCPN Partial API docs
Loading...
Searching...
No Matches
observable_evt.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, write to the
17 * Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 **************************************************************************/
20
29#ifndef OBSERVABLE_EVT_H // Guard also used in ocpn_plugin.h
30#define OBSERVABLE_EVT_H
31
32#include <memory>
33
34#include <wx/event.h>
35
37class ObservedEvt;
38
39wxDECLARE_EVENT(obsNOTIFY, ObservedEvt);
40
42class ObservedEvt : public wxCommandEvent {
43public:
44 explicit ObservedEvt(wxEventType commandType = obsNOTIFY, int id = 0)
45 : wxCommandEvent(commandType, id) {}
46
47 ObservedEvt(const ObservedEvt& event) : wxCommandEvent(event) {
48 this->m_shared_ptr = event.m_shared_ptr;
49 }
50
51 [[nodiscard]] wxEvent* Clone() const override{ return new ObservedEvt(*this); }
52
53 [[nodiscard]] std::shared_ptr<const void> GetSharedPtr() const { return m_shared_ptr; }
54
55 void SetSharedPtr(const std::shared_ptr<const void> p) { m_shared_ptr = p; }
56
57private:
58 std::shared_ptr<const void> m_shared_ptr;
59};
60
61#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.