Skip to content

Commit 0973ad4

Browse files
committed
Implemented iService interface in DeviceBundler
1 parent 3800236 commit 0973ad4

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

src/devices/deviceBundler/DeviceBundler.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ bool DeviceBundler::open(yarp::os::Searchable& config)
7676
return false;
7777
}
7878

79+
ret = m_pdev_wrapper.view(m_iService);
80+
if (ret)
81+
{
82+
yCInfo(DEVICEBUNDLER, "The device implements the IService iterface");
83+
}
84+
7985
ret = m_iWrapper->attach(&m_pdev_subdevice);
8086
if (!ret)
8187
{
@@ -93,6 +99,7 @@ bool DeviceBundler::close()
9399
{
94100
m_iWrapper->detach();
95101
m_iWrapper = nullptr;
102+
m_iService = nullptr;
96103
}
97104

98105
if (m_pdev_wrapper.isValid())
@@ -107,3 +114,30 @@ bool DeviceBundler::close()
107114

108115
return true;
109116
}
117+
118+
bool DeviceBundler::startService()
119+
{
120+
if (m_iService)
121+
{
122+
return m_iService->startService();
123+
}
124+
return true; //If not implemented, emulate running in background
125+
}
126+
127+
bool DeviceBundler::updateService()
128+
{
129+
if (m_iService)
130+
{
131+
return m_iService->updateService();
132+
}
133+
return false;
134+
}
135+
136+
bool DeviceBundler::stopService()
137+
{
138+
if (m_iService)
139+
{
140+
return m_iService->stopService();
141+
}
142+
return false;
143+
}

src/devices/deviceBundler/DeviceBundler.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <yarp/dev/DeviceDriver.h>
1010
#include <yarp/dev/PolyDriver.h>
1111
#include <yarp/dev/IWrapper.h>
12+
#include <yarp/dev/ServiceInterfaces.h>
1213
#include "DeviceBundler_ParamsParser.h"
1314

1415
/**
@@ -25,6 +26,7 @@
2526
*/
2627

2728
class DeviceBundler : public yarp::dev::DeviceDriver,
29+
public yarp::dev::IService,
2830
public DeviceBundler_ParamsParser
2931
{
3032
public:
@@ -39,10 +41,16 @@ class DeviceBundler : public yarp::dev::DeviceDriver,
3941
bool open(yarp::os::Searchable& config) override;
4042
bool close() override;
4143

44+
// yarp::dev::IService methods
45+
virtual bool startService() override;
46+
virtual bool updateService() override;
47+
virtual bool stopService() override;
48+
4249
private:
4350
yarp::dev::PolyDriver m_pdev_wrapper;
4451
yarp::dev::PolyDriver m_pdev_subdevice;
4552
yarp::dev::IWrapper* m_iWrapper=nullptr;
53+
yarp::dev::IService* m_iService=nullptr;
4654
};
4755

4856
#endif // YARP_DEVICEBUNDLER_H

0 commit comments

Comments
 (0)