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 (C) 1992-2021 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
33class LOCALE_IO;
34
36{
37public:
38 DESIGN_BLOCK_INFO_IMPL( DESIGN_BLOCK_LIST* aOwner, const wxString& aNickname,
39 const wxString& aDesignBlockName )
40 {
41 m_nickname = aNickname;
42 m_dbname = aDesignBlockName;
43 m_num = 0;
44
45 m_owner = aOwner;
46 m_loaded = false;
47 load();
48 }
49
50 // A constructor for cached items
51 DESIGN_BLOCK_INFO_IMPL( const wxString& aNickname, const wxString& aDesignBlockName,
52 const wxString& aDescription, const wxString& aKeywords, int aOrderNum )
53 {
54 m_nickname = aNickname;
55 m_dbname = aDesignBlockName;
56 m_num = aOrderNum;
57 m_doc = aDescription;
58 m_keywords = aKeywords;
59
60 m_owner = nullptr;
61 m_loaded = true;
62 }
63
64
65 // A dummy constructor for use as a target in a binary search
66 DESIGN_BLOCK_INFO_IMPL( const wxString& aNickname, const wxString& aDesignBlockName )
67 {
68 m_nickname = aNickname;
69 m_dbname = aDesignBlockName;
70
71 m_owner = nullptr;
72 m_loaded = true;
73 }
74
75protected:
76 virtual void load() override;
77};
78
79
81{
82public:
85
86 bool ReadDesignBlockFiles( DESIGN_BLOCK_LIB_TABLE* aTable, const wxString* aNickname = nullptr,
87 PROGRESS_REPORTER* aProgressReporter = nullptr ) override;
88
89protected:
90 void loadLibs();
91 void loadDesignBlocks();
92
93private:
99 bool CatchErrors( const std::function<void()>& aFunc );
100
105 std::atomic_bool m_cancelled;
106 std::mutex m_join;
107};
108
109#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)
virtual void load()
lazily load stuff not filled in by constructor. This may throw IO_ERRORS.
SYNC_QUEUE< wxString > m_queue_in
SYNC_QUEUE< wxString > m_queue_out
PROGRESS_REPORTER * m_progress_reporter
Holds a list of DESIGN_BLOCK_INFO objects, along with a list of IO_ERRORs or PARSE_ERRORs that were t...
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:49
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