00001 #if !defined(EDITABLEPARAMETER_H_INCLUDED_)
00002 #define EDITABLEPARAMETER_H_INCLUDED_
00003
00004 #if _MSC_VER > 1000
00005 #pragma once
00006 #endif // _MSC_VER > 1000
00007
00008 #include "ConstrainedParameter.h"
00009
00010 class EditableParameter : public ConstrainedParameter
00011 {
00012 public:
00013
00014 EditableParameter();
00015 EditableParameter(const string & name,
00016 const string & description,
00017 double value,
00018 double defaultValue,
00019 double min,
00020 double max,
00021 double increment,
00022 int type,
00023 int key);
00024 EditableParameter(const string & name,
00025 const string & description,
00026 bool* value,
00027 bool defaultValue,
00028 int key);
00029 EditableParameter(const string & name,
00030 const string & description,
00031 int* value,
00032 int defaultValue,
00033 int min,
00034 int max,
00035 int increment,
00036 int key);
00037 EditableParameter(const string & name,
00038 const string & description,
00039 float* value,
00040 float defaultValue,
00041 float min,
00042 float max,
00043 float increment,
00044 int key);
00045 EditableParameter(const string & name,
00046 const string & description,
00047 double* value,
00048 double defaultValue,
00049 double min,
00050 double max,
00051 double increment,
00052 int key);
00053 EditableParameter(const EditableParameter & parameter);
00054 virtual ~EditableParameter();
00055
00056 const EditableParameter & operator=(const EditableParameter & parameter);
00057
00058 double getIncrement() const;
00059 void setIncrement(double increment);
00060 EditableParameter* set(const string & name, const string & description,
00061 double value, double defaultValue, double min, double max, double increment, int type,int key);
00062 EditableParameter* set(const string & name,const string & description,bool*value, bool defaultValue, int key=0);
00063 EditableParameter* set(const string & name,const string & description,int *value, int defaultValue, int min, int max, int increment,int key=0);
00064 EditableParameter* set(const string & name,const string & description,float*value, float defaultValue, float min, float max, float increment,int key=0);
00065 EditableParameter* set(const string & name,const string & description,double*value, double defaultValue, double min, double max, double increment,int key=0);
00066 void reset();
00067 void unset(){;}
00068 friend ostream& operator<<(ostream& os, const EditableParameter&par);
00069
00070 protected:
00071
00072 double _increment;
00073
00074 };
00075
00076 inline const EditableParameter & EditableParameter::operator=(const EditableParameter & parameter)
00077 {
00078 if (¶meter==this)
00079 return *this;
00080 _key = parameter._key;
00081 _type = parameter._type;
00082 _value = parameter._value;
00083 _minimum = parameter._minimum;
00084 _maximum = parameter._maximum;
00085 _default = parameter._default;
00086 _increment = parameter._increment;
00087 return *this;
00088 }
00089
00090 inline double EditableParameter::getIncrement() const
00091 {
00092 return _increment;
00093 }
00094
00095 inline void EditableParameter::setIncrement(double increment)
00096 {
00097 _increment = increment;
00098 }
00099
00100 inline void EditableParameter::reset()
00101 {
00102 _value = _default;
00103 }
00104
00105 inline EditableParameter* EditableParameter::set(const string & name,const string & description, double value,
00106 double defaultValue, double min, double max,double increment,int type,int key)
00107 {
00108 ConstrainedParameter::set(name,description,value,defaultValue,min,max,type,key);
00109 _increment = increment;
00110 return this;
00111 }
00112
00113 inline EditableParameter* EditableParameter::set(const string & name,const string & description,
00114 bool*value, bool defaultValue, int key)
00115 {
00116 ConstrainedParameter::set(name,description,value,defaultValue,key);
00117 _increment = 1;
00118 *value = defaultValue;
00119 return this;
00120 }
00121
00122 inline EditableParameter* EditableParameter::set(const string & name,const string & description,
00123 int *value, int defaultValue, int min, int max, int increment,int key)
00124 {
00125 ConstrainedParameter::set(name,description,value,defaultValue,min,max,key);
00126 _increment = increment;
00127 *value = defaultValue;
00128 return this;
00129 }
00130
00131 inline EditableParameter* EditableParameter::set(const string & name,const string & description,
00132 float*value, float defaultValue, float min, float max, float increment,int key)
00133 {
00134 ConstrainedParameter::set(name,description,value,defaultValue,min,max,key);
00135 _increment = increment;
00136 *value = defaultValue;
00137 return this;
00138 }
00139
00140 inline EditableParameter * EditableParameter::set(const string & name,const string & description,
00141 double*value, double defaultValue, double min, double max, double increment,int key)
00142 {
00143 ConstrainedParameter::set(name,description,value,defaultValue,min,max,key);
00144 _increment = increment;
00145 *value = defaultValue;
00146 return this;
00147 }
00148
00149 #endif // !defined(EDITABLEPARAMETER_H_INCLUDED_)