Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
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
00101 class RTT_API FileDescriptorActivity : public Activity
00102 {
00103 std::set<int> m_watched_fds;
00104 bool m_running;
00105 int m_interrupt_pipe[2];
00106 int m_timeout;
00108 mutable RTT::os::Mutex m_lock;
00109 fd_set m_fd_set;
00110 fd_set m_fd_work;
00111 bool m_has_error;
00112 bool m_has_timeout;
00113
00114 static const char CMD_BREAK_LOOP = 0;
00115 static const char CMD_TRIGGER = 1;
00116 static const char CMD_UPDATE_SETS = 2;
00117
00121 void triggerUpdateSets();
00122
00123 public:
00133 FileDescriptorActivity(int priority, base::RunnableInterface* _r = 0, const std::string& name ="FileDescriptorActivity" );
00134
00145 FileDescriptorActivity(int scheduler, int priority, base::RunnableInterface* _r = 0, const std::string& name ="FileDescriptorActivity" );
00146
00147 virtual ~FileDescriptorActivity();
00148
00149 bool isRunning() const;
00150
00161 void watch(int fd);
00162
00167 void unwatch(int fd);
00168
00170 void clearAllWatches();
00171
00174 bool isWatched(int fd) const;
00175
00182 bool isUpdated(int fd) const;
00183
00191 bool hasTimeout() const;
00192
00200 bool hasError() const;
00201
00205 void setTimeout(int timeout);
00206
00210 int getTimeout() const;
00211
00212 virtual bool start();
00213 virtual void loop();
00214 virtual bool breakLoop();
00215 virtual bool stop();
00216
00220 virtual void step();
00221
00225 virtual bool trigger();
00226 };
00227 }}
00228
00229 #endif