abstract_execution_base.h
Go to the documentation of this file.
00001 /*
00002  *  Copyright 2018, Sebastian Pütz
00003  *
00004  *  Redistribution and use in source and binary forms, with or without
00005  *  modification, are permitted provided that the following conditions
00006  *  are met:
00007  *
00008  *  1. Redistributions of source code must retain the above copyright
00009  *     notice, this list of conditions and the following disclaimer.
00010  *
00011  *  2. Redistributions in binary form must reproduce the above
00012  *     copyright notice, this list of conditions and the following
00013  *     disclaimer in the documentation and/or other materials provided
00014  *     with the distribution.
00015  *
00016  *  3. Neither the name of the copyright holder nor the names of its
00017  *     contributors may be used to endorse or promote products derived
00018  *     from this software without specific prior written permission.
00019  *
00020  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00021  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00022  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00023  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00024  *  COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00025  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00026  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00027  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00028  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00029  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00030  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00031  *  POSSIBILITY OF SUCH DAMAGE.
00032  *
00033  *  abstract_execution_base.h
00034  *
00035  *  author: Sebastian Pütz <spuetz@uni-osnabrueck.de>
00036  *
00037  */
00038 
00039 #ifndef MBF_ABSTRACT_NAV__ABSTRACT_EXECUTION_BASE_H_
00040 #define MBF_ABSTRACT_NAV__ABSTRACT_EXECUTION_BASE_H_
00041 
00042 #include <mbf_abstract_nav/MoveBaseFlexConfig.h>
00043 #include <boost/thread.hpp>
00044 #include <boost/chrono/duration.hpp>
00045 #include <boost/chrono/thread_clock.hpp>
00046 
00047 namespace mbf_abstract_nav
00048 {
00049 
00050 class AbstractExecutionBase
00051 {
00052  public:
00053 
00054   AbstractExecutionBase(std::string name,
00055                         boost::function<void()> setup_fn,
00056                         boost::function<void()> cleanup_fn);
00057 
00058   virtual bool start();
00059 
00060   virtual void stop();
00061 
00066   virtual bool cancel() = 0;
00067 
00068   void join();
00069 
00070   void waitForStateUpdate(boost::chrono::microseconds const &duration);
00071 
00075   boost::function<void()> setup_fn_;
00076 
00080   boost::function<void()> cleanup_fn_;
00081 
00085   uint32_t getOutcome();
00086 
00090   std::string getMessage();
00091 
00095   std::string getName();
00096 
00097  protected:
00098 
00099   virtual void run() = 0;
00100 
00102   boost::condition_variable condition_;
00103 
00105   boost::thread thread_;
00106 
00108   bool cancel_;
00109 
00111   uint32_t outcome_;
00112 
00114   std::string message_;
00115 
00117   std::string name_;
00118 };
00119 } /* namespace mbf_abstract_nav */
00120 
00121 #endif  /* MBF_ABSTRACT_NAV__ABSTRACT_EXECUTION_BASE_H_ */


mbf_abstract_nav
Author(s): Sebastian Pütz
autogenerated on Mon Jun 17 2019 20:11:35