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

GenEdge.TCC

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------+
00002  | Library QgarLib, graphics analysis and recognition                  |
00003  | Copyright (C) 2005  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 /**
00029  * @file   GenEdge.TCC
00030  * @brief  Implementation of function members of class qgar::GenEdge.
00031  *
00032  * @author <a href="mailto:qgar-develop@loria.fr?subject=Qgar fwd Gérald Masini">Gérald Masini</a>
00033  * @date   January 27, 2005  21:04
00034  * @since  Qgar 2.2
00035  */
00036 
00037 
00038 
00039 namespace qgar
00040 {
00041 
00042 
00043 // -------------------------------------------------------------------
00044 // C O N S T R U C T O R S
00045 // -------------------------------------------------------------------
00046 
00047 
00048 // DEFAULT CONSTRUCTOR
00049 
00050 template <class TNODE, class TEDGE>
00051 GenEdge<TNODE,TEDGE>::GenEdge(short int aFlag)
00052 
00053   : _flag(aFlag),
00054     _pSource (0),
00055     _pTarget (0)
00056 
00057 {
00058   // VOID
00059 }
00060 
00061 
00062 // INITIALIZE WITH DATA
00063 
00064 template <class TNODE, class TEDGE>
00065 GenEdge<TNODE,TEDGE>::GenEdge(const TEDGE& aData, short int aFlag)
00066 
00067   : _data    (aData),
00068     _flag    (aFlag),
00069     _pSource (0),
00070     _pTarget (0)
00071 
00072 {
00073   // VOID
00074 }
00075 
00076 
00077 // INITIALIZE WITH SOURCE AND TARGET
00078 
00079 template <class TNODE, class TEDGE>
00080 GenEdge<TNODE,TEDGE>::GenEdge(GenNode<TNODE,TEDGE>* const aPSource,
00081                               GenNode<TNODE,TEDGE>* const aPTarget,
00082                               short int aFlag)
00083 
00084   : _flag    (aFlag),
00085     _pSource (aPSource),
00086     _pTarget (aPTarget)
00087 
00088 {
00089   // VOID
00090 }
00091 
00092 
00093 // INITIALIZE WITH SOURCE, TARGET, AND DATA
00094 
00095 template <class TNODE, class TEDGE>
00096 GenEdge<TNODE,TEDGE>::GenEdge(GenNode<TNODE,TEDGE>* const aPSource,
00097                               GenNode<TNODE,TEDGE>* const aPTarget,
00098                               const TEDGE& aData,
00099                               short int aFlag)
00100 
00101   : _data    (aData),
00102     _flag    (aFlag),
00103     _pSource (aPSource),
00104     _pTarget (aPTarget)
00105 
00106 {
00107   // VOID
00108 }
00109 
00110 
00111 // COPY CONSTRUCTOR
00112 
00113 template <class TNODE, class TEDGE>
00114 GenEdge<TNODE,TEDGE>::GenEdge(const GenEdge<TNODE,TEDGE>& anEdge)
00115 
00116   : _data    (anEdge._data),
00117     _flag    (anEdge._flag),
00118     _pSource (anEdge._pSource),
00119     _pTarget (anEdge._pTarget)
00120 
00121 {
00122   // VOID
00123 }
00124 
00125 
00126 // -------------------------------------------------------------------
00127 // D E S T R U C T O R 
00128 // -------------------------------------------------------------------
00129 
00130 
00131 // NON-VIRTUAL DESTRUCTOR
00132 
00133 template <class TNODE, class TEDGE>
00134 GenEdge<TNODE,TEDGE>::~GenEdge()
00135 {
00136   // VOID
00137 }
00138 
00139 
00140 // -------------------------------------------------------------------
00141 // E D G E   D A T A
00142 // -------------------------------------------------------------------
00143 
00144 
00145 // GET EDGE DATA
00146 
00147 template <class TNODE, class TEDGE>
00148 inline const TEDGE&
00149 GenEdge<TNODE,TEDGE>::accessData() const
00150 {
00151   return _data;
00152 }
00153 
00154 
00155 // GET A COPY OF EDGE DATA
00156 
00157 template <class TNODE, class TEDGE>
00158 inline TEDGE
00159 GenEdge<TNODE,TEDGE>::data() const
00160 {
00161   return _data;
00162 }
00163 
00164 
00165 // SET EDGE DATA
00166 
00167 template <class TNODE, class TEDGE>
00168 inline void
00169 GenEdge<TNODE,TEDGE>::setData(const TEDGE& aData)
00170 {
00171   _data = aData;
00172 }
00173 
00174 
00175 // GET EDGE FLAG
00176 
00177 template <class TNODE, class TEDGE>
00178 inline short int
00179 GenEdge<TNODE,TEDGE>::flag() const
00180 {
00181   return _flag;
00182 }
00183 
00184 
00185 // SET EDGE FLAG
00186 
00187 template <class TNODE, class TEDGE>
00188 inline void
00189 GenEdge<TNODE,TEDGE>::setFlag(short int aFlag)
00190 {
00191   _flag = aFlag;
00192 }
00193 
00194 
00195 // -------------------------------------------------------------------
00196 // A D J A C E N T   N O D E S
00197 // -------------------------------------------------------------------
00198 
00199 
00200 // GET SOURCE NODE
00201 
00202 template <class TNODE, class TEDGE>
00203 inline const GenNode<TNODE,TEDGE>&
00204 GenEdge<TNODE,TEDGE>::accessSource() const
00205 {
00206   return *_pSource;
00207 }
00208 
00209 
00210 // GET A COPY OF THE SOURCE NODE
00211 
00212 template <class TNODE, class TEDGE>
00213 inline GenNode<TNODE,TEDGE>
00214 GenEdge<TNODE,TEDGE>::source() const
00215 {
00216   return *_pSource;
00217 }
00218 
00219 
00220 // GET A POINTER TO THE SOURCE NODE
00221 
00222 template <class TNODE, class TEDGE>
00223 inline GenNode<TNODE,TEDGE>*
00224 GenEdge<TNODE,TEDGE>::pSource() const
00225 {
00226   return _pSource;
00227 }
00228 
00229 
00230 // GET TARGET NODE
00231 
00232 template <class TNODE, class TEDGE>
00233 inline const GenNode<TNODE,TEDGE>&
00234 GenEdge<TNODE,TEDGE>::accessTarget() const
00235 {
00236   return *_pTarget;
00237 }
00238 
00239 
00240 // GET A COPY OF THE TARGET NODE
00241 
00242 template <class TNODE, class TEDGE>
00243 inline GenNode<TNODE,TEDGE>
00244 GenEdge<TNODE,TEDGE>::target() const
00245 {
00246   return *_pTarget;
00247 }
00248 
00249 
00250 // RETURN A POINTER TO THE TARGET NODE
00251 
00252 template <class TNODE, class TEDGE>
00253 inline GenNode<TNODE,TEDGE>*
00254 GenEdge<TNODE,TEDGE>::pTarget() const
00255 {
00256   return _pTarget;
00257 }
00258 
00259 
00260 // SET POINTER TO SOURCE NODE
00261 
00262 template <class TNODE, class TEDGE>
00263 inline void
00264 GenEdge<TNODE,TEDGE>::setPSource(GenNode<TNODE,TEDGE>* aPSource)
00265 {
00266   _pSource = aPSource;
00267 }
00268 
00269 
00270 // SET POINTER TO TARGET NODE
00271 
00272 template <class TNODE, class TEDGE>
00273 inline void
00274 GenEdge<TNODE,TEDGE>::setPTarget(GenNode<TNODE,TEDGE>* aPTarget)
00275 {
00276   _pTarget = aPTarget;
00277 }
00278 
00279 
00280 // SET POINTER TO SOURCE NODE WHEN FREE,
00281 // OTHERWISE SET POINTER TO TARGET NODE
00282 
00283 template <class TNODE, class TEDGE>
00284 inline void
00285 GenEdge<TNODE,TEDGE>::setPNode(GenNode<TNODE,TEDGE>* aPNode)
00286 {
00287   if (_pSource == 0)
00288     {
00289       _pSource = aPNode;
00290     }
00291   else
00292     {
00293       _pTarget = aPNode;
00294     }
00295 }
00296 
00297 
00298 // -------------------------------------------------------------------
00299 // O P E R A T O R S
00300 // -------------------------------------------------------------------
00301 
00302 
00303 // ASSIGNMENT
00304 
00305 template <class TNODE, class TEDGE>
00306 GenEdge<TNODE,TEDGE>&
00307 GenEdge<TNODE,TEDGE>::operator=(const GenEdge<TNODE,TEDGE>& anEdge)
00308 {
00309   // Are left hand side and right hand side different objects?
00310   if (this != &anEdge)
00311     {
00312       _data    = anEdge._data;
00313       _flag    = anEdge._flag;
00314       _pSource = anEdge._pSource;
00315       _pTarget = anEdge._pTarget;
00316     }
00317 
00318   return *this;
00319 }
00320  
00321 
00322 // EQUALITY
00323 
00324 template <class TNODE, class TEDGE>
00325 bool
00326 GenEdge<TNODE,TEDGE>::operator==(const GenEdge<TNODE,TEDGE>& anEdge)
00327 {
00328   return _data == anEdge._data;
00329 }
00330 
00331 
00332 // INEQUALITY
00333 
00334 template <class TNODE, class TEDGE>
00335 bool
00336 GenEdge<TNODE,TEDGE>::operator!=(const GenEdge<TNODE,TEDGE>& anEdge)
00337 {
00338   return _data != anEdge._data;
00339 }
00340 
00341 
00342 // -------------------------------------------------------------------
00343 
00344 
00345 } // namespace qgar