KiCad PCB EDA Suite
Loading...
Searching...
No Matches
design_block.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) 2024 Mike Williams <[email protected]>
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
21#pragma once
22
23#include <kicommon.h>
24#include <lib_id.h>
25#include <lib_tree_item.h>
26#include <json_common.h>
27
28#include <api/common/types/base_types.pb.h>
29#include <api/serializable.h>
30
31
33{
34public:
35 // LIB_TREE_ITEM interface
36 LIB_ID GetLIB_ID() const override { return GetLibId(); }
37 wxString GetName() const override { return m_lib_id.GetLibItemName(); }
38 wxString GetLibNickname() const override { return m_lib_id.GetLibNickname(); }
39 wxString GetDesc() override { return GetLibDescription(); }
40 std::vector<SEARCH_TERM>& GetSearchTerms() override;
41
42 void SetLibId( const LIB_ID& aName ) { m_lib_id = aName; }
43 const LIB_ID& GetLibId() const { return m_lib_id; }
44 LIB_ID& GetLibId() { return m_lib_id; }
45
46 const wxString& GetLibDescription() const { return m_libDescription; }
47 void SetLibDescription( const wxString& aDesc ) { m_libDescription = aDesc; }
48
49 const wxString& GetKeywords() const { return m_keywords; }
50 void SetKeywords( const wxString& aKeywords ) { m_keywords = aKeywords; }
51
52 const wxString& GetSchematicFile() const { return m_schematicFile; }
53 void SetSchematicFile( const wxString& aFile ) { m_schematicFile = aFile; }
54
55 const wxString& GetBoardFile() const { return m_boardFile; }
56 void SetBoardFile( const wxString& aFile ) { m_boardFile = aFile; }
57
58 const nlohmann::ordered_map<wxString, wxString>& GetFields() const { return m_fields; }
59 nlohmann::ordered_map<wxString, wxString>& GetFields() { return m_fields; }
60
61 void Serialize( google::protobuf::Any &aContainer ) const override;
62 void Serialize( kiapi::common::types::DesignBlock& aDesignBlock ) const;
63
64 bool Deserialize( const google::protobuf::Any &aContainer ) override;
65 bool Deserialize( const kiapi::common::types::DesignBlock& aDesignBlock );
66
67 DESIGN_BLOCK() = default;
68
70 DESIGN_BLOCK( DESIGN_BLOCK&& aOther ) = delete;
71
72private:
74 wxString m_schematicFile;
75 wxString m_boardFile;
77 wxString m_keywords;
78
79 nlohmann::ordered_map<wxString, wxString> m_fields;
80 std::vector<SEARCH_TERM> m_searchTerms;
81};
void SetLibDescription(const wxString &aDesc)
wxString m_schematicFile
File name and path for schematic file.
void SetKeywords(const wxString &aKeywords)
LIB_ID & GetLibId()
wxString GetLibNickname() const override
wxString GetDesc() override
void SetSchematicFile(const wxString &aFile)
DESIGN_BLOCK()=default
void SetBoardFile(const wxString &aFile)
DESIGN_BLOCK(DESIGN_BLOCK &&aOther)=delete
This is the only way to get m_fields to compile as a class member.
LIB_ID GetLIB_ID() const override
const wxString & GetKeywords() const
wxString m_keywords
Search keywords to find design block in library.
LIB_ID m_lib_id
const wxString & GetLibDescription() const
wxString m_libDescription
File name and path for documentation file.
std::vector< SEARCH_TERM > m_searchTerms
void SetLibId(const LIB_ID &aName)
const wxString & GetBoardFile() const
const wxString & GetSchematicFile() const
nlohmann::ordered_map< wxString, wxString > m_fields
wxString m_boardFile
File name and path for board file.
const LIB_ID & GetLibId() const
wxString GetName() const override
const nlohmann::ordered_map< wxString, wxString > & GetFields() const
nlohmann::ordered_map< wxString, wxString > & GetFields()
A logical library item identifier and consists of various portions much like a URI.
Definition lib_id.h:45
A mix-in to provide polymorphism between items stored in libraries (symbols, aliases and footprints).
virtual std::vector< SEARCH_TERM > & GetSearchTerms()=0
Interface for objects that can be serialized to Protobuf messages.
virtual void Serialize(google::protobuf::Any &aContainer) const
Serializes this object to the given Any message.
virtual bool Deserialize(const google::protobuf::Any &aContainer)
Deserializes the given protobuf message into this object.
#define KICOMMON_API
Definition kicommon.h:27