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"
A mixin that can tell when a nodelet is being unloaded.
Object implementing an ok() method that can interrupt pending sleeps when it returns false...
A non-templated interface of the mixin that can tell when a nodelet is being unloaded.
bool isNodeletUnloading(const ::nodelet::Nodelet &nodelet)
Tells whether the nodelet is currently being unloaded (with some pending callbacks still running)...
Definition: any.hpp:15
virtual void requestStop()=0
Call this function to request stopping this nodelet. ok() should return false after calling this...
ROSCONSOLE_DECL void shutdown()
virtual bool ok() const
Whether it is OK to continue sleeping. If false, a pending sleep() should stop as soon as possible...
Interface to an object whose sleep() calls can be interrupted externally. Multiple sleep() calls can ...


cras_cpp_common
Author(s): Martin Pecka
autogenerated on Sat Jun 17 2023 02:32:53