FileDescriptorActivity.hpp
Go to the documentation of this file.
00001 /***************************************************************************
00002   tag: Peter Soetens  Thu Oct 22 11:59:08 CEST 2009  FileDescriptorActivity.hpp
00003 
00004                         FileDescriptorActivity.hpp -  description
00005                            -------------------
00006     begin                : Thu October 22 2009
00007     copyright            : (C) 2009 Peter Soetens
00008     email                : peter@thesourcworks.com
00009 
00010  ***************************************************************************
00011  *   This library is free software; you can redistribute it and/or         *
00012  *   modify it under the terms of the GNU General Public                   *
00013  *   License as published by the Free Software Foundation;                 *
00014  *   version 2 of the License.                                             *
00015  *                                                                         *
00016  *   As a special exception, you may use this file as part of a free       *
00017  *   software library without restriction.  Specifically, if other files   *
00018  *   instantiate templates or use macros or inline functions from this     *
00019  *   file, or you compile this file and link it with other files to        *
00020  *   produce an executable, this file does not by itself cause the         *
00021  *   resulting executable to be covered by the GNU General Public          *
00022  *   License.  This exception does not however invalidate any other        *
00023  *   reasons why the executable file might be covered by the GNU General   *
00024  *   Public License.                                                       *
00025  *                                                                         *
00026  *   This library is distributed in the hope that it will be useful,       *
00027  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00028  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
00029  *   Lesser General Public License for more details.                       *
00030  *                                                                         *
00031  *   You should have received a copy of the GNU General Public             *
00032  *   License along with this library; if not, write to the Free Software   *
00033  *   Foundation, Inc., 59 Temple Place,                                    *
00034  *   Suite 330, Boston, MA  02111-1307  USA                                *
00035  *                                                                         *
00036  ***************************************************************************/
00037 
00038 
00039 #ifndef FILEDESCRIPTOR_ACTIVITY_HPP
00040 #define FILEDESCRIPTOR_ACTIVITY_HPP
00041 
00042 #include "../Activity.hpp"
00043 #include <set>
00044 
00045 namespace RTT { namespace extras {
00046 
00103     class RTT_API FileDescriptorActivity : public Activity
00104     {
00105         std::set<int> m_watched_fds;
00106         bool m_running;
00107         int  m_interrupt_pipe[2];
00108         int  m_timeout_us;              
00109         Seconds m_period;               
00110 
00111         mutable RTT::os::Mutex m_lock;
00112         fd_set m_fd_set;
00113         fd_set m_fd_work;
00114         bool m_has_error;
00115         bool m_has_timeout;
00116 
00117         static const char CMD_ANY_COMMAND = 0;
00118         RTT::os::Mutex m_command_mutex;
00119         bool m_break_loop;
00120         bool m_trigger;
00121         bool m_update_sets;
00122 
00126         void triggerUpdateSets();
00127 
00128     public:
00138         FileDescriptorActivity(int priority, base::RunnableInterface* _r = 0, const std::string& name ="FileDescriptorActivity" );
00139 
00150         FileDescriptorActivity(int scheduler, int priority, base::RunnableInterface* _r = 0, const std::string& name ="FileDescriptorActivity" );
00151 
00163         FileDescriptorActivity(int scheduler, int priority, Seconds period, base::RunnableInterface* _r = 0, const std::string& name ="FileDescriptorActivity" );
00164 
00177         FileDescriptorActivity(int scheduler, int priority, Seconds period, unsigned cpu_affinity,
00178                                                            base::RunnableInterface* _r = 0, const std::string& name ="FileDescriptorActivity" );
00179 
00180         virtual ~FileDescriptorActivity();
00181 
00182         bool isRunning() const;
00183 
00185         virtual Seconds getPeriod() const;
00186 
00188         virtual bool setPeriod(Seconds period);
00189 
00200         void watch(int fd);
00201 
00206         void unwatch(int fd);
00207 
00209         void clearAllWatches();
00210 
00213         bool isWatched(int fd) const;
00214 
00221         bool isUpdated(int fd) const;
00222 
00230         bool hasTimeout() const;
00231 
00239         bool hasError() const;
00240 
00246         void setTimeout(int timeout);
00247 
00253         void setTimeout_us(int timeout_us);
00254 
00258         int getTimeout() const;
00259 
00263         int getTimeout_us() const;
00264 
00265         virtual bool start();
00266         virtual void loop();
00267         virtual bool breakLoop();
00268         virtual bool stop();
00269     
00273         virtual void step();
00274 
00278         virtual bool trigger();
00279     };
00280 }}
00281 
00282 #endif


rtt
Author(s): RTT Developers
autogenerated on Sat Jun 8 2019 18:46:11