Skip to content

Commit 57dbc32

Browse files
committed
change: derived from shared_base
1 parent c196599 commit 57dbc32

2 files changed

Lines changed: 9 additions & 8 deletions

File tree

src/posix_timer.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ timer_base::timer_base(std::shared_ptr<posix_timer> parent, const YAML::Node& co
6666
//! Initialize timer
6767
void timer_base::init(void) {
6868
// add trigger device
69-
robotkernel::add_device(shared_from_this());
69+
robotkernel::add_device(shared_from_this_as<trigger>());
7070

7171
string pdin_desc = "- double: interval\n";
7272
pdin = make_shared<robotkernel::triple_buffer>(
@@ -88,7 +88,7 @@ void timer_base::deinit(void) {
8888
pdin_inspect = nullptr;
8989

9090
// register devices (trigger, process_data)
91-
robotkernel::remove_device(shared_from_this());
91+
robotkernel::remove_device(shared_from_this_as<trigger>());
9292
robotkernel::remove_device(pdin);
9393

9494
pdin->reset_provider(prov);
@@ -282,15 +282,15 @@ void posix_timer::init() {
282282
std::function<void(const YAML::Node& timer_config)> create_timer = [&](const YAML::Node& timer_config) {
283283
if (timer_config["mode"]) {
284284
if (timer_config["mode"].as<string>() == string("nanosleep")) {
285-
timers.push_back(std::make_shared<nanosleep>(shared_from_this(), timer_config));
285+
timers.push_back(std::make_shared<nanosleep>(shared_from_this_as<posix_timer>(), timer_config));
286286
} else if (timer_config["mode"].as<string>() == string("timer")) {
287-
timers.push_back(std::make_shared<timer>(shared_from_this(), timer_config));
287+
timers.push_back(std::make_shared<timer>(shared_from_this_as<posix_timer>(), timer_config));
288288
} else if (timer_config["mode"].as<string>() == string("busywait")) {
289-
timers.push_back(std::make_shared<busywait>(shared_from_this(), timer_config));
289+
timers.push_back(std::make_shared<busywait>(shared_from_this_as<posix_timer>(), timer_config));
290290
}
291291
} else {
292292
log(info, "mode not specified, assuming nanosleep mode!\n");
293-
timers.push_back(std::make_shared<nanosleep>(shared_from_this(), timer_config));
293+
timers.push_back(std::make_shared<nanosleep>(shared_from_this_as<posix_timer>(), timer_config));
294294
}
295295
};
296296

src/posix_timer.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "robotkernel/module_base.h"
2929
#include "robotkernel/robotkernel.h"
3030
#include "robotkernel/trigger_base.h"
31+
#include "robotkernel/helpers.h"
3132

3233
#include "service_provider_process_data_inspection/base.h"
3334

@@ -37,7 +38,7 @@ namespace module_posix_timer {
3738
class posix_timer;
3839

3940
class timer_base :
40-
public std::enable_shared_from_this<timer_base>,
41+
public virtual robotkernel::shared_base,
4142
public robotkernel::runnable,
4243
public robotkernel::trigger
4344
{
@@ -111,7 +112,7 @@ class timer : public timer_base {
111112

112113
// forward declaration
113114
class posix_timer :
114-
public std::enable_shared_from_this<posix_timer>,
115+
public virtual robotkernel::shared_base,
115116
public robotkernel::module_base
116117
{
117118
private:

0 commit comments

Comments
 (0)