Changeset 116 in pacpusframework for trunk/include/Pacpus/PacpusTools
- Timestamp:
- Jun 25, 2013, 1:44:25 PM (11 years ago)
- Location:
- trunk/include/Pacpus/PacpusTools
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/Pacpus/PacpusTools/AsyncWorkerBase.h
r106 r116 22 22 namespace pacpus 23 23 { 24 /** 25 * @brief A simple base class for asynchronous workers able to partake in the 26 * Qt slot / signal mechanism 27 * 28 * This class represents an asynchronous event-based worker able to receive and 29 * send Qt signals to other workers or threads. The rationale is to be able to 30 * define stateful objects that perform calculations asynchronously, triggered 31 * by external user-defined messages. 32 */ 33 class PACPUSTOOLS_API AsyncWorkerBase 24 25 /// A simple base class for asynchronous workers able to partake in the 26 /// Qt slot / signal mechanism 27 /// 28 /// This class represents an asynchronous event-based worker able to receive and 29 /// send Qt signals to other workers or threads. The rationale is to be able to 30 /// define stateful objects that perform calculations asynchronously, triggered 31 /// by external user-defined messages. 32 class PACPUSTOOLS_API AsyncWorkerBase 34 33 : public QObject 35 34 , private boost::noncopyable 36 35 { 37 36 Q_OBJECT 38 public:39 /** Constructor. */40 AsyncWorkerBase();41 37 42 /** Destructor. */ 43 virtual ~AsyncWorkerBase(); 38 public: 39 /// Constructor. 40 AsyncWorkerBase(); 44 41 45 /** Starts the worker by creating a new thread for it, and calling the setup() virtual method. */46 void start();42 /// Destructor. 43 virtual ~AsyncWorkerBase(); 47 44 48 /** Terminates the worker as soon as there are no more requests pending and its current processing 49 * is finished. 50 * 51 * This method tries to end the worker gracefully. All pending signals sent before the stop() request will 52 * be honored. 53 * It is safe to call this method from any thread. 54 * 55 * @param autoDelete if true, deletes the worker as soon as its event loop has finished processing. 56 */ 57 void stop(bool autoDelete); 45 /// Starts the worker by creating a new thread for it, and calling the setup() virtual method. */ 46 void start(); 58 47 59 /** Returns true if the worker is active. */ 60 bool isActive() const { return active_; } 48 /// Terminates the worker as soon as there are no more requests pending and its current processing 49 /// is finished. 50 /// 51 /// This method tries to end the worker gracefully. All pending signals sent before the stop() request will 52 /// be honored. 53 /// It is safe to call this method from any thread. 54 /// 55 /// @param autoDelete if true, deletes the worker as soon as its event loop has finished processing. 56 void stop(bool autoDelete); 61 57 62 Q_SIGNALS:63 /// @todo Documentation64 void finished();65 /// @todo Documentation66 void stopped();58 /// @returns @b true if the worker is active, @b false otherwise. 59 bool isActive() const 60 { 61 return active_; 62 } 67 63 68 protected: 69 /// @todo Documentation 70 virtual void setup(); 71 /// @todo Documentation 72 virtual void process(); 73 /// @todo Documentation 74 virtual void cleanup(); 64 Q_SIGNALS: 65 /// @todo Documentation 66 void finished(); 67 /// @todo Documentation 68 void stopped(); 75 69 76 /** Returns true if the worker is stopping. */ 77 bool isStopping() const { return stopping_; } 70 protected: 71 /// @todo Documentation 72 virtual void setup(); 73 /// @todo Documentation 74 virtual void process(); 75 /// @todo Documentation 76 virtual void cleanup(); 78 77 79 private Q_SLOTS: 80 /// @todo Documentation 81 void doSetup(); 82 /// @todo Documentation 83 void doFinish(); 78 /// Returns true if the worker is stopping. 79 bool isStopping() const { return stopping_; } 84 80 85 private: 86 /*! \brief Ends the worker, asking the underlying thread to terminate 87 * 88 * This method signals the end of processing and requests the underlying thread to terminate. Actual termination 89 * will occur as soon as all pending signals (including those that may come from other workers during the 90 * finish request handling) have been processed. 91 */ 92 void finish(); 81 private Q_SLOTS: 82 /// @todo Documentation 83 void doSetup(); 84 /// @todo Documentation 85 void doFinish(); 93 86 94 // Attributes 95 bool active_; 96 bool stopping_; 97 }; 87 private: 88 /// Ends the worker, asking the underlying thread to terminate 89 /// 90 /// This method signals the end of processing and requests the underlying thread to terminate. Actual termination 91 /// will occur as soon as all pending signals (including those that may come from other workers during the 92 /// finish request handling) have been processed. 93 void finish(); 94 95 // Attributes 96 bool active_; 97 bool stopping_; 98 }; 99 98 100 } // namespace pacpus 99 101 -
trunk/include/Pacpus/PacpusTools/PeriodicWorker.h
r115 r116 23 23 namespace pacpus 24 24 { 25 /// @brief A simple base class for periodic worker. 26 /// 27 /// @example 28 /// To use the PeriodicWorker, simply inherit from this class when creating your worker. 29 /// ~~~ 30 /// class MyWorker 31 /// : public PeriodicWorkder 32 /// { 33 /// public: 34 /// void doWork() { std::cout << "Hey, I'm working!" << std::endl; } 35 /// }; 36 /// 37 /// // Do its work every second. 38 /// MyWorker worker; 39 /// worker.startWork(1000); 40 /// ~~~ 41 class PACPUSTOOLS_API PeriodicWorker 42 : public AsyncWorkerBase 43 { 25 26 /// @brief A simple base class for periodic worker. 27 /// 28 /// @example 29 /// To use the PeriodicWorker, simply inherit from this class when creating your worker. 30 /// ~~~ 31 /// class MyWorker 32 /// : public PeriodicWorkder 33 /// { 34 /// public: 35 /// void doWork() { std::cout << "Hey, I'm working!" << std::endl; } 36 /// }; 37 /// 38 /// // Do its work every second. 39 /// MyWorker worker; 40 /// worker.startWork(1000); 41 /// ~~~ 42 class PACPUSTOOLS_API PeriodicWorker 43 : public AsyncWorkerBase 44 { 44 45 Q_OBJECT 45 public: 46 /// Ctor of PeriodicWorker. 47 PeriodicWorker(); 48 49 /// Dtor of PeriodicWorker. 50 virtual ~PeriodicWorker(); 51 52 /** Start the periodic worker. 53 * @param msec Period in mseconds. 54 */ 55 void startWork(int msec); 56 57 /** Stop the periodic worker, but do not delete it. */ 58 void stopWork(); 59 60 public slots: 61 /** Do the work. 62 * This method need to be implemented in the subclasses, it will be called 63 * each time the timer has reached its period. 64 */ 65 virtual void doWork() = 0; 66 67 private: 68 QTimer* mHeartbeat; 69 }; 70 } 46 public: 47 /// Ctor of PeriodicWorker. 48 PeriodicWorker(); 49 50 /// Dtor of PeriodicWorker. 51 virtual ~PeriodicWorker(); 52 53 /// Start the periodic worker. 54 /// @param msec Period in mseconds. 55 void startWork(int msec); 56 57 /// Stop the periodic worker, but do not delete it. 58 void stopWork(); 59 60 public Q_SLOTS: 61 /// Do the work. 62 /// This method need to be implemented in the subclasses, it will be called 63 /// each time the timer has reached its period. 64 virtual void doWork() = 0; 65 66 private: 67 QTimer * mHeartbeat; 68 }; 69 70 } // namespace pacpus 71 71 72 72 #endif // DEF_PACPUS_PERIODIC_WORKER_H -
trunk/include/Pacpus/PacpusTools/geodesie.h
r91 r116 89 89 /// @param latitude [degrees] 90 90 /// @param Hwgs84 Output: interpolated altitude using WGS84 geoid model [meters] 91 bool Interpol(double longitude /*deg*/, double latitude/*deg*/, double* Hwgs84) const;91 bool Interpol(double longitudeDegrees, double latitudeDegrees, double * heightMetersWgs84) const; 92 92 93 93 private: … … 127 127 void Lambert93_2_Geographique(const Raf98& raf98,double E,double N,double h,double& lambda,double& phi,double& he); 128 128 void Lambert93_2_Geographique(const Raf98& raf98,double E,double N,double h,Matrice in,double& lambda,double& phi,double& he,Matrice& out); 129 /** Convert from geographique to ECEF. 130 * @param[in] longitude Longitude in radian. 131 * @param[in] latitude Latitude in radian. 132 * @param[in] he Height in meter. 133 */ 129 /// Convert from geographique to ECEF. 130 /// @param[in] longitude Longitude in radian. 131 /// @param[in] latitude Latitude in radian. 132 /// @param[in] he Height in meter. 134 133 void Geographique_2_ECEF(double longitude, double latitude, double he, double& x, double& y, double& z); 135 /** Convert from ECEF two ENU. 136 * @param[in] lon0 Longitude of the origin in radian. 137 * @param[in] lat0 Latitude of the origin in radian. 138 * @param[in] he0 Height of the origin in radian. 139 */ 134 /// Convert from ECEF two ENU. 135 /// @param[in] lon0 Longitude of the origin in radian. 136 /// @param[in] lat0 Latitude of the origin in radian. 137 /// @param[in] he0 Height of the origin in radian. 140 138 void ECEF_2_ENU(double x,double y,double z,double& e,double& n,double& u,double lon0,double lat0,double he0); 141 139 //////////////////////////////////////////////////////////////////////// … … 164 162 double ConvMerApp(double longitude); 165 163 166 /** 167 Converts Cartesian (x, y) coordinates to polar coordinates (r, theta) 168 */ 164 /// Converts Cartesian (x, y) coordinates to polar coordinates (r, theta) 169 165 template <typename _T1, typename _T2> 170 166 void cartesianToPolar(const _T1 x, const _T1 y, _T2 & r, _T2 & theta) { … … 173 169 } 174 170 175 /** 176 Converts polar coordinates (r, theta) to Cartesian (x, y) coordinates 177 */ 171 /// Converts polar coordinates (r, theta) to Cartesian (x, y) coordinates 178 172 template <typename _T1, typename _T2> 179 173 void polarToCartesian(const _T1 r, const _T1 theta, _T2 & x, _T2 & y) { … … 182 176 } 183 177 184 /** 185 Converts Cartesian (x, y, z) coordinates to spherical coordinates (r, theta, phi) 186 Angles expressed in radians. 187 */ 178 /// Converts Cartesian (x, y, z) coordinates to spherical coordinates (r, theta, phi) 179 /// Angles expressed in radians. 188 180 template <typename _T1, typename _T2> 189 181 void cartesianToSpherical(const _T1 x, const _T1 y, const _T1 z, _T2 & r, _T2 & theta, _T2 & phi) { … … 193 185 } 194 186 195 /** 196 Converts spherical coordinates (r, theta, phi) to Cartesian (x, y, z) coordinates. 197 Angles expressed in radians. 198 */ 187 /// Converts spherical coordinates (r, theta, phi) to Cartesian (x, y, z) coordinates. 188 /// Angles expressed in radians. 199 189 template <typename _T1, typename _T2> 200 190 void sphericalToCartesian(const _T1 r, const _T1 theta, const _T1 phi, _T2 & x, _T2 & y, _T2 & z) {
Note:
See TracChangeset
for help on using the changeset viewer.