KiCad PCB EDA Suite
Loading...
Searching...
No Matches
allegro_test_utils.cpp
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, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24#include "allegro_test_utils.h"
25
26#include <board.h>
28
30
31
32std::ostream& ALLEGRO::boost_test_print_type( std::ostream& os, FMT_VER const& aFmtVer )
33{
34 os << static_cast<int>( aFmtVer );
35 return os;
36};
37
38
39static std::string getBoardsDataDir()
40{
41 return KI_TEST::GetPcbnewTestDataDir() + "plugins/allegro/boards/";
42}
43
44
45std::string KI_TEST::AllegroBoardDataDir( const std::string& aBoardName )
46{
47 if( aBoardName.empty() )
48 {
49 return getBoardsDataDir();
50 }
51
52 return getBoardsDataDir() + aBoardName + "/";
53}
54
55
56std::string KI_TEST::AllegroBoardFile( const std::string& aFileName )
57{
58 return getBoardsDataDir() + aFileName;
59}
60
61
66
67
71
72
74{
75 static ALLEGRO_CACHED_LOADER s_AllegroBoardCache;
76 return s_AllegroBoardCache;
77}
78
79
80BOARD* KI_TEST::ALLEGRO_CACHED_LOADER::getCachedBoard( const std::string& aFilePath, bool aForceReload,
81 REPORTER* aReporter )
82{
83 return CACHED_BOARD_LOADER::getCachedBoard( *m_allegroPlugin, aFilePath, aForceReload, aReporter );
84}
static std::string getBoardsDataDir()
General utilities for PCB file IO for QA programs.
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:322
Singleton class to load Allegro boards and cache them in memory, to avoid repeatedly loading and pars...
static ALLEGRO_CACHED_LOADER & GetInstance()
Get the singleton instance of the Allegro board cache loader.
BOARD * getCachedBoard(const std::string &aFilePath, bool aForceReload, REPORTER *aReporter) override
Implementation of CACHED_BOARD_LOADER interface with our Allegro PCB_IO plugin.
std::unique_ptr< PCB_IO_ALLEGRO > m_allegroPlugin
BOARD * getCachedBoard(PCB_IO &aIoPlugin, const std::string &aFilePath, bool aForceReload, REPORTER *aReporter)
A pure virtual class used to derive REPORTER objects from.
Definition reporter.h:73
FMT_VER
The format of an Allego file.
std::ostream & boost_test_print_type(std::ostream &os, FMT_VER const &aFmtVer)
std::string GetPcbnewTestDataDir()
Utility which returns a path to the data directory where the test board files are stored.
std::string AllegroBoardDataDir(const std::string &aBoardName)
std::string AllegroBoardFile(const std::string &aFileName)
STL namespace.