Minsky
lock.h
Go to the documentation of this file.
1 /*
2  @copyright Steve Keen 2021
3  @author Russell Standish
4  This file is part of Minsky.
5 
6  Minsky is free software: you can redistribute it and/or modify it
7  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  Minsky 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 Minsky. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #ifndef LOCK_H
21 #define LOCK_H
22 
23 #include "item.h"
24 #include "ravelState.h"
25 #include "ravelWrap.h"
26 #include "SVGItem.h"
27 
28 namespace minsky
29 {
30  class Lock: public ItemT<Lock>
31  {
32  public:
33  Lock();
34  Lock(const Lock& x): ItemT<Lock>(x) {addPorts();}
35  Lock& operator=(const Lock& x)=default;
36  void addPorts();
37  ravel::RavelState lockedState;
38 
39  bool locked() const {return !lockedState.empty();}
40  void toggleLocked();
41 
44  void draw(cairo_t* cairo) const override;
45  Units units(bool) const override;
47  Ravel* ravelInput() const;
48  void applyLockedStateToRavel() const;
49  };
50 }
51 
52 #include "lock.cd"
53 #endif
Ravel * ravelInput() const
Ravel this is connected to. nullptr if not connected to a Ravel.
Definition: lock.cc:55
virtual float x() const
Definition: item.cc:107
ravel::RavelState lockedState
Definition: lock.h:37
Units units(bool) const override
compute the dimensional units
Definition: lock.cc:107
bool locked() const
Definition: lock.h:39
static SVGRenderer lockedIcon
Definition: lock.h:42
Creation and access to the minskyTCL_obj object, which has code to record whenever Minsky&#39;s state cha...
Definition: constMap.h:22
void draw(cairo_t *cairo) const override
draw this item into a cairo context
Definition: lock.cc:81
represents the units (in sense of dimensional analysis) of a variable.
Definition: units.h:34
Lock & operator=(const Lock &x)=default
Lock(const Lock &x)
Definition: lock.h:34
static SVGRenderer unlockedIcon
Definition: lock.h:43
void addPorts()
Definition: lock.cc:46
void applyLockedStateToRavel() const
Definition: lock.cc:142
void toggleLocked()
Definition: lock.cc:65