00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef ARCONFIGARG_H
00028 #define ARCONFIGARG_H
00029
00030 #include "ariaTypedefs.h"
00031 #include "ariaUtil.h"
00032 #include "ArFunctor.h"
00033
00034 class ArArgumentBuilder;
00035
00037
00040 class ArConfigArg
00041 {
00042 public:
00043 typedef enum
00044 {
00045 INVALID,
00046 INT,
00047 DOUBLE,
00048 STRING,
00049 BOOL,
00050 FUNCTOR,
00051 DESCRIPTION_HOLDER,
00052
00053 LAST_TYPE = DESCRIPTION_HOLDER
00054 } Type;
00055
00056 enum {
00057 TYPE_COUNT = LAST_TYPE + 1
00058 };
00059
00061 ArConfigArg();
00063 ArConfigArg(const char * name, int *pointer,
00064 const char * description = "",
00065 int minInt = INT_MIN,
00066 int maxInt = INT_MAX);
00068 ArConfigArg(const char * name, short *pointer,
00069 const char * description = "",
00070 int minInt = SHRT_MIN,
00071 int maxInt = SHRT_MAX);
00073 ArConfigArg(const char * name, unsigned short *pointer,
00074 const char * description = "",
00075 int minInt = 0,
00076 int maxInt = USHRT_MAX);
00078 ArConfigArg(const char * name, unsigned char *pointer,
00079 const char * description = "",
00080 int minInt = 0,
00081 int maxInt = 255);
00083 ArConfigArg(const char * name, double *pointer,
00084 const char * description = "",
00085 double minDouble = -HUGE_VAL,
00086 double maxDouble = HUGE_VAL);
00088 ArConfigArg(const char * name, bool *pointer,
00089 const char * description = "");
00091 ArConfigArg(const char *name, char *str,
00092 const char *description,
00093 size_t maxStrLen);
00095 ArConfigArg(const char * name, int val,
00096 const char * description = "",
00097 int minInt = INT_MIN,
00098 int maxInt = INT_MAX);
00100 ArConfigArg(const char * name, double val,
00101 const char * description = "",
00102 double minDouble = -HUGE_VAL,
00103 double maxDouble = HUGE_VAL);
00105 ArConfigArg(const char * name, bool val,
00106 const char * description = "");
00108 ArConfigArg(const char *name,
00109 ArRetFunctor1<bool, ArArgumentBuilder *> *setFunctor,
00110 ArRetFunctor<const std::list<ArArgumentBuilder *> *> *getFunctor,
00111 const char *description);
00113 ArConfigArg(const char *description);
00115 ArConfigArg(const ArConfigArg & arg);
00117 ArConfigArg &operator=(const ArConfigArg &arg);
00119 virtual ~ArConfigArg();
00120
00122 Type getType(void) const;
00124 const char *getName(void) const;
00126 const char *getDescription(void) const;
00128 bool setInt(int val, char *errorBuffer = NULL,
00129 size_t errorBufferLen = 0, bool doNotSet = false);
00131 bool setDouble(double val, char *errorBuffer = NULL,
00132 size_t errorBufferLen = 0, bool doNotSet = false);
00134 bool setBool(bool val, char *errorBuffer = NULL,
00135 size_t errorBufferLen = 0, bool doNotSet = false);
00137 bool setString(const char *str, char *errorBuffer = NULL,
00138 size_t errorBufferLen = 0, bool doNotSet = false);
00140 bool setArgWithFunctor(ArArgumentBuilder *argument,
00141 char *errorBuffer = NULL,
00142 size_t errorBufferLen = 0,
00143 bool doNotSet = false);
00145 int getInt(void) const;
00147 double getDouble(void) const;
00149 bool getBool(void) const;
00151 const char *getString(void) const;
00153 const std::list<ArArgumentBuilder *> *getArgsWithFunctor(void) const;
00155 void log(bool verbose = false) const;
00157 int getMinInt(void) const;
00159 int getMaxInt(void) const;
00161 double getMinDouble(void) const;
00163 double getMaxDouble(void) const;
00165 ArPriority::Priority getConfigPriority(void) const;
00167 void setConfigPriority(ArPriority::Priority priority);
00169 void setIgnoreBounds(bool ignoreBounds = false);
00170
00171 private:
00173 void clear(void);
00174 void copy(const ArConfigArg &arg);
00175
00176 protected:
00177 enum IntType {
00178 INT_NOT,
00179 INT_INT,
00180 INT_SHORT,
00181 INT_UNSIGNED_SHORT,
00182 INT_UNSIGNED_CHAR
00183 };
00184
00185
00186 ArConfigArg::Type myType;
00187 std::string myName;
00188 std::string myDescription;
00189 bool myOwnPointedTo;
00190 int *myIntPointer;
00191 short *myIntShortPointer;
00192 unsigned short *myIntUnsignedShortPointer;
00193 unsigned char *myIntUnsignedCharPointer;
00194 int myMinInt, myMaxInt;
00195 double *myDoublePointer;
00196 double myMinDouble, myMaxDouble;
00197 bool *myBoolPointer;
00198 char *myStringPointer;
00199 size_t myMaxStrLen;
00200 bool myUsingOwnedString;
00201 std::string myString;
00202 ArPriority::Priority myConfigPriority;
00203 ArConfigArg::IntType myIntType;
00204 bool myIgnoreBounds;
00205 ArRetFunctor1<bool, ArArgumentBuilder *> *mySetFunctor;
00206 ArRetFunctor<const std::list<ArArgumentBuilder *> *> *myGetFunctor;
00207 };
00208
00209 #endif // ARARGUMENT_H