Skip to content

Commit 22502ac

Browse files
committed
Add name setter to Monitor
1 parent 59b91a6 commit 22502ac

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

include/scratchcpp/monitor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class LIBSCRATCHCPP_EXPORT Monitor : public Entity
3838
void setInterface(IMonitorHandler *iface);
3939

4040
const std::string &name() const;
41+
void setName(const std::string &name);
4142

4243
Mode mode() const;
4344
void setMode(Mode mode);

src/scratch/monitor.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ const std::string &Monitor::name() const
4141
return impl->name;
4242
}
4343

44+
/*! Sets the name of this monitor. */
45+
void Monitor::setName(const std::string &name)
46+
{
47+
impl->name = name;
48+
}
49+
4450
/*! Returns the monitor's mode. */
4551
Monitor::Mode Monitor::mode() const
4652
{

test/scratch_classes/monitor_test.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,15 @@ TEST(MonitorTest, Interface)
4747
monitor.setInterface(&iface);
4848
}
4949

50+
TEST(MonitorTest, Name)
51+
{
52+
Monitor monitor("", "");
53+
ASSERT_TRUE(monitor.name().empty());
54+
55+
monitor.setName("test");
56+
ASSERT_EQ(monitor.name(), "test");
57+
}
58+
5059
TEST(MonitorTest, Mode)
5160
{
5261
Monitor monitor("", "");

0 commit comments

Comments
 (0)