Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Grabber::toggle() method #3615

Merged
merged 2 commits into from
Feb 4, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions io/include/pcl/io/grabber.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,8 @@ namespace pcl
class PCL_EXPORTS Grabber
{
public:

/** \brief Constructor. */
Grabber () {}

/** \brief virtual destructor. */
virtual inline ~Grabber () throw ();
virtual inline ~Grabber () noexcept;

/** \brief registers a callback function/method to a signal with the corresponding signature
* \param[in] callback: the callback function/method
Expand Down Expand Up @@ -101,6 +97,13 @@ namespace pcl
virtual void
stop () = 0;

/** \brief For devices that are streaming, stopped streams are started and running stream are stopped.
* For triggered devices, the behavior is not defined.
* \return true if grabber is running / streaming. False otherwise.
*/
inline bool
toggle ();

/** \brief returns the name of the concrete subclass.
* \return the name of the concrete driver.
*/
Expand Down Expand Up @@ -151,12 +154,25 @@ namespace pcl
std::map<std::string, std::vector<boost::signals2::shared_connection_block> > shared_connections_;
} ;

Grabber::~Grabber () throw ()
Grabber::~Grabber () noexcept
{
for (auto &signal : signals_)
delete signal.second;
}

bool
Grabber::toggle ()
{
if (isRunning ())
{
stop ();
} else
{
start ();
}
return isRunning ();
}

template<typename T> boost::signals2::signal<T>*
Grabber::find_signal () const
{
Expand Down