2022-05-29 19:29:32 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2022 Jon Evans <jon@craftyjon.com>
|
|
|
|
* Copyright (C) 2022 KiCad Developers, see AUTHORS.txt for contributors.
|
|
|
|
*
|
|
|
|
* 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 KICAD_DATABASE_LIB_SETTINGS_H
|
|
|
|
#define KICAD_DATABASE_LIB_SETTINGS_H
|
|
|
|
|
|
|
|
#include <settings/json_settings.h>
|
2024-02-19 20:45:24 +00:00
|
|
|
#include <wx/string.h>
|
2022-05-29 19:29:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
enum class DATABASE_SOURCE_TYPE
|
|
|
|
{
|
|
|
|
ODBC,
|
|
|
|
INVALID
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct DATABASE_SOURCE
|
|
|
|
{
|
|
|
|
DATABASE_SOURCE_TYPE type;
|
|
|
|
std::string dsn;
|
|
|
|
std::string username;
|
|
|
|
std::string password;
|
|
|
|
int timeout;
|
|
|
|
std::string connection_string;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct DATABASE_FIELD_MAPPING
|
|
|
|
{
|
2024-02-19 20:45:24 +00:00
|
|
|
const std::string column; ///< Database column name
|
|
|
|
const std::string name; ///< KiCad field name
|
|
|
|
const wxString name_wx; ///< KiCad field name (converted)
|
|
|
|
const bool visible_on_add; ///< Whether to show the field when placing the symbol
|
|
|
|
const bool visible_in_chooser; ///< Whether the column is shown by default in the chooser
|
|
|
|
const bool show_name; ///< Whether or not to show the field name as well as its value
|
|
|
|
const bool inherit_properties; ///< Whether or not to inherit properties from symbol field
|
|
|
|
|
|
|
|
explicit DATABASE_FIELD_MAPPING( std::string aColumn, std::string aName, bool aVisibleOnAdd,
|
|
|
|
bool aVisibleInChooser, bool aShowName,
|
|
|
|
bool aInheritProperties );
|
2022-05-29 19:29:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2022-11-09 03:18:29 +00:00
|
|
|
struct MAPPABLE_SYMBOL_PROPERTIES
|
|
|
|
{
|
|
|
|
std::string description;
|
|
|
|
std::string footprint_filters;
|
2022-11-10 01:50:01 +00:00
|
|
|
std::string keywords;
|
2023-08-08 16:32:08 +00:00
|
|
|
std::string exclude_from_sim;
|
2022-11-09 03:18:29 +00:00
|
|
|
std::string exclude_from_bom;
|
|
|
|
std::string exclude_from_board;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2022-05-29 19:29:32 +00:00
|
|
|
/**
|
|
|
|
* A database library table will be mapped to a sub-library provided by the database library entry
|
|
|
|
* in the KiCad symbol/footprint library table. A single database library config file (managed by
|
|
|
|
* this class) may contain more than one table mapping, and each will have its own nickname.
|
|
|
|
*
|
|
|
|
* The LIB_ID for parts placed from this library will be constructed from the nickname of the
|
|
|
|
* database library itself, plus the nickname of the particular sub-library and the value of the
|
|
|
|
* key column for the placed part.
|
|
|
|
*
|
|
|
|
* For example, if a database library is configured with the nickname "PartsDB" and it provides a
|
|
|
|
* table called "Capacitors", with `key_col` set to "Part Number", the LIB_ID for a capacitor placed
|
|
|
|
* from this table will look something like `PartsDB-Capacitors:CAP-001`
|
|
|
|
*/
|
|
|
|
struct DATABASE_LIB_TABLE
|
|
|
|
{
|
|
|
|
std::string name; ///< KiCad library nickname (will form part of the LIB_ID)
|
|
|
|
std::string table; ///< Database table to pull content from
|
|
|
|
std::string key_col; ///< Unique key column name (will form part of the LIB_ID)
|
|
|
|
std::string symbols_col; ///< Column name containing KiCad symbol refs
|
|
|
|
std::string footprints_col; ///< Column name containing KiCad footprint refs
|
|
|
|
|
2022-11-09 03:18:29 +00:00
|
|
|
MAPPABLE_SYMBOL_PROPERTIES properties;
|
2022-05-29 19:29:32 +00:00
|
|
|
std::vector<DATABASE_FIELD_MAPPING> fields;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2022-08-31 02:18:21 +00:00
|
|
|
struct DATABASE_CACHE_SETTINGS
|
|
|
|
{
|
|
|
|
int max_size; ///< Maximum number of single-row results to cache
|
|
|
|
int max_age; ///< Max age of cached rows before they expire, in seconds
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2022-05-29 19:29:32 +00:00
|
|
|
class DATABASE_LIB_SETTINGS : public JSON_SETTINGS
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DATABASE_LIB_SETTINGS( const std::string& aFilename );
|
|
|
|
|
|
|
|
virtual ~DATABASE_LIB_SETTINGS() {}
|
|
|
|
|
|
|
|
DATABASE_SOURCE m_Source;
|
|
|
|
|
|
|
|
std::vector<DATABASE_LIB_TABLE> m_Tables;
|
|
|
|
|
2022-08-31 02:18:21 +00:00
|
|
|
DATABASE_CACHE_SETTINGS m_Cache;
|
|
|
|
|
2022-05-29 19:29:32 +00:00
|
|
|
protected:
|
|
|
|
wxString getFileExt() const override;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif //KICAD_DATABASE_LIB_SETTINGS_H
|