File tree Expand file tree Collapse file tree 4 files changed +29
-0
lines changed Expand file tree Collapse file tree 4 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ namespace libscratchcpp
1010{
1111
1212class Target ;
13+ class Monitor ;
1314class VariablePrivate ;
1415
1516/* ! \brief The Variable class represents a Scratch variable. */
@@ -33,6 +34,9 @@ class LIBSCRATCHCPP_EXPORT Variable : public Entity
3334 Target *target () const ;
3435 void setTarget (Target *target);
3536
37+ Monitor *monitor () const ;
38+ void setMonitor (Monitor *monitor);
39+
3640 std::shared_ptr<Variable> clone ();
3741
3842 private:
Original file line number Diff line number Diff line change @@ -61,6 +61,18 @@ void Variable::setTarget(Target *target)
6161 impl->target = target;
6262}
6363
64+ /* ! Returns the monitor of this variable. */
65+ Monitor *Variable::monitor () const
66+ {
67+ return impl->monitor ;
68+ }
69+
70+ /* ! Sets the monitor of this variable. */
71+ void Variable::setMonitor (Monitor *monitor)
72+ {
73+ impl->monitor = monitor;
74+ }
75+
6476/* ! Creates a copy of the variable. */
6577std::shared_ptr<Variable> Variable::clone ()
6678{
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ namespace libscratchcpp
88{
99
1010class Target ;
11+ class Monitor ;
1112
1213struct VariablePrivate
1314{
@@ -18,6 +19,7 @@ struct VariablePrivate
1819 Value value;
1920 bool isCloudVariable;
2021 Target *target = nullptr ;
22+ Monitor *monitor = nullptr ;
2123};
2224
2325} // namespace libscratchcpp
Original file line number Diff line number Diff line change 11#include < scratchcpp/variable.h>
22#include < scratchcpp/target.h>
3+ #include < scratchcpp/monitor.h>
34
45#include " ../common.h"
56
@@ -68,6 +69,16 @@ TEST(VariableTest, Target)
6869 ASSERT_EQ (var.target (), &target);
6970}
7071
72+ TEST (VariableTest, Monitor)
73+ {
74+ Variable var (" " , " " );
75+ ASSERT_EQ (var.monitor (), nullptr );
76+
77+ Monitor monitor (" " , " " );
78+ var.setMonitor (&monitor);
79+ ASSERT_EQ (var.monitor (), &monitor);
80+ }
81+
7182TEST (VariableTest, Clone)
7283{
7384 std::shared_ptr<Variable> clone;
You can’t perform that action at this time.
0 commit comments