KiCad PCB EDA Suite
Loading...
Searching...
No Matches
kiway_mail.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2014 SoftPLC Corporation, Dick Hollenbeck <[email protected]>
5 * Copyright The KiCad Developers, see AUTHORS.TXT for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
21#ifndef KIWAY_MAIL_H
22#define KIWAY_MAIL_H
23
24#include <frame_type.h>
25#include <mail_type.h>
26#include <kicommon.h>
27#include <wx/string.h>
28#include <wx/event.h>
29
33class KICOMMON_API KIWAY_MAIL_EVENT : public wxEvent
34{
35public:
40
45 {
46 return (MAIL_T) GetId(); // re-purposed control id.
47 }
48
52 std::string& GetPayload() { return m_payload; }
53 void SetPayload( const std::string& aPayload ) { m_payload = aPayload; }
54
55 KIWAY_MAIL_EVENT* Clone() const override { return new KIWAY_MAIL_EVENT( *this ); }
56
57 KIWAY_MAIL_EVENT( FRAME_T aDestination, MAIL_T aCommand, std::string& aPayload,
58 wxWindow* aSource = nullptr );
59
60 KIWAY_MAIL_EVENT( const KIWAY_MAIL_EVENT& anOther );
61
62private:
64 std::string& m_payload;
65};
66
67
68typedef void ( wxEvtHandler::*kiwayMailFunction )( KIWAY_MAIL_EVENT& );
69
71#define kiwayMailHandler( func ) wxEVENT_HANDLER_CAST( kiwayMailFunction, func )
72
74#define EVT_KIWAY_EXPRESS( func ) \
75 wx__DECLARE_EVT0( EDA_KIWAY_MAIL_RECEIVED, kiwayMailHandler( func ) )
76
78
79#endif // KIWAY_EXPRESS_H_
Carry a payload from one KIWAY_PLAYER to another within a PROJECT.
Definition kiway_mail.h:34
std::string & GetPayload()
Return the payload, which can be any text but it typically self identifying s-expression.
Definition kiway_mail.h:52
FRAME_T m_destination
could have been a bitmap indicating multiple recipients.
Definition kiway_mail.h:63
FRAME_T Dest()
Return the destination player id of the message.
Definition kiway_mail.h:39
KIWAY_MAIL_EVENT * Clone() const override
Definition kiway_mail.h:55
std::string & m_payload
very often s-expression text, but not always.
Definition kiway_mail.h:64
void SetPayload(const std::string &aPayload)
Definition kiway_mail.h:53
KIWAY_MAIL_EVENT(FRAME_T aDestination, MAIL_T aCommand, std::string &aPayload, wxWindow *aSource=nullptr)
MAIL_T Command()
Returns the MAIL_T associated with this mail.
Definition kiway_mail.h:44
FRAME_T
The set of EDA_BASE_FRAME derivatives, typically stored in EDA_BASE_FRAME::m_Ident.
Definition frame_type.h:29
#define KICOMMON_API
Definition kicommon.h:27
wxDECLARE_EXPORTED_EVENT(KICOMMON_API, EDA_KIWAY_MAIL_RECEIVED, KIWAY_MAIL_EVENT)
void(wxEvtHandler::* kiwayMailFunction)(KIWAY_MAIL_EVENT &)
Definition kiway_mail.h:68
MAIL_T
The set of mail types sendable via KIWAY::ExpressMail() and supplied as the aCommand parameter to tha...
Definition mail_type.h:34