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, see <https://www.gnu.org/licenses/>.
18 */
19
20#include "allegro_test_utils.h"
21
22#include <board.h>
24
26
27
28std::ostream& ALLEGRO::boost_test_print_type( std::ostream& os, FMT_VER const& aFmtVer )
29{
30 os << static_cast<int>( aFmtVer );
31 return os;
32};
33
34
35static std::string getBoardsDataDir()
36{
37 return KI_TEST::GetPcbnewTestDataDir() + "plugins/allegro/boards/";
38}
39
40
41std::string KI_TEST::AllegroBoardDataDir( const std::string& aBoardName )
42{
43 if( aBoardName.empty() )
44 {
45 return getBoardsDataDir();
46 }
47
48 return getBoardsDataDir() + aBoardName + "/";
49}
50
51
52std::string KI_TEST::AllegroBoardFile( const std::string& aFileName )
53{
54 return getBoardsDataDir() + aFileName;
55}
56
57
62
63
67
68
70{
71 static ALLEGRO_CACHED_LOADER s_AllegroBoardCache;
72 return s_AllegroBoardCache;
73}
74
75
76BOARD* KI_TEST::ALLEGRO_CACHED_LOADER::getCachedBoard( const std::string& aFilePath, bool aForceReload,
77 REPORTER* aReporter )
78{
79 return CACHED_BOARD_LOADER::getCachedBoard( *m_allegroPlugin, aFilePath, aForceReload, aReporter );
80}
static std::string getBoardsDataDir()
General utilities for PCB file IO for QA programs.
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:372
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:71
FMT_VER
The format of an Allegro 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.