KiCad PCB EDA Suite
Loading...
Searching...
No Matches
kiway_holder.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 The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#ifndef KIWAY_HOLDER_H_
21#define KIWAY_HOLDER_H_
22
23#include <kicommon.h>
24
25#include <wx/debug.h>
26
27
28class KIWAY;
29class PROJECT;
30class wxWindow;
31
38{
39public:
41
42 KIWAY_HOLDER( KIWAY* aKiway, HOLDER_TYPE aType ) :
43 m_kiway( aKiway ),
44 m_type( aType )
45 {}
46
47 HOLDER_TYPE GetType() const { return m_type; }
48
54 KIWAY& Kiway() const
55 {
56 wxASSERT( m_kiway ); // smoke out bugs in Debug build, then Release runs fine.
57 return *m_kiway;
58 }
59
64 bool HasKiway() const
65 {
66 return m_kiway != nullptr;
67 }
68
72 PROJECT& Prj() const;
73
81 void SetKiway( wxWindow* aDest, KIWAY* aKiway );
82
83private:
84 // private, all setting is done through SetKiway().
85 KIWAY* m_kiway; // no ownership.
87};
88
89
90#endif // KIWAY_HOLDER_H_
KIWAY * m_kiway
KIWAY_HOLDER(KIWAY *aKiway, HOLDER_TYPE aType)
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
bool HasKiway() const
Safety check before asking for the Kiway reference.
HOLDER_TYPE GetType() const
HOLDER_TYPE m_type
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition kiway.h:340
Container for project specific data.
Definition project.h:63
PROJECT & Prj()
Definition kicad.cpp:727
#define KICOMMON_API
Definition kicommon.h:27