stateful_nodelet.hpp
Go to the documentation of this file.
1 #pragma once
2 
11 #include <nodelet/nodelet.h>
12 #include <ros/duration.h>
13 
15 
16 namespace cras
17 {
18 
25 bool isNodeletUnloading(const ::nodelet::Nodelet& nodelet);
26 
33 {
34 public:
41  virtual void requestStop() = 0;
42 };
43 
48 template <typename NodeletType = ::nodelet::Nodelet>
49 class StatefulNodelet : public virtual NodeletType, public ::cras::StatefulNodeletInterface
50 {
51 public:
52  virtual ~StatefulNodelet();
53  bool ok() const override;
54  void requestStop() override;
55 
56  [[deprecated("Use requestStop() instead.")]] void shutdown();
57 
58 protected:
59  using NodeletType::getName;
60 
61 private:
63  volatile bool shouldStop = false;
64 };
65 
66 }
67 
68 #include "impl/stateful_nodelet.hpp"
cras
Definition: any.hpp:15
interruptible_sleep_interface.h
Object implementing an ok() method that can interrupt pending sleeps when it returns false.
cras::StatefulNodelet::shouldStop
volatile bool shouldStop
Whether requestStop() has been called.
Definition: stateful_nodelet.hpp:63
duration.h
cras::StatefulNodelet::requestStop
void requestStop() override
Call this function to request stopping this nodelet. ok() should return false after calling this....
cras::InterruptibleSleepInterface
Interface to an object whose sleep() calls can be interrupted externally. Multiple sleep() calls can ...
Definition: interruptible_sleep_interface.h:26
cras::StatefulNodelet::~StatefulNodelet
virtual ~StatefulNodelet()
cras::StatefulNodeletInterface
A non-templated interface of the mixin that can tell when a nodelet is being unloaded.
Definition: stateful_nodelet.hpp:32
cras::StatefulNodelet::shutdown
void shutdown()
nodelet
nodelet.h
cras::isNodeletUnloading
bool isNodeletUnloading(const ::nodelet::Nodelet &nodelet)
Tells whether the nodelet is currently being unloaded (with some pending callbacks still running).
cras::StatefulNodelet
A mixin that can tell when a nodelet is being unloaded.
Definition: stateful_nodelet.hpp:49
cras::StatefulNodeletInterface::requestStop
virtual void requestStop()=0
Call this function to request stopping this nodelet. ok() should return false after calling this....
cras::StatefulNodelet::ok
bool ok() const override
Whether it is OK to continue sleeping. If false, a pending sleep() should stop as soon as possible.


cras_cpp_common
Author(s): Martin Pecka
autogenerated on Mon Jun 17 2024 02:48:57