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

QgarAppParamDescr.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------*
00002  | Library QgarLib, graphics analysis and recognition                  |
00003  | Copyright (C) 2003  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 license. |
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 __QGARAPPPARAMDESCR_H_INCLUDED__
00029 #define __QGARAPPPARAMDESCR_H_INCLUDED__
00030 
00031 
00032 /**
00033  * @file     QgarAppParamDescr.H
00034  * @brief    Header file of class qgar::QgarAppParamDescr.
00035  *
00036  * @author   <a href="mailto:qgar-develop@loria.fr?subject=Qgar fwd Jan Rendek">Jan Rendek</a>
00037  * @date     May 15, 2003  10:26
00038  * @since    Qgar 2.1.1
00039  */
00040 
00041 
00042 // For RCS/CVS use: Do not delete
00043 /* $Id: QgarAppParamDescr.H,v 1.9 2005/01/31 14:16:07 masini Exp $ */
00044 
00045 
00046 
00047 // STD
00048 #include <string>
00049 
00050 
00051 
00052 namespace qgar
00053 {
00054 
00055 /**
00056  * @class QgarAppParamDescr QgarAppParamDescr.H "qgarlib/QgarAppParamDescr.H"
00057  * @ingroup APP
00058  * @brief Memory representation of an application parameter
00059  * description.
00060  *
00061  * @see QgarAppDescr
00062  *
00063  * @author <a href="mailto:qgar-develop@loria.fr?subject=Qgar fwd Jan Rendek">Jan Rendek</a>
00064  * @date   May 15, 2003  10:26
00065  * @since  Qgar 2.1.1
00066  */
00067 class QgarAppParamDescr
00068 {
00069 // -------------------------------------------------------------------
00070 // P U B L I C    M E M B E R S
00071 // -------------------------------------------------------------------
00072 public:
00073 
00074 
00075 /**
00076  * @brief The parameters passing methods.
00077  */
00078   enum ParamPassing
00079     {
00080       QGE_IN,
00081       QGE_OUT,
00082       QGE_INOUT
00083     };
00084 
00085 /** 
00086  * @var QgarAppParamDescr::QGE_IN
00087  * @brief The parameter is an input of the application and will not be
00088  * modified by its execution.
00089  */
00090 /** 
00091  * @var QgarAppParamDescr::QGE_OUT
00092  * @brief The parameter is an output of the application and will be
00093  * created by its execution.
00094  */
00095 /** 
00096  * @var QgarAppParamDescr::QGE_INOUT
00097  * @brief The parameter is used by the application as both input and
00098  * output.
00099  * The parameter will be modified by the execution of the application.
00100  */
00101 
00102 
00103 /**
00104  * @brief The parameters types.
00105  */
00106   enum ParamType
00107     {
00108       QGE_UNKNOWN_TYPE,
00109       QGE_NUM, 
00110       QGE_IMAGE
00111     };
00112 /** 
00113  * @var QgarAppParamDescr::QGE_UNKNOWN_TYPE
00114  * @brief The type of the parameter is either unknown, or is not
00115  * recognized as a basic parameter type.
00116  */
00117 /** 
00118  * @var QgarAppParamDescr::QGE_NUM
00119  * @brief The parameter is a number.
00120  */
00121 /** 
00122  * @var QgarAppParamDescr::QGE_IMAGE
00123  * @brief The parameter is an image.
00124  */
00125 
00126 
00127 /**
00128  * @brief The parameters formats. 
00129  */
00130   enum ParamFormat
00131     {
00132       QGE_UNKNOWN_FORMAT,
00133       QGE_PBM, 
00134       QGE_PPM, 
00135       QGE_PGM, 
00136       QGE_DXF, 
00137       QGE_SVG,
00138       QGE_INT,
00139       QGE_REAL
00140     };
00141 /** 
00142  * @var qgar::QgarAppParamDescr::QGE_UNKNOWN_FORMAT
00143  * @brief The format of the parameter is either unknown, or is not 
00144  * recognized as a basic parameter format.
00145  */
00146 /** 
00147  * @var qgar::QgarAppParamDescr::QGE_PBM
00148  * @brief The parameter is an image in PBM format.
00149  */
00150 /** 
00151  * @var qgar::QgarAppParamDescr::QGE_PPM
00152  * @brief The parameter is an image in PPM format.
00153  */
00154 /** 
00155  * @var qgar::QgarAppParamDescr::QGE_PGM
00156  * @brief The parameter is an image in PGM format.
00157  */
00158 /** 
00159  * @var qgar::QgarAppParamDescr::QGE_DXF
00160  * @brief The parameter is an image in DXF format.
00161  */
00162 /** 
00163  * @var qgar::QgarAppParamDescr::QGE_SVG
00164  * @brief The parameter is an image in SVG format.
00165  */
00166 /** 
00167  * @var qgar::QgarAppParamDescr::QGE_INT
00168  * @brief The parameter is an integer number.
00169  */
00170 /** 
00171  * @var qgar::QgarAppParamDescr::QGE_REAL
00172  * @brief The parameter is a real number.
00173  */
00174 
00175 
00176 /** @name Constructors */
00177 //        ============
00178 //@{
00179 /**
00180  * @brief Builds an empty parameter description.
00181  *
00182  * The created description cannot be used as is. Its members must be
00183  * updated using the class setters.
00184  */
00185   QgarAppParamDescr();
00186 
00187 /**
00188  * @brief Creates a parameter description from a full set of parameter
00189  * data.
00190  *
00191  * @param name The name of the parameter.
00192  * @param flag The flag introducing the parameter on the command line.
00193  * @param required Whether the parameter is mandatory.
00194  * @param passingMode The passing mode of the parameter.
00195  * @param type The type of the parameter.
00196  * @param format The format of the parameter.
00197  * @param briefDoc The brief documentation of the parameter.
00198  * @param longDoc The detailed documentation of the parameter.
00199  * @param defaultValue The default value for this parameter (if any).
00200  * @param minValue The minimum value for this parameter (if any).
00201  * @param maxValue The maximum value for this parameter (if any).
00202  */
00203   QgarAppParamDescr(const std::string& name,
00204                     const std::string& flag,
00205                     bool required,
00206                     ParamPassing passingMode,
00207                     ParamType type,
00208                     ParamFormat format,
00209                     const std::string& briefDoc,
00210                     const std::string& longDoc,
00211                     const std::string& defaultValue = "",
00212                     const std::string& minValue     = "",
00213                     const std::string& maxValue     = "");
00214 
00215 /**
00216  * @brief Copy constructor
00217  */
00218   QgarAppParamDescr(const QgarAppParamDescr&);
00219 //@}
00220 
00221 
00222 /** @name Destructors */
00223 //        ===========
00224 //@{
00225 /**
00226  * @brief Destructor
00227  */
00228   virtual ~QgarAppParamDescr();
00229 //@}
00230 
00231 
00232 /** @name Access */
00233 //        ======
00234 //@{
00235 /**
00236  * @brief Retrieve the name of the parameter.
00237  *
00238  * @return The name of the parameter.
00239  */
00240   std::string name() const;
00241 
00242 /**
00243  * @brief Retrieve the flag introducing the parameter on the command
00244  * line.
00245  *
00246  * @return The flag introducing the parameter on the command line.
00247  */
00248   std::string flag() const;
00249   
00250 /**
00251  * @brief Query if the parameter is required.
00252  *
00253  * @return True if the parameter is required, false if it is optional
00254  */
00255   bool required() const;
00256 
00257 /**
00258  * @brief Retrieve the parameter passing mode.
00259  *
00260  * @return The parameter passing mode.
00261  */
00262   ParamPassing passingMode() const;
00263 
00264 /**
00265  * @brief Retrieve the parameter type.
00266  *
00267  * @return The parameter type.
00268  */
00269   ParamType type() const;
00270 
00271 /**
00272  * @brief Retrieve the parameter format
00273  *
00274  * @return The parameter format.
00275  */
00276   ParamFormat format() const;
00277   
00278 /**
00279  * @brief Retrieve the parameter default value.
00280  *
00281  * @return The default value serialized as a string, or an empty
00282  * string if none was provided
00283  */
00284   std::string defaultValue() const;
00285 
00286 /**
00287  * @brief Retrieve the parameter minimum value.
00288  *
00289  * @return The minimum value serialized as a string, or an empty
00290  * string if none was provided
00291  */
00292   std::string minValue() const;
00293 
00294 /**
00295  * @brief Retrieve the parameter maximum value.
00296  *
00297  * @return The maximum value serialized as a string, or an empty
00298  * string if none was provided
00299  */
00300   std::string maxValue() const;
00301 
00302 /**
00303  * @brief Retrieve the parameter brief documentation.
00304  *
00305  * @return The parameter brief documentation.
00306  */
00307   std::string briefDoc() const;
00308 
00309 /**
00310  * @brief Retrieve the parameter detailed documentation.
00311  *
00312  * @return The parameter detailed documentation.
00313  */
00314   std::string longDoc() const;
00315 //@}
00316 
00317 
00318 
00319 
00320 /** @name Transformation */
00321 //        ==============
00322 //@{
00323 
00324 /**
00325  * @brief Sets the parameter name.
00326  *
00327  * @param name The new name of the parameter.
00328  */
00329   void setName(const std::string& name);
00330 
00331 /**
00332  * @brief Sets the parameter introducing flag.
00333  *
00334  * @param flag The new flag for the parameter.
00335  */
00336   void setFlag(const std::string& flag);
00337 
00338 /**
00339  * @brief Sets if the parameter is mandatory.
00340  *
00341  * @param required True if the parameter is required, false
00342  * otherwise.
00343  */
00344   void setRequired(bool required);
00345 
00346 /**
00347  * @brief Sets the parameter passing mode.
00348  *
00349  * @param passingMode The new parameter passing mode.
00350  */
00351   void setPassingMode(ParamPassing passingMode);
00352 
00353 /**
00354  * @brief Sets the parameter type.
00355  *
00356  * @param type The new parameter type.
00357  */
00358   void setType(ParamType type);
00359 
00360 /**
00361  * @brief Sets the parameter format.
00362  *
00363  * @param format The new parameter format.
00364  */
00365   void setFormat(ParamFormat format);
00366 
00367 /**
00368  * @brief Sets the parameter default value.
00369  *
00370  * @param val The new default value for the parameter serialized as a
00371  * string.
00372  */
00373   void setDefaultValue(const std::string& val);
00374 
00375 /**
00376  * @brief Sets the parameter minimum value.
00377  *
00378  * @param val The new minimum value for the parameter serialized as a
00379  * string.
00380  */
00381   void setMinValue(const std::string& val);
00382 
00383 /**
00384  * @brief Sets the parameter maximum value.
00385  *
00386  * @param val The new maximum value for the parameter serialized as a
00387  * string.
00388  */
00389   void setMaxValue(const std::string& val);
00390 
00391 /**
00392  * @brief Sets the brief documentation for the parameter.
00393  *
00394  * @param briefDoc The new brief documentation for the parameter.
00395  */
00396   void setBriefDoc(const std::string& briefDoc);
00397 
00398 /**
00399  * @brief Sets the detailed documentation for the parameter.
00400  *
00401  * @param longDoc The new detailed documentation for the parameter.
00402  */
00403   void setLongDoc(const std::string& longDoc);
00404 
00405 //@}
00406 
00407 
00408 
00409 /** @name Operators */
00410 //        =========
00411 //@{
00412 /**
00413  * @brief Assignment operator
00414  */
00415   QgarAppParamDescr& operator=(const QgarAppParamDescr&);
00416 //@}
00417 
00418 
00419 // -------------------------------------------------------------------
00420 // P R O T E C T E D    M E M B E R S
00421 // -------------------------------------------------------------------
00422 protected:
00423 
00424   /// The name of the parameter.
00425   std::string _name;
00426  
00427 /**
00428  * @brief The flag introducing this parameter on the command line
00429  * invoking  the application.
00430  */
00431   std::string _flag;
00432   
00433   /// Flag indicating if the parameter is required or optional.
00434   bool _required;
00435 
00436   /// The passing mode for this parameter.  
00437   ParamPassing _passingMode;
00438 
00439   /// The type of this parameter.
00440   ParamType _type;
00441 
00442   /// The format of this parameter.
00443   ParamFormat _format;
00444 
00445   /// The brief documentation for this parameter.
00446   std::string _briefDoc;
00447 
00448   /// The long documentation for this parameter.
00449   std::string _longDoc;
00450 
00451   /// The default value for this parameter (if any).
00452   std::string _defaultValue;
00453 
00454   /// The minimum value for this parameter (if any).
00455   std::string _minValue;
00456 
00457   /// The max value for this parameter (if any).
00458   std::string _maxValue;
00459 
00460 // -------------------------------------------------------------------
00461 }; // class QgarAppParamDescr
00462 
00463 } // namespace qgar
00464 
00465 
00466 #endif /* __QGARAPPPARAMDESCR_H_INCLUDED__ */