Program Listing for File ceres-signal-handler.h

Return to documentation for file (algorithms/ceres-error-terms/include/ceres-error-terms/ceres-signal-handler.h)

#ifndef CERES_ERROR_TERMS_CERES_SIGNAL_HANDLER_H_
#define CERES_ERROR_TERMS_CERES_SIGNAL_HANDLER_H_

#include <signal.h>

#include <ceres/iteration_callback.h>
#include <ceres/types.h>
#include <glog/logging.h>

namespace ceres {
struct IterationSummary;
}

namespace ceres_error_terms {
class SignalHandlerCallback : public ceres::IterationCallback {
 public:
  SignalHandlerCallback();
  virtual ~SignalHandlerCallback();

  static void signalHandler(int signal);
  virtual ceres::CallbackReturnType operator()(const ceres::IterationSummary&);

 private:
  bool terminate_after_next_iteration_;
  struct sigaction previous_signal_handler_;
};

}  // namespace ceres_error_terms

#endif  // CERES_ERROR_TERMS_CERES_SIGNAL_HANDLER_H_