LibrePCB Developers Documentation
projectattributelookup.h
Go to the documentation of this file.
1/*
2 * LibrePCB - Professional EDA for everyone!
3 * Copyright (C) 2013 LibrePCB Developers, see AUTHORS.md for contributors.
4 * https://librepcb.org/
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (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 <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef LIBREPCB_CORE_PROJECTATTRIBUTELOOKUP_H
21#define LIBREPCB_CORE_PROJECTATTRIBUTELOOKUP_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include <QtCore>
27
28#include <functional>
29#include <memory>
30
31/*******************************************************************************
32 * Namespace / Forward Declarations
33 ******************************************************************************/
34namespace librepcb {
35
36class AssemblyVariant;
37class BI_Device;
38class Board;
39class Circuit;
40class ComponentInstance;
41class Part;
42class Project;
43class SI_Symbol;
44class Schematic;
45
46/*******************************************************************************
47 * Class ProjectAttributeLookup
48 ******************************************************************************/
49
68 typedef std::function<QString(const QString&)> LookupFunction;
69
70public:
71 // Constructors / Destructor
75 std::shared_ptr<AssemblyVariant> av) noexcept;
77 QPointer<const BI_Device> device,
78 std::shared_ptr<const Part> part) noexcept;
80 std::shared_ptr<AssemblyVariant> av) noexcept;
82 std::shared_ptr<AssemblyVariant> av) noexcept;
83 ProjectAttributeLookup(const SI_Symbol& obj, QPointer<const BI_Device> device,
84 std::shared_ptr<const Part> part,
85 std::shared_ptr<AssemblyVariant> av) noexcept;
87 std::shared_ptr<const Part> part) noexcept;
88 ~ProjectAttributeLookup() noexcept;
89
90 // Operator Overloadings
91
100 QString operator()(const QString& key) const noexcept;
101
102 ProjectAttributeLookup& operator=(const ProjectAttributeLookup& rhs) noexcept;
103
104private: // Methods
105 static bool query(const Project& project, const QString& key,
106 QString& value) noexcept;
107 static bool query(const AssemblyVariant& av, const Circuit& circuit,
108 const QString& key, QString& value) noexcept;
109 static bool query(const ComponentInstance& cmp, const QString& key,
110 QString& value) noexcept;
111 static bool query(const Schematic& schematic, const QString& key,
112 QString& value) noexcept;
113 static bool query(const Board& board, const QString& key,
114 QString& value) noexcept;
115 static bool query(const SI_Symbol& symbol, const QString& key,
116 QString& value) noexcept;
117 static bool query(const BI_Device& device, const QString& key,
118 QString& value) noexcept;
119 static bool query(const Part& part, const QString& key,
120 QString& value) noexcept;
121
122private: // Data
124};
125
126/*******************************************************************************
127 * End of File
128 ******************************************************************************/
129
130} // namespace librepcb
131
132#endif
The AssemblyVariant class.
Definition: assemblyvariant.h:45
The BI_Device class.
Definition: bi_device.h:57
The Board class represents a PCB of a project and is always part of a circuit.
Definition: board.h:73
The Circuit class represents all electrical connections in a project (drawn in the schematics)
Definition: circuit.h:70
The ComponentInstance class.
Definition: componentinstance.h:54
The Part class.
Definition: part.h:46
Determine an attribute value of an object within a librepcb::Project.
Definition: projectattributelookup.h:67
~ProjectAttributeLookup() noexcept
Definition: projectattributelookup.cpp:148
LookupFunction mFunction
Definition: projectattributelookup.h:123
static bool query(const Project &project, const QString &key, QString &value) noexcept
Definition: projectattributelookup.cpp:170
std::function< QString(const QString &)> LookupFunction
Definition: projectattributelookup.h:68
The Project class represents a whole (opened) project with all its content.
Definition: project.h:71
The SI_Symbol class.
Definition: si_symbol.h:54
The Schematic class represents one schematic page of a project and is always part of a circuit.
Definition: schematic.h:74
Definition: occmodel.cpp:77