Public Member Functions | Private Attributes | List of all members
cras::StatefulNodelet< NodeletType > Class Template Reference

A mixin that can tell when a nodelet is being unloaded. More...

#include <stateful_nodelet.hpp>

Inheritance diagram for cras::StatefulNodelet< NodeletType >:
Inheritance graph
[legend]

Public Member Functions

bool ok () const override
 Whether it is OK to continue sleeping. If false, a pending sleep() should stop as soon as possible. More...
 
void requestStop () override
 Call this function to request stopping this nodelet. ok() should return false after calling this. It terminates all ongoing sleeps called by this->sleep(). More...
 
void shutdown ()
 
virtual ~StatefulNodelet ()
 
- Public Member Functions inherited from nodelet::Nodelet
void init (const std::string &name, const M_string &remapping_args, const V_string &my_argv, ros::CallbackQueueInterface *st_queue=NULL, ros::CallbackQueueInterface *mt_queue=NULL)
 
 Nodelet ()
 
virtual ~Nodelet ()
 
- Public Member Functions inherited from cras::InterruptibleSleepInterface
 InterruptibleSleepInterface ()
 
virtual bool sleep (const ::ros::Duration &duration) const
 Sleep for the given duration or until ok() returns false. More...
 
virtual ~InterruptibleSleepInterface ()
 Destroy the object waiting for a pending sleep() call to finish. More...
 

Private Attributes

volatile bool shouldStop = false
 Whether requestStop() has been called. More...
 

Additional Inherited Members

- Protected Member Functions inherited from nodelet::Nodelet
ros::CallbackQueueInterfacegetMTCallbackQueue () const
 
ros::NodeHandlegetMTNodeHandle () const
 
ros::NodeHandlegetMTPrivateNodeHandle () const
 
const V_stringgetMyArgv () const
 
const std::string & getName () const
 
ros::NodeHandlegetNodeHandle () const
 
ros::NodeHandlegetPrivateNodeHandle () const
 
const M_stringgetRemappingArgs () const
 
ros::CallbackQueueInterfacegetSTCallbackQueue () const
 
std::string getSuffixedName (const std::string &suffix) const
 
- Protected Attributes inherited from cras::InterruptibleSleepInterface
::ros::WallDuration pollDuration {0, 1000000}
 How long to wait between querying the ok() status and other conditions. More...
 

Detailed Description

template<typename NodeletType = ::nodelet::Nodelet>
class cras::StatefulNodelet< NodeletType >

A mixin that can tell when a nodelet is being unloaded.

Template Parameters
NodeletTypeType of the base nodelet.

Definition at line 49 of file stateful_nodelet.hpp.

Constructor & Destructor Documentation

◆ ~StatefulNodelet()

template<typename NodeletType = ::nodelet::Nodelet>
virtual cras::StatefulNodelet< NodeletType >::~StatefulNodelet ( )
virtual

Member Function Documentation

◆ ok()

template<typename NodeletType = ::nodelet::Nodelet>
bool cras::StatefulNodelet< NodeletType >::ok ( ) const
overridevirtual

Whether it is OK to continue sleeping. If false, a pending sleep() should stop as soon as possible.

Returns
Whether it is OK to continue.
Note
Always override this function as its default implementation returns false (used in case this function is called after the descendant parts of the objects have already been destructed).

Reimplemented from cras::InterruptibleSleepInterface.

◆ requestStop()

template<typename NodeletType = ::nodelet::Nodelet>
void cras::StatefulNodelet< NodeletType >::requestStop ( )
overridevirtual

Call this function to request stopping this nodelet. ok() should return false after calling this. It terminates all ongoing sleeps called by this->sleep().

Note
This method is automatically called from the destructor (but rather call it as soon as you know the nodelet should be stopped).

Implements cras::StatefulNodeletInterface.

◆ shutdown()

template<typename NodeletType = ::nodelet::Nodelet>
void cras::StatefulNodelet< NodeletType >::shutdown ( )

Member Data Documentation

◆ shouldStop

template<typename NodeletType = ::nodelet::Nodelet>
volatile bool cras::StatefulNodelet< NodeletType >::shouldStop = false
private

Whether requestStop() has been called.

Definition at line 63 of file stateful_nodelet.hpp.


The documentation for this class was generated from the following file:


cras_cpp_common
Author(s): Martin Pecka
autogenerated on Sat Mar 2 2024 03:47:35