Changeset 116 in pacpusframework for trunk/include/Pacpus/PacpusTools


Ignore:
Timestamp:
Jun 25, 2013, 1:44:25 PM (11 years ago)
Author:
Marek Kurdej
Message:

Added: PacpusException - base class for all exceptions. DbiteExceptions inherits from it.
Added: PacpusLibConfig.h - dllimport/dllexport clauses separated from pacpus.h.
Update: comments.

Location:
trunk/include/Pacpus/PacpusTools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/Pacpus/PacpusTools/AsyncWorkerBase.h

    r106 r116  
    2222namespace pacpus
    2323{
    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.
     32class PACPUSTOOLS_API AsyncWorkerBase
    3433    : public QObject
    3534    , private boost::noncopyable
    36   {
     35{
    3736    Q_OBJECT
    38     public:
    39       /** Constructor. */
    40       AsyncWorkerBase();
    4137
    42       /** Destructor. */
    43       virtual ~AsyncWorkerBase();
     38public:
     39    /// Constructor.
     40    AsyncWorkerBase();
    4441
    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();
    4744
    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();
    5847
    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);
    6157
    62     Q_SIGNALS:
    63        /// @todo Documentation
    64        void finished();
    65        /// @todo Documentation
    66        void stopped();
     58    /// @returns @b true if the worker is active, @b false otherwise.
     59    bool isActive() const
     60    {
     61        return active_;
     62    }
    6763
    68     protected:
    69        /// @todo Documentation
    70        virtual void setup();
    71        /// @todo Documentation
    72        virtual void process();
    73        /// @todo Documentation
    74        virtual void cleanup();
     64Q_SIGNALS:
     65    /// @todo Documentation
     66    void finished();
     67    /// @todo Documentation
     68    void stopped();
    7569
    76        /** Returns true if the worker is stopping. */
    77        bool isStopping() const { return stopping_; }
     70protected:
     71    /// @todo Documentation
     72    virtual void setup();
     73    /// @todo Documentation
     74    virtual void process();
     75    /// @todo Documentation
     76    virtual void cleanup();
    7877
    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_; }
    8480
    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();
     81private Q_SLOTS:
     82    /// @todo Documentation
     83    void doSetup();
     84    /// @todo Documentation
     85    void doFinish();
    9386
    94       // Attributes
    95       bool active_;
    96       bool stopping_;
    97   };
     87private:
     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
    98100} // namespace pacpus
    99101
  • trunk/include/Pacpus/PacpusTools/PeriodicWorker.h

    r115 r116  
    2323namespace pacpus
    2424{
    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/// ~~~
     42class PACPUSTOOLS_API PeriodicWorker
     43    : public AsyncWorkerBase
     44{
    4445    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 }
     46public:
     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
     66private:
     67    QTimer * mHeartbeat;
     68};
     69
     70} // namespace pacpus
    7171
    7272#endif // DEF_PACPUS_PERIODIC_WORKER_H
  • trunk/include/Pacpus/PacpusTools/geodesie.h

    r91 r116  
    8989    /// @param latitude [degrees]
    9090    /// @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;
    9292   
    9393private:
     
    127127void Lambert93_2_Geographique(const Raf98& raf98,double E,double N,double h,double& lambda,double& phi,double& he);
    128128void 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.
    134133void 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.
    140138void ECEF_2_ENU(double x,double y,double z,double& e,double& n,double& u,double lon0,double lat0,double he0);
    141139////////////////////////////////////////////////////////////////////////
     
    164162double ConvMerApp(double longitude);
    165163
    166 /**
    167 Converts Cartesian (x, y) coordinates to polar coordinates (r, theta)
    168 */
     164/// Converts Cartesian (x, y) coordinates to polar coordinates (r, theta)
    169165template <typename _T1, typename _T2>
    170166void cartesianToPolar(const _T1 x, const _T1 y, _T2 & r, _T2 & theta) {
     
    173169}
    174170
    175 /**
    176 Converts polar coordinates (r, theta) to Cartesian (x, y) coordinates
    177 */
     171/// Converts polar coordinates (r, theta) to Cartesian (x, y) coordinates
    178172template <typename _T1, typename _T2>
    179173void polarToCartesian(const _T1 r, const _T1 theta, _T2 & x, _T2 & y) {
     
    182176}
    183177
    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.
    188180template <typename _T1, typename _T2>
    189181void cartesianToSpherical(const _T1 x, const _T1 y, const _T1 z, _T2 & r, _T2 & theta, _T2 & phi) {
     
    193185}
    194186
    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.
    199189template <typename _T1, typename _T2>
    200190void 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.