Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages | Examples

ArConfigArg.h

00001 /*
00002 MobileRobots Advanced Robotics Interface for Applications (ARIA)
00003 Copyright (C) 2004, 2005 ActivMedia Robotics LLC
00004 Copyright (C) 2006, 2007 MobileRobots Inc.
00005 
00006      This program is free software; you can redistribute it and/or modify
00007      it under the terms of the GNU General Public License as published by
00008      the Free Software Foundation; either version 2 of the License, or
00009      (at your option) any later version.
00010 
00011      This program is distributed in the hope that it will be useful,
00012      but WITHOUT ANY WARRANTY; without even the implied warranty of
00013      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014      GNU General Public License for more details.
00015 
00016      You should have received a copy of the GNU General Public License
00017      along with this program; if not, write to the Free Software
00018      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 
00020 If you wish to redistribute ARIA under different terms, contact 
00021 MobileRobots for information about a commercial version of ARIA at 
00022 robots@mobilerobots.com or 
00023 MobileRobots Inc, 19 Columbia Drive, Amherst, NH 03031; 800-639-9481
00024 */
00025 
00026 #ifndef ARCONFIGARG_H
00027 #define ARCONFIGARG_H
00028 
00029 #include "ariaTypedefs.h"
00030 #include "ariaUtil.h"
00031 #include "ArFunctor.h"
00032 
00033 class ArArgumentBuilder;
00034 
00036 
00047 class ArConfigArg
00048 {
00049 public:
00050 
00051   typedef enum 
00052   { 
00053     INVALID, 
00054     INT, 
00055     DOUBLE, 
00056     STRING, 
00057     BOOL, 
00058     FUNCTOR, 
00059     DESCRIPTION_HOLDER, 
00060     STRING_HOLDER, 
00061     SEPARATOR, 
00062     LAST_TYPE = SEPARATOR 
00063   } Type;
00064 
00065   enum {
00066     TYPE_COUNT = LAST_TYPE + 1 
00067   };
00068 
00070   AREXPORT ArConfigArg();
00072   AREXPORT ArConfigArg(const char * name, int *pointer, 
00073                const char * description = "", 
00074                int minInt = INT_MIN, 
00075                int maxInt = INT_MAX); 
00077   AREXPORT ArConfigArg(const char * name, short *pointer, 
00078                const char * description = "", 
00079                int minInt = SHRT_MIN, 
00080                int maxInt = SHRT_MAX); 
00082   AREXPORT ArConfigArg(const char * name, unsigned short *pointer, 
00083                const char * description = "", 
00084                int minInt = 0, 
00085                int maxInt = USHRT_MAX); 
00087   AREXPORT ArConfigArg(const char * name, unsigned char *pointer, 
00088                const char * description = "", 
00089                int minInt = 0,
00090                int maxInt = 255); 
00092   AREXPORT ArConfigArg(const char * name, double *pointer,
00093                const char * description = "", 
00094                double minDouble = -HUGE_VAL,
00095                double maxDouble = HUGE_VAL); 
00097   AREXPORT ArConfigArg(const char * name, bool *pointer,
00098                const char * description = ""); 
00100   AREXPORT ArConfigArg(const char *name, char *str, 
00101                const char *description,
00102                size_t maxStrLen);
00104   AREXPORT ArConfigArg(const char * name, int val, 
00105                const char * description = "", 
00106                int minInt = INT_MIN, 
00107                int maxInt = INT_MAX); 
00109   AREXPORT ArConfigArg(const char * name, double val,
00110                const char * description = "", 
00111                double minDouble = -HUGE_VAL,
00112                double maxDouble = HUGE_VAL); 
00114   AREXPORT ArConfigArg(const char * name, bool val,
00115                const char * description = ""); 
00117   AREXPORT ArConfigArg(const char *name, 
00118          ArRetFunctor1<bool, ArArgumentBuilder *> *setFunctor, 
00119          ArRetFunctor<const std::list<ArArgumentBuilder *> *> *getFunctor,
00120          const char *description);
00121 
00123   AREXPORT ArConfigArg(const char *str, Type type = DESCRIPTION_HOLDER);
00125   AREXPORT ArConfigArg(const char *name, const char *str);
00127   AREXPORT ArConfigArg(Type type);
00128 
00129 
00131   AREXPORT ArConfigArg(const ArConfigArg & arg);
00133   AREXPORT ArConfigArg &operator=(const ArConfigArg &arg);
00135   AREXPORT virtual ~ArConfigArg();
00136 
00138   AREXPORT ArConfigArg::Type getType(void) const;
00140   AREXPORT const char *getName(void) const;
00142   AREXPORT const char *getDescription(void) const;
00143 
00144 
00146   AREXPORT bool setInt(int val, char *errorBuffer = NULL,
00147                size_t errorBufferLen = 0, bool doNotSet = false);
00149   AREXPORT bool setDouble(double val, char *errorBuffer = NULL,
00150               size_t errorBufferLen = 0, bool doNotSet = false);
00152   AREXPORT bool setBool(bool val, char *errorBuffer = NULL,
00153             size_t errorBufferLen = 0, bool doNotSet = false);
00155   AREXPORT bool setString(const char *str, char *errorBuffer = NULL,
00156               size_t errorBufferLen = 0, bool doNotSet = false);
00158   AREXPORT bool setArgWithFunctor(ArArgumentBuilder *argument, 
00159                   char *errorBuffer = NULL,
00160                   size_t errorBufferLen = 0,
00161                   bool doNotSet = false);
00162 
00164   AREXPORT int getInt(void) const; 
00166   AREXPORT double getDouble(void) const;
00168   AREXPORT bool getBool(void) const;
00170   AREXPORT const char *getString(void) const;
00172   AREXPORT const std::list<ArArgumentBuilder *> *getArgsWithFunctor(void) const;
00173 
00175   AREXPORT void log(bool verbose = false) const;
00176   
00178   AREXPORT int getMinInt(void) const;
00180   AREXPORT int getMaxInt(void) const;
00182   AREXPORT double getMinDouble(void) const;
00184   AREXPORT double getMaxDouble(void) const;
00185 
00187   AREXPORT ArPriority::Priority getConfigPriority(void) const;
00189   AREXPORT void setConfigPriority(ArPriority::Priority priority);
00190 
00192   AREXPORT const char *getDisplayHint() const;
00194   AREXPORT void setDisplayHint(const char *hintText);
00195 
00197   AREXPORT void setIgnoreBounds(bool ignoreBounds = false);
00198 
00200   AREXPORT bool isValueEqual(const ArConfigArg &other) const;
00201   
00203   bool isValueSet(void) { return myValueSet; }
00204   
00206   void clearValueSet(void) { myValueSet = false; }
00207   
00208 private:
00210   void clear(void);
00211   void copy(const ArConfigArg &arg);
00212   
00213   void set(ArConfigArg::Type type,
00214            const char *name,
00215            const char *description);
00216 
00217 protected:
00218   enum IntType {
00219     INT_NOT, 
00220     INT_INT, 
00221     INT_SHORT, 
00222     INT_UNSIGNED_SHORT, 
00223     INT_UNSIGNED_CHAR 
00224   };
00225   
00226   ArConfigArg::Type myType;
00227   std::string myName;
00228   std::string myDescription;
00229   bool myOwnPointedTo;
00230   int *myIntPointer;
00231   short *myIntShortPointer;
00232   unsigned short *myIntUnsignedShortPointer;
00233   unsigned char *myIntUnsignedCharPointer;
00234   int myMinInt, myMaxInt;
00235   double *myDoublePointer;
00236   double myMinDouble, myMaxDouble;
00237   bool *myBoolPointer;
00238   char *myStringPointer;
00239   size_t myMaxStrLen;
00240   bool myUsingOwnedString;
00241   std::string myString;
00242   ArPriority::Priority myConfigPriority;
00243   ArConfigArg::IntType myIntType;
00244   bool myIgnoreBounds;
00245   ArRetFunctor1<bool, ArArgumentBuilder *> *mySetFunctor;
00246   ArRetFunctor<const std::list<ArArgumentBuilder *> *> *myGetFunctor;
00247   std::string myDisplayHint;
00248   bool myValueSet;
00249 };
00250 
00251 #endif // ARARGUMENT_H

Generated on Tue Feb 20 10:51:39 2007 for Aria by  doxygen 1.4.0