KiCad PCB EDA Suite
Loading...
Searching...
No Matches
design_block_info_impl.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 modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef DESIGN_BLOCK_INFO_IMPL_H
21#define DESIGN_BLOCK_INFO_IMPL_H
22
23#include <atomic>
24#include <functional>
25#include <memory>
26#include <thread>
27#include <vector>
28
29#include <kicommon.h>
30#include <design_block_info.h>
31#include <core/sync_queue.h>
32
34{
35public:
36 DESIGN_BLOCK_INFO_IMPL( DESIGN_BLOCK_LIST* aOwner, const wxString& aNickname,
37 const wxString& aDesignBlockName )
38 {
39 m_nickname = aNickname;
40 m_dbname = aDesignBlockName;
41 m_num = 0;
42
43 m_owner = aOwner;
44 m_loaded = false;
45 load();
46 }
47
48 // A constructor for cached items
49 DESIGN_BLOCK_INFO_IMPL( const wxString& aNickname, const wxString& aDesignBlockName,
50 const wxString& aDescription, const wxString& aKeywords, int aOrderNum )
51 {
52 m_nickname = aNickname;
53 m_dbname = aDesignBlockName;
54 m_num = aOrderNum;
55 m_doc = aDescription;
56 m_keywords = aKeywords;
57
58 m_owner = nullptr;
59 m_loaded = true;
60 }
61
62
63 // A dummy constructor for use as a target in a binary search
64 DESIGN_BLOCK_INFO_IMPL( const wxString& aNickname, const wxString& aDesignBlockName )
65 {
66 m_nickname = aNickname;
67 m_dbname = aDesignBlockName;
68
69 m_owner = nullptr;
70 m_loaded = true;
71 }
72
73protected:
74 virtual void load() override;
75};
76
77
79{
80public:
83
84 bool ReadDesignBlockFiles( DESIGN_BLOCK_LIB_TABLE* aTable, const wxString* aNickname = nullptr,
85 PROGRESS_REPORTER* aProgressReporter = nullptr ) override;
86
87protected:
88 void loadDesignBlocks();
89
90private:
96 bool CatchErrors( const std::function<void()>& aFunc );
97
98private:
102 std::atomic_bool m_cancelled;
103 std::mutex m_join;
104};
105
106#endif // DESIGN_BLOCK_INFO_IMPL_H
DESIGN_BLOCK_INFO_IMPL(const wxString &aNickname, const wxString &aDesignBlockName, const wxString &aDescription, const wxString &aKeywords, int aOrderNum)
DESIGN_BLOCK_INFO_IMPL(DESIGN_BLOCK_LIST *aOwner, const wxString &aNickname, const wxString &aDesignBlockName)
DESIGN_BLOCK_INFO_IMPL(const wxString &aNickname, const wxString &aDesignBlockName)
Helper class to handle the list of design blocks available in libraries.
virtual void load()
lazily load stuff not filled in by constructor. This may throw IO_ERRORS.
PROGRESS_REPORTER * m_progress_reporter
SYNC_QUEUE< wxString > m_queue
Holds a list of DESIGN_BLOCK_INFO objects, along with a list of IO_ERRORs or PARSE_ERRORs that were t...
A progress reporter interface for use in multi-threaded environments.
Synchronized, locking queue.
Definition: sync_queue.h:32
#define KICOMMON_API
Definition: kicommon.h:28