Skip to content

Commit

Permalink
Merge pull request #3615 from kunaltyagi/grabber-toggle
Browse files Browse the repository at this point in the history
Add a toggle option to grabber
  • Loading branch information
taketwo authored Feb 4, 2020
2 parents c3d9a90 + 71e81c5 commit 58e1b1e
Showing 1 changed file with 22 additions and 6 deletions.
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

0 comments on commit 58e1b1e

Please sign in to comment.