2017-03-23 00:59:25 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2021-06-04 13:04:30 +00:00
|
|
|
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
2017-03-23 00:59:25 +00:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation, either version 3 of the License, or (at your
|
|
|
|
* option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef FOOTPRINT_INFO_IMPL_H
|
|
|
|
#define FOOTPRINT_INFO_IMPL_H
|
|
|
|
|
|
|
|
#include <atomic>
|
|
|
|
#include <functional>
|
|
|
|
#include <memory>
|
|
|
|
#include <thread>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include <footprint_info.h>
|
2023-09-08 11:07:52 +00:00
|
|
|
#include <core/sync_queue.h>
|
2017-03-23 00:59:25 +00:00
|
|
|
|
|
|
|
class LOCALE_IO;
|
|
|
|
|
|
|
|
class FOOTPRINT_INFO_IMPL : public FOOTPRINT_INFO
|
|
|
|
{
|
|
|
|
public:
|
2018-04-16 22:18:02 +00:00
|
|
|
FOOTPRINT_INFO_IMPL( FOOTPRINT_LIST* aOwner, const wxString& aNickname,
|
|
|
|
const wxString& aFootprintName )
|
2017-03-23 00:59:25 +00:00
|
|
|
{
|
|
|
|
m_nickname = aNickname;
|
|
|
|
m_fpname = aFootprintName;
|
|
|
|
m_num = 0;
|
|
|
|
m_pad_count = 0;
|
|
|
|
m_unique_pad_count = 0;
|
2018-07-30 13:18:37 +00:00
|
|
|
|
2018-08-03 16:53:38 +00:00
|
|
|
m_owner = aOwner;
|
|
|
|
m_loaded = false;
|
2017-03-23 00:59:25 +00:00
|
|
|
load();
|
2018-07-30 13:18:37 +00:00
|
|
|
}
|
|
|
|
|
2018-08-03 16:53:38 +00:00
|
|
|
// A constructor for cached items
|
|
|
|
FOOTPRINT_INFO_IMPL( const wxString& aNickname, const wxString& aFootprintName,
|
|
|
|
const wxString& aDescription, const wxString& aKeywords,
|
|
|
|
int aOrderNum, unsigned int aPadCount, unsigned int aUniquePadCount )
|
|
|
|
{
|
|
|
|
m_nickname = aNickname;
|
|
|
|
m_fpname = aFootprintName;
|
|
|
|
m_num = aOrderNum;
|
|
|
|
m_pad_count = aPadCount;
|
|
|
|
m_unique_pad_count = aUniquePadCount;
|
|
|
|
m_doc = aDescription;
|
|
|
|
m_keywords = aKeywords;
|
|
|
|
|
|
|
|
m_owner = nullptr;
|
|
|
|
m_loaded = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-07-30 13:18:37 +00:00
|
|
|
// A dummy constructor for use as a target in a binary search
|
2018-08-03 21:09:48 +00:00
|
|
|
FOOTPRINT_INFO_IMPL( const wxString& aNickname, const wxString& aFootprintName )
|
2018-07-30 13:18:37 +00:00
|
|
|
{
|
2018-08-03 21:09:48 +00:00
|
|
|
m_nickname = aNickname;
|
2018-07-30 13:18:37 +00:00
|
|
|
m_fpname = aFootprintName;
|
2018-08-03 16:53:38 +00:00
|
|
|
|
|
|
|
m_owner = nullptr;
|
|
|
|
m_loaded = true;
|
2017-03-23 00:59:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void load() override;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class FOOTPRINT_LIST_IMPL : public FOOTPRINT_LIST
|
|
|
|
{
|
2021-06-04 13:04:30 +00:00
|
|
|
public:
|
|
|
|
FOOTPRINT_LIST_IMPL();
|
2022-06-15 00:41:10 +00:00
|
|
|
virtual ~FOOTPRINT_LIST_IMPL() {};
|
2017-03-23 00:59:25 +00:00
|
|
|
|
2021-06-04 13:04:30 +00:00
|
|
|
void WriteCacheToFile( const wxString& aFilePath ) override;
|
|
|
|
void ReadCacheFromFile( const wxString& aFilePath ) override;
|
|
|
|
|
|
|
|
bool ReadFootprintFiles( FP_LIB_TABLE* aTable, const wxString* aNickname = nullptr,
|
|
|
|
PROGRESS_REPORTER* aProgressReporter = nullptr ) override;
|
2017-03-23 00:59:25 +00:00
|
|
|
|
|
|
|
protected:
|
2022-06-15 00:41:10 +00:00
|
|
|
void loadLibs();
|
|
|
|
void loadFootprints();
|
2017-03-23 00:59:25 +00:00
|
|
|
|
2021-06-04 13:04:30 +00:00
|
|
|
private:
|
|
|
|
/**
|
|
|
|
* Call aFunc, pushing any IO_ERRORs and std::exceptions it throws onto m_errors.
|
|
|
|
*
|
|
|
|
* @return true if no error occurred.
|
|
|
|
*/
|
|
|
|
bool CatchErrors( const std::function<void()>& aFunc );
|
2018-08-03 16:53:38 +00:00
|
|
|
|
2021-06-04 13:04:30 +00:00
|
|
|
SYNC_QUEUE<wxString> m_queue_in;
|
|
|
|
SYNC_QUEUE<wxString> m_queue_out;
|
|
|
|
long long m_list_timestamp;
|
|
|
|
PROGRESS_REPORTER* m_progress_reporter;
|
|
|
|
std::atomic_bool m_cancelled;
|
|
|
|
std::mutex m_join;
|
2017-03-23 00:59:25 +00:00
|
|
|
};
|
|
|
|
|
2018-03-25 12:48:13 +00:00
|
|
|
extern FOOTPRINT_LIST_IMPL GFootprintList; // KIFACE scope.
|
|
|
|
|
|
|
|
|
2017-03-23 00:59:25 +00:00
|
|
|
#endif // FOOTPRINT_INFO_IMPL_H
|