KiCad PCB EDA Suite
Loading...
Searching...
No Matches
component_class_cache_proxy.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 The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20
21#ifndef PCBNEW_COMPONENT_CLASS_CACHE_PROXY_H
22#define PCBNEW_COMPONENT_CLASS_CACHE_PROXY_H
23
26
27class FOOTPRINT;
28
29/*
30 * A class which acts as a cache-aware proxy for a FOOTPRINT's component class.
31 * Creating dynamic component classes (from component class generators) is an
32 * expensive operation, so we want to cache the results. This class is a cache
33 * proxy which tracks the validity of the cached component class with respect
34 * to loaded static and dynamic component class rules
35 */
37{
38public:
39 explicit COMPONENT_CLASS_CACHE_PROXY( FOOTPRINT* footprint ) : m_footprint( footprint ) {}
40
45 {
46 m_staticComponentClass = compClass;
47 }
48
51
54
56 void RecomputeComponentClass( COMPONENT_CLASS_MANAGER* manager = nullptr ) const;
57
61
62protected:
64
66 mutable const COMPONENT_CLASS* m_dynamicComponentClass{ nullptr };
67 mutable const COMPONENT_CLASS* m_finalComponentClass{ nullptr };
68
69 mutable long long int m_lastTickerValue{ -1 };
70};
71
72#endif //PCBNEW_COMPONENT_CLASS_CACHE_PROXY_H
COMPONENT_CLASS_CACHE_PROXY(FOOTPRINT *footprint)
void InvalidateCache()
Invalidates the cache The component class will be recalculated on the next access.
const COMPONENT_CLASS * m_staticComponentClass
void RecomputeComponentClass(COMPONENT_CLASS_MANAGER *manager=nullptr) const
Forces recomputation of the component class.
const COMPONENT_CLASS * GetStaticComponentClass() const
Gets the static component class.
void SetStaticComponentClass(const COMPONENT_CLASS *compClass)
Sets the static component class Static component classes are assigned in the schematic,...
const COMPONENT_CLASS * GetComponentClass() const
Gets the full component class (static + dynamic resultant component class)
const COMPONENT_CLASS * m_finalComponentClass
const COMPONENT_CLASS * m_dynamicComponentClass
A class to manage Component Classes in a board context.
A lightweight representation of a component class.