Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

AbstractGenPointChain.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------+
00002  | Library QgarLib, graphics analysis and recognition                  |
00003  | Copyright (C) 2002  Qgar Project, LORIA                             |
00004  |                                                                     |
00005  | This library is free software; you can redistribute it and/or       |
00006  | modify it under the terms of the GNU Lesser General Public          |
00007  | License version 2.1, as published by the Free Software Foundation.  |
00008  |                                                                     |
00009  | This library is distributed in the hope that it will be useful,     |
00010  | but WITHOUT ANY WARRANTY; without even the implied warranty of      |
00011  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                |
00012  | See the GNU Lesser General Public License for more details.         |
00013  |                                                                     |
00014  | The GNU Lesser General Public License is included in the file       |
00015  | LICENSE.LGPL, in the root directory of the Qgar packaging. See      |
00016  | http://www.gnu.org/licenses/lgpl.html for the terms of the licence. |
00017  | To receive a paper copy, write to the Free Software Foundation,     |
00018  | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.       |
00019  |                                                                     |
00020  | Contact Project Qgar for any information:                           |
00021  |   LORIA - équipe Qgar                                               |
00022  |   B.P. 239, 54506 Vandoeuvre-lès-Nancy Cedex, France                |
00023  |   email: qgar-contact@loria.fr                                      |
00024  |   http://www.qgar.org/                                              |
00025  *---------------------------------------------------------------------*/
00026 
00027 
00028 #ifndef __ABSTRACTGENPOINTCHAIN_H_INCLUDED__
00029 #define __ABSTRACTGENPOINTCHAIN_H_INCLUDED__
00030 
00031 
00032 /**
00033  * @file    AbstractGenPointChain.H
00034  * @brief   Header file of class qgar::AbstractGenPointChain.
00035  *
00036  * @author  <a href="mailto:qgar-develop@loria.fr?subject=Qgar fwd Gérald Masini">Gérald Masini</a>,
00037  *          from previous work by Karl Tombre
00038  * @date    December 10, 2003  19:19
00039  * @since   Qgar 2.1.1
00040  */
00041 
00042 
00043 // For RCS/CVS use: Do not delete
00044 /* $Id: AbstractGenPointChain.H,v 1.11 2005/10/17 15:32:35 masini Exp $ */
00045 
00046 
00047 // STL
00048 #include <list>
00049 // QGAR
00050 namespace qgar
00051 {
00052   // Avoid #include's when not necessary
00053   template <class T> class GenPoint;
00054 }
00055 
00056 
00057 
00058 namespace qgar
00059 {
00060 
00061 /**
00062  * @class AbstractGenPointChain AbstractGenPointChain.H "qgarlib/AbstractGenPointChain.H"
00063  * @ingroup DS_POINT
00064  * @brief Base class for chain of points having coordinates of type <b>T</b>.
00065  *
00066  * A point is an instance of class qgar::GenPoint<T>.
00067  * New points can only be inserted to the beginning or to the end of the chain.
00068  *
00069  * Such a chain is provided with some kind of internal ``iterator'',
00070  * that allows bidirectional traversal of the chain. The validity
00071  * of this iterator is preserved by any of the public operations of the class.
00072  *
00073  * - To set the iterator to the beginning (resp. end) of the chain,
00074  *   use function qgar::AbstractGenPointChain::setToBegin
00075  *   (resp. qgar::AbstractGenPointChain::setToEnd)
00076  * - To test if the iterator points to the beginning (resp. end) of the
00077  *   chain, use function qgar::AbstractGenPointChain::isAtBegin
00078  *   (resp. qgar::AbstractGenPointChain::isAtEnd)
00079  * - To test if the chain includes at least one point after (resp. before)
00080  *   the current point, use function qgar::AbstractGenPointChain::hasNext
00081  *   (resp. qgar::AbstractGenPointChain::hasPrevious)
00082  * - To move to the next (resp. previous) point, use function
00083  *   qgar::AbstractGenPointChain::moveNext
00084  *   (resp. qgar::AbstractGenPointChain::movePrevious)
00085  * - To get the current point, use functions qgar::AbstractGenPointChain::current
00086  *   or qgar::AbstractGenPointChain::accessCurrent
00087  * - To get the next (resp. previous) point, use function
00088  *   qgar::AbstractGenPointChain::next
00089  *   or qgar::AbstractGenPointChain::accessNext
00090  *   (resp. qgar::AbstractGenPointChain::previous
00091  *   or qgar::AbstractGenPointChain::accessPrevious)
00092  * - To insert a new point at the beginning (resp. end) of the chain,
00093  *   function qgar::AbstractGenPointChain::push_front
00094  *   (resp. qgar::AbstractGenPointChain::push_back)
00095  *
00096  * Predefined types:
00097  * - qgar::AbstChain
00098  * - qgar::IAbstChain
00099  * - qgar::FAbstChain
00100  * - qgar::DAbstChain
00101  *
00102  * @warning This is an abstract class: It cannot be instantiated.
00103  * Pure virtual functions are:
00104  * - qgar::AbstractGenPointChain::acessBack
00105  * - qgar::AbstractGenPointChain::accessCurrent
00106  * - qgar::AbstractGenPointChain::accessFront
00107  * - qgar::AbstractGenPointChain::accessNext
00108  * - qgar::AbstractGenPointChain::accessPrevious
00109  * - qgar::AbstractGenPointChain::back
00110  * - qgar::AbstractGenPointChain::current
00111  * - qgar::AbstractGenPointChain::empty
00112  * - qgar::AbstractGenPointChain::front
00113  * - qgar::AbstractGenPointChain::hasNext
00114  * - qgar::AbstractGenPointChain::hasPrevious
00115  * - qgar::AbstractGenPointChain::isAtBegin
00116  * - qgar::AbstractGenPointChain::isAtEnd
00117  * - qgar::AbstractGenPointChain::moveNext
00118  * - qgar::AbstractGenPointChain::movePrevious
00119  * - qgar::AbstractGenPointChain::next
00120  * - qgar::AbstractGenPointChain::previous
00121  * - qgar::AbstractGenPointChain::push_back
00122  * - qgar::AbstractGenPointChain::push_front
00123  * - qgar::AbstractGenPointChain::reverse
00124  * - qgar::AbstractGenPointChain::setToBegin
00125  * - qgar::AbstractGenPointChain::setToEnd
00126  * - qgar::AbstractGenPointChain::size
00127  * - qgar::AbstractGenPointChain::toPointList
00128  *
00129  * @author  <a href="mailto:qgar-develop@loria.fr?subject=Qgar fwd Gérald Masini">Gérald Masini</a>,
00130  *          from previous work by Karl Tombre
00131  * @date    December 10, 2003  19:19
00132  * @since   Qgar 2.1.1
00133  */
00134 template <class T> class AbstractGenPointChain
00135 {
00136 // -------------------------------------------------------------------
00137 // T Y P E   D E F I N I T I O N S
00138 // -------------------------------------------------------------------
00139 public:
00140 
00141 
00142   /** @name Types */
00143   //        =====
00144   //@{
00145 
00146   /**
00147    * @brief Type of the points stored in the chain.
00148    */
00149   typedef T value_type;
00150 
00151   /**
00152    * @brief Reference to qgar::AbstractGenPointChain::value_type.
00153    */
00154   typedef value_type& reference;
00155 
00156   /**
00157    * @brief Constant reference to qgar::AbstractGenPointChain::value_type.
00158    */
00159   typedef const value_type& const_reference;
00160 
00161   /**
00162    * @brief Pointer to qgar::AbstractGenPointChain::value_type.
00163    */
00164   typedef value_type* pointer;
00165 
00166   /**
00167    * @brief Constant pointer to qgar::AbstractGenPointChain::value_type.
00168    */
00169   typedef const value_type* const_pointer;
00170 
00171   //@}
00172 
00173 
00174 // -------------------------------------------------------------------
00175 // P U B L I C    M E M B E R S
00176 // -------------------------------------------------------------------
00177 public:
00178 
00179   /** @name Constructors */
00180   //        ============
00181   //@{
00182 
00183   /**
00184    * @brief Default constructor.
00185    */
00186   AbstractGenPointChain();
00187 
00188   //@}
00189 
00190 
00191   /** @name Destructor */
00192   //        ==========
00193   //@{
00194 
00195   /**
00196    * @brief Virtual destructor.
00197    */
00198   virtual ~AbstractGenPointChain();
00199 
00200   //@}
00201 
00202 
00203   /** @name Access to chain characteristics */
00204   //        ===============================
00205   //@{
00206 
00207   /**
00208    * @brief Is current chain empty?
00209    */
00210   virtual bool empty() const = 0;
00211 
00212   /**
00213    * @brief Get chain size (number of points).
00214    */
00215   virtual int size() const = 0;
00216 
00217   //@}
00218 
00219 
00220   /** @name Iterator */
00221   //        ========
00222   //@{
00223 
00224   /**
00225    * @brief Set internal iterator to the beginning of the chain.
00226    */
00227   virtual void setToBegin() = 0;
00228 
00229   /**
00230    * @brief Set internal iterator to the end of the chain.
00231    */
00232   virtual void setToEnd() = 0;
00233 
00234   /**
00235    * @brief Does internal iterator points to the beginning of the chain?
00236    */
00237   virtual bool isAtBegin() const = 0;
00238 
00239   /**
00240    * @brief Does internal iterator points to the end of the chain?
00241    */
00242   virtual bool isAtEnd() const = 0;
00243 
00244   /**
00245    * @brief Is there a point after the current point?
00246    */
00247   virtual bool hasNext() const = 0;
00248 
00249   /**
00250    * @brief Is there a point before the current point?
00251    */
00252   virtual bool hasPrevious() const = 0;
00253 
00254   /**
00255    * @brief Move to next point, that becomes the current point.
00256    */
00257   virtual void moveNext() = 0;
00258 
00259   /**
00260    * @brief Move to previous point, that becomes the current point.
00261    */
00262   virtual void movePrevious() = 0;
00263 
00264   //@}
00265 
00266 
00267   /** @name Access to points */
00268   //        ================
00269   //@{
00270 
00271   /**
00272    * @brief Get the first point.
00273    */
00274   virtual const GenPoint<value_type>& accessFront() const = 0;
00275 
00276  /**
00277    * @brief Get a copy of the first point.
00278    */
00279   virtual GenPoint<value_type> front() const = 0;
00280 
00281   /**
00282    * @brief Get the last point.
00283    */
00284   virtual const GenPoint<value_type>& accessBack() const = 0;
00285 
00286   /**
00287    * @brief Get a copy of the last point.
00288    */
00289   virtual GenPoint<value_type> back() const = 0;
00290 
00291   /**
00292    * @brief Get the current point.
00293    */
00294   virtual const GenPoint<value_type>& accessCurrent() const = 0;
00295 
00296   /**
00297    * @brief Get a copy of the current point.
00298    */
00299   virtual GenPoint<value_type> current() const = 0;
00300 
00301   /**
00302    * @brief Get the successor of the current point.
00303    */
00304   virtual const GenPoint<value_type>& accessNext() = 0;
00305 
00306   /**
00307    * @brief Get a copy of the successor of the current point.
00308    */
00309   virtual GenPoint<value_type> next() = 0;
00310 
00311   /**
00312    * @brief Get the predecessor of the current point.
00313    */
00314   virtual const GenPoint<value_type>& accessPrevious() = 0;
00315 
00316   /**
00317    * @brief Get a copy of the predecessor of the current point.
00318    */
00319   virtual GenPoint<value_type> previous() = 0;
00320 
00321   //@}
00322 
00323 
00324   /** @name Insertion */
00325   //        =========
00326   //@{
00327 
00328   /**
00329    * @brief Insert a point at the beginning of the chain.
00330    * @param aPt  a point
00331    *
00332    * The internal iterator remains valid after the operation.
00333    */
00334   virtual void push_front(const GenPoint<value_type>& aPt) = 0;
00335 
00336   /**
00337    * @brief Insert a point at the end of the chain.
00338    * @param aPt  a point
00339    *
00340    * The internal iterator remains valid after the operation.
00341    */
00342   virtual void push_back(const GenPoint<value_type>& aPt) = 0;
00343 
00344   //@}
00345 
00346 
00347   /** @name Transformations */
00348   //        ===============
00349   //@{
00350 
00351   /**
00352    * @brief Reverse the order of elements in the list.
00353    *
00354    * The internal iterator remains valid once the operation is completed.
00355    */
00356   virtual void reverse() = 0;
00357 
00358 //  /**
00359 //   * @brief Insert the elements of a given chain at the end of current chain.
00360 //   * @param aPtChain  a chain of points
00361 //   *
00362 //   * The internal iterator remains valid once the operation is completed.
00363 //   */
00364 //  virtual void merge(AbstractGenPointChain<T>* aPtChain) = 0;
00365 
00366   //@}
00367 
00368 
00369   /** @name Conversions */
00370   //        ===========
00371   //@{
00372 
00373   /**
00374    * @brief Get a (STL) list of the points of the chain.
00375    */
00376   virtual std::list< GenPoint<value_type> > toPointList() const = 0;
00377 
00378   //@}
00379 
00380 
00381 // -------------------------------------------------------------------
00382 
00383 }; // class AbstractGenPointChain
00384 
00385 
00386 } // namespace qgar
00387 
00388 
00389 
00390 
00391 // IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
00392 // IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
00393 // F U N C T I O N    M E M B E R S    I M P L E M E N T A T I O N
00394 // IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
00395 // IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
00396 
00397 #include <qgarlib/AbstractGenPointChain.TCC>
00398 
00399 // IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
00400 // IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
00401 
00402 
00403 
00404 
00405 // TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
00406 // TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
00407 // P R E D E F I N E D    C H A I N    T Y P E S
00408 // TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
00409 // TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
00410 
00411 
00412 namespace qgar
00413 {
00414 
00415 
00416 /** @name Predefined abstract point chain types */
00417 //        =====================================
00418 //@{
00419 
00420 /**
00421  * @brief Abstract chain of points with <b>integer</b> coordinates.
00422  * @ingroup DS_POINT
00423  *
00424  * @see qgar::IChain
00425  */
00426 typedef AbstractGenPointChain<int> AbstChain;
00427 
00428 /** 
00429  * @brief Abstract chain of points with <b>integer</b> coordinates.
00430  * @ingroup DS_POINT
00431  *
00432  * @see Chain
00433  */
00434 typedef AbstractGenPointChain<int> IAbstChain;
00435 
00436 /**
00437  * @brief Abstract chain of points with <b>float</b> coordinates.
00438  * @ingroup DS_POINT
00439  */
00440 typedef AbstractGenPointChain<float> FAbstChain;
00441 
00442 /**
00443  * @brief Abstract chain of points with <b>double</b> coordinates.
00444  * @ingroup DS_POINT
00445  */
00446 typedef AbstractGenPointChain<double> DAbstChain;
00447 
00448 //@}
00449 
00450 
00451 // TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
00452 // TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
00453 
00454 } // namespace qgar
00455 
00456 
00457 #endif /* __ABSTRACTGENPOINTCHAIN_H_INCLUDED__ */