- Timestamp:
- Jan 11, 2009, 10:20:06 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 10 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/configure
r1262 r1270 14950 14950 14951 14951 14952 ac_config_files="$ac_config_files Makefile packages/Makefile src/Makefile src/core/Makefile src/core2/Makefile src/objects/Makefile gui/Makefile gui/apps/Makefile gui/apps/about gui/apps/rappture gui/apps/rappture-csh.env gui/apps/rappture.env gui/apps/rerun gui/apps/simsim gui/apps/xmldiff gui/pkgIndex.tcl gui/scripts/Makefile lang/Makefile lang/perl/Makefile lang/perl/Makefile.PL lang/python/Makefile lang/python/setup.py lang/matlab/Makefile lang/octave/Makefile lang/octave/RpOctaveInterface.h lang/ruby/Makefile lang/ruby/build.rb lang/tcl/Makefile lang/tcl/pkgIndex.tcl lang/tcl/src/Makefile lang/tcl/scripts/Makefile lang/tcl/tests/Makefile lib/Makefile examples/3D/Makefile examples/Makefile examples/app-fermi/2.0/Makefile examples/app-fermi/Makefile examples/app-fermi/cee/Makefile examples/app-fermi/fortran/Makefile examples/app-fermi/matlab/Makefile examples/app-fermi/matlab/compiled/Makefile examples/app-fermi/matlab/uncompiled/Makefile examples/app-fermi/octave/Makefile examples/app-fermi/perl/Makefile examples/app-fermi/python/Makefile examples/app-fermi/ruby/Makefile examples/app-fermi/tcl/Makefile examples/app-fermi/wrapper/Makefile examples/app-fermi/wrapper/cee/Makefile examples/app-fermi/wrapper/python/Makefile examples/app-fermi/wrapper/tcl/Makefile examples/c-example/Makefile examples/canvas/Makefile examples/demo.bash examples/graph/Makefile examples/objects/Makefile examples/objects/dxWriter/Makefile examples/objects/floatBuffer/Makefile examples/zoo/Makefile examples/zoo/binary/Makefile examples/zoo/boolean/Makefile examples/zoo/choice/Makefile examples/zoo/cloud/Makefile examples/zoo/cloud/matlab/Makefile examples/zoo/curve/Makefile examples/zoo/enable/Makefile examples/zoo/field/Makefile examples/zoo/group/Makefile examples/zoo/image/Makefile examples/zoo/image/docs/Makefile examples/zoo/image/examples/Makefile examples/zoo/integer/Makefile examples/zoo/integer2/Makefile examples/zoo/loader/Makefile examples/zoo/loader/examples/Makefile examples/zoo/loadrun/Makefile examples/zoo/log/Makefile examples/zoo/note/Makefile examples/zoo/note/docs/Makefile examples/zoo/number/Makefile examples/zoo/number2/Makefile examples/zoo/phase/Makefile examples/zoo/sequence/Makefile examples/zoo/sequence/examples/Makefile examples/zoo/string/Makefile examples/zoo/structure/Makefile examples/zoo/structure/examples/Makefile examples/zoo/table/Makefile examples/zoo/unirect2d/Makefile test/Makefile test/src/Makefile"14952 ac_config_files="$ac_config_files Makefile packages/Makefile src/Makefile src/core/Makefile src/core2/Makefile src/objects/Makefile src/objects/RpHash.h gui/Makefile gui/apps/Makefile gui/apps/about gui/apps/rappture gui/apps/rappture-csh.env gui/apps/rappture.env gui/apps/rerun gui/apps/simsim gui/apps/xmldiff gui/pkgIndex.tcl gui/scripts/Makefile lang/Makefile lang/perl/Makefile lang/perl/Makefile.PL lang/python/Makefile lang/python/setup.py lang/matlab/Makefile lang/octave/Makefile lang/octave/RpOctaveInterface.h lang/ruby/Makefile lang/ruby/build.rb lang/tcl/Makefile lang/tcl/pkgIndex.tcl lang/tcl/src/Makefile lang/tcl/scripts/Makefile lang/tcl/tests/Makefile lib/Makefile examples/3D/Makefile examples/Makefile examples/app-fermi/2.0/Makefile examples/app-fermi/Makefile examples/app-fermi/cee/Makefile examples/app-fermi/fortran/Makefile examples/app-fermi/matlab/Makefile examples/app-fermi/matlab/compiled/Makefile examples/app-fermi/matlab/uncompiled/Makefile examples/app-fermi/octave/Makefile examples/app-fermi/perl/Makefile examples/app-fermi/python/Makefile examples/app-fermi/ruby/Makefile examples/app-fermi/tcl/Makefile examples/app-fermi/wrapper/Makefile examples/app-fermi/wrapper/cee/Makefile examples/app-fermi/wrapper/python/Makefile examples/app-fermi/wrapper/tcl/Makefile examples/c-example/Makefile examples/canvas/Makefile examples/demo.bash examples/graph/Makefile examples/objects/Makefile examples/objects/dxWriter/Makefile examples/objects/floatBuffer/Makefile examples/zoo/Makefile examples/zoo/binary/Makefile examples/zoo/boolean/Makefile examples/zoo/choice/Makefile examples/zoo/cloud/Makefile examples/zoo/cloud/matlab/Makefile examples/zoo/curve/Makefile examples/zoo/enable/Makefile examples/zoo/field/Makefile examples/zoo/group/Makefile examples/zoo/image/Makefile examples/zoo/image/docs/Makefile examples/zoo/image/examples/Makefile examples/zoo/integer/Makefile examples/zoo/integer2/Makefile examples/zoo/loader/Makefile examples/zoo/loader/examples/Makefile examples/zoo/loadrun/Makefile examples/zoo/log/Makefile examples/zoo/note/Makefile examples/zoo/note/docs/Makefile examples/zoo/number/Makefile examples/zoo/number2/Makefile examples/zoo/phase/Makefile examples/zoo/sequence/Makefile examples/zoo/sequence/examples/Makefile examples/zoo/string/Makefile examples/zoo/structure/Makefile examples/zoo/structure/examples/Makefile examples/zoo/table/Makefile examples/zoo/unirect2d/Makefile test/Makefile test/src/Makefile" 14953 14953 14954 14954 cat >confcache <<\_ACEOF … … 15527 15527 "src/core2/Makefile") CONFIG_FILES="$CONFIG_FILES src/core2/Makefile" ;; 15528 15528 "src/objects/Makefile") CONFIG_FILES="$CONFIG_FILES src/objects/Makefile" ;; 15529 "src/objects/RpHash.h") CONFIG_FILES="$CONFIG_FILES src/objects/RpHash.h" ;; 15529 15530 "gui/Makefile") CONFIG_FILES="$CONFIG_FILES gui/Makefile" ;; 15530 15531 "gui/apps/Makefile") CONFIG_FILES="$CONFIG_FILES gui/apps/Makefile" ;; -
trunk/configure.in
r1262 r1270 1 AC_INIT([Rappture], [1.1], [rappture@nanohub.org]) 1 AC_INIT([Rappture],[1.1],[rappture@nanohub.org]) 2 dnl AC_CONFIG_HEADER(src/core/RpConfig.h) 2 3 AC_CONFIG_AUX_DIR(cf) 3 4 … … 35 36 AC_PROG_F77([g77 gfortran f77 fort77 f90 xlf xlf90 fl32]) 36 37 37 AC_LANG _C38 AC_LANG([C]) 38 39 39 40 AC_HEADER_STDC 40 41 AC_CHECK_FUNC(atol,,AC_MSG_ERROR(oops! no atol ?!?)) 41 42 42 AC_LANG _CPLUSPLUS43 AC_LANG([C++]) 43 44 44 45 AC_CHECK_LIB(m, main,,AC_MSG_ERROR(librappture requires libm)) … … 94 95 done 95 96 if test "x${make_command}" = "x" ; then 96 AC_ ERROR([Requires GNU make. You can specify a version with \$MAKE])97 AC_MSG_ERROR([Requires GNU make. You can specify a version with \$MAKE]) 97 98 fi 98 99 AC_SUBST(MAKE, ${make_command}) … … 483 484 484 485 dnl read Makefile.in and write Makefile 485 AC_ OUTPUT([486 AC_CONFIG_FILES([ 486 487 Makefile 487 488 packages/Makefile … … 490 491 src/core2/Makefile 491 492 src/objects/Makefile 493 src/objects/RpHash.h 492 494 gui/Makefile 493 495 gui/apps/Makefile … … 576 578 test/src/Makefile 577 579 ]) 580 AC_OUTPUT -
trunk/src/core/Makefile.in
r1086 r1270 1 1 2 2 bindir = @bindir@ 3 datadir 4 datarootdir 3 datadir = @datadir@ 4 datarootdir = @datarootdir@ 5 5 exec_prefix = @exec_prefix@ 6 6 includedir = @includedir@ … … 8 8 mandir = @mandir@ 9 9 prefix = @prefix@ 10 srcdir 11 incdir 10 srcdir = @srcdir@ 11 incdir = $(prefix)/include 12 12 13 INSTALL 14 MKDIR_P 13 INSTALL = @INSTALL@ 14 MKDIR_P = @MKDIR_P@ 15 15 16 16 CXX = @CXX@ … … 19 19 # We need to link with g++ on MacOS 10.4 20 20 CC = $(CXX) 21 CCC 21 CCC = @CC@ 22 22 CFLAGS_DEBUG = @CFLAGS_DEBUG@ -Wall 23 23 CFLAGS_OPTIMIZE = @CFLAGS_OPTIMIZE@ … … 31 31 CFLAGS = @CFLAGS@ 32 32 33 CC_SWITCHES 34 CXX_SWITCHES 33 CC_SWITCHES = $(CFLAGS) $(CFLAGS_DEBUG) $(INCLUDES) $(DEFINES) 34 CXX_SWITCHES = $(CFLAGS) $(CFLAGS_DEBUG) $(INCLUDES) $(DEFINES) 35 35 36 INCLUDES = -I$(srcdir) \ 37 -I$(includedir) 36 INCLUDES = \ 37 -I. \ 38 -I$(srcdir) \ 39 -I$(includedir) 38 40 39 RANLIB 40 AR 41 VPATH 42 RM 41 RANLIB = @RANLIB@ 42 AR = ar 43 VPATH = $(srcdir):$(srcdir)/scew:$(srcdir)/b64 44 RM = rm -f 43 45 44 46 CDEBUGFLAGS = -g -Wall 45 47 46 LIBS 48 LIBS = -lexpat -lz -lm -lstdc++ 47 49 48 50 HEADERS = \ … … 76 78 RpUtilsFInterface.h \ 77 79 RpUtilsFStubs.h \ 78 rappture.h 80 rappture.h 79 81 80 82 SCEW_HEADERS = \ … … 94 96 xprint.h \ 95 97 xtree.h \ 96 97 xerror.h98 writer.h \ 99 xerror.h 98 100 99 101 # Build the scew and b64 libraries directly into Rappture for now. … … 116 118 xhandler.o \ 117 119 xparser.o \ 118 xprint.o 120 xprint.o 119 121 120 122 OBJS = \ … … 144 146 $(B64_OBJS) 145 147 146 name 147 libname 148 lib 149 shared_lib 148 name = rappture 149 libname = lib$(name) 150 lib = $(libname).a 151 shared_lib = $(libname)$(SHLIB_SUFFIX) 150 152 151 153 all: $(lib) $(shared_lib) -
trunk/src/objects/Makefile.in
r1018 r1270 14 14 15 15 CXX = @CXX@ 16 CC = @CXX@ 16 CC = $(CXX) 17 CCC = @CC@ 17 18 CFLAGS_DEBUG = @CFLAGS_DEBUG@ 18 19 CFLAGS_OPTIMIZE = @CFLAGS_OPTIMIZE@ … … 29 30 30 31 INCLUDES = \ 32 -I. \ 33 -I../core \ 31 34 -I$(srcdir) \ 32 35 -I$(srcdir)/../core \ … … 48 51 49 52 HEADERS = \ 50 RpBoolean.h \ 53 RpChain.h \ 54 RpInt.h \ 55 RpHash.h \ 56 RpHashHelper.h \ 57 RpNumber.h \ 58 RpPool.h \ 59 RpVariable.h 60 61 # RpBoolean.h \ 51 62 RpAbout.h \ 52 63 RpNumber.h \ … … 57 68 58 69 OBJS = \ 59 RpAbout.o \ 70 RpChain.o \ 71 RpHash.o \ 72 RpHashHelper.o \ 73 RpNumber.o \ 74 RpPool.o \ 75 RpVariable.o 76 77 # RpAbout.o \ 60 78 RpBoolean.o \ 61 79 RpChoice.o \ … … 93 111 $(CXX) $(CC_SWITCHES) -c $? 94 112 .c.o: 95 $(CC ) $(CC_SWITCHES) -c $?113 $(CCC) $(CC_SWITCHES) -c $? 96 114 97 115 clean: -
trunk/src/objects/RpNumber.cc
r1018 r1270 5 5 * ====================================================================== 6 6 * AUTHOR: Derrick Kearney, Purdue University 7 * Copyright (c) 200 4-2005Purdue Research Foundation7 * Copyright (c) 2005-2009 Purdue Research Foundation 8 8 * 9 9 * See the file "license.terms" for information on usage and … … 12 12 */ 13 13 14 #include <cstring> 15 #include <stdlib.h> 14 16 #include "RpNumber.h" 15 17 16 /**********************************************************************/ 17 // METHOD: setDefaultValue() 18 /// set the default value of a RpNumber object. 19 /** 20 */ 18 #ifndef _RpUNITS_H 19 #include "RpUnits.h" 20 #endif 21 21 22 RpNumber& 23 RpNumber::setDefaultValue(double newDefaultVal) { 22 RpNumber::RpNumber ( 23 const char *path, 24 const char *unit, 25 double val 26 ) 27 : RpVariable (), 28 _default (val), 29 _current (val), 30 _min (0.0), 31 _max (0.0), 32 _minmaxSet (0.0) 33 { 34 const RpUnits *u = NULL; 24 35 25 double* def = NULL;36 property("path",(const void *)path); 26 37 27 def = (double*) RpVariable::getDefaultValue(); 38 u = RpUnits::find(std::string(unit)); 39 if (!u) { 40 u = RpUnits::define(unit,NULL); 41 } 42 property("units",(const void *)unit); 28 43 29 if (!def) { 30 RpVariable::setDefaultValue(new double (newDefaultVal)); 44 property("default",(const void *)&_default); 45 property("current",(const void *)&_current); 46 property("min",(const void *)&_min); 47 property("max",(const void *)&_max); 48 } 49 50 RpNumber::RpNumber ( 51 const char *path, 52 const char *unit, 53 double val, 54 double min, 55 double max, 56 const char *label, 57 const char *desc 58 ) 59 : RpVariable (), 60 _default (val), 61 _current (val), 62 _min (min), 63 _max (max), 64 _minmaxSet (0) 65 { 66 const RpUnits *u = NULL; 67 68 property("path",(const void *)path); 69 70 u = RpUnits::find(std::string(unit)); 71 if (! u) { 72 u = RpUnits::define(unit,NULL); 73 } 74 property("units",(const void *)unit); 75 76 if ((min == 0) && (max == 0)) { 77 _minmaxSet = 0; 31 78 } 32 79 else { 33 *def = newDefaultVal; 80 81 if (min > val) { 82 _min = val; 83 } 84 85 if (max < val) { 86 _max = val; 87 } 34 88 } 35 89 36 return *this; 90 property("default",(const void *)&_default); 91 property("current",(const void *)&_current); 92 property("min",(const void *)&_min); 93 property("max",(const void *)&_max); 94 } 95 96 // copy constructor 97 RpNumber::RpNumber ( const RpNumber& o ) 98 : RpVariable(o), 99 _default (o._default), 100 _current (o._current), 101 _min (o._min), 102 _max (o._max), 103 _minmaxSet (o._minmaxSet) 104 {} 105 106 // default destructor 107 RpNumber::~RpNumber () 108 { 109 // clean up dynamic memory 110 37 111 } 38 112 39 113 /**********************************************************************/ 40 // METHOD: setCurrentValue()41 /// Set the current value of a RpNumber object.114 // METHOD: units() 115 /// get / set the units of this number 42 116 /** 117 * get / set the units property of this object 43 118 */ 44 119 45 RpNumber& 46 RpNumber::setCurrentValue(double newCurrentVal) { 47 48 double* cur = (double*) RpVariable::getCurrentValue(); 49 double* def = (double*) RpVariable::getDefaultValue(); 50 51 if (cur == def) { 52 RpVariable::setCurrentValue(new double (newCurrentVal)); 53 } 54 else { 55 *cur = newCurrentVal; 56 } 57 58 return *this; 120 const char * 121 RpNumber::units( 122 const char *val) 123 { 124 return (const char *) property("units",val); 59 125 } 60 126 61 62 /**********************************************************************/63 // METHOD: setMin()64 /// Set the min value of a RpNumber object.65 /**66 */67 68 RpNumber&69 RpNumber::setMin(double newMin) {70 71 min = newMin;72 return *this;73 }74 75 /**********************************************************************/76 // METHOD: setMax()77 /// set the min value of a RpNumber object78 /**79 */80 81 RpNumber&82 RpNumber::setMax(double newMax) {83 84 max = newMax;85 return *this;86 }87 88 /**********************************************************************/89 // METHOD: getUnits()90 /// Report the units of the object.91 /**92 */93 94 std::string95 RpNumber::getUnits() const {96 97 return units->getUnitsName();98 }99 100 101 /**********************************************************************/102 // METHOD: getDefaultValue()103 /// Report the default value of the object.104 /**105 */106 107 double108 RpNumber::getDefaultValue(void* null_val) const {109 110 return *((double*) RpVariable::getDefaultValue());111 }112 113 /**********************************************************************/114 // METHOD: getCurrentValue()115 /// Report the current value of the object.116 /**117 */118 119 double120 RpNumber::getCurrentValue(void* null_val) const {121 122 return *((double*) RpVariable::getCurrentValue());123 }124 125 /**********************************************************************/126 // METHOD: getMin()127 /// Report the min of the object.128 /**129 */130 131 double132 RpNumber::getMin() const {133 134 return min;135 }136 137 /**********************************************************************/138 // METHOD: getMax()139 /// report the max of the object.140 /**141 */142 143 double144 RpNumber::getMax() const {145 146 return max;147 }148 127 149 128 /**********************************************************************/ … … 155 134 156 135 double 157 RpNumber::convert( std::string toUnitStr, int storeResult, int* result) {136 RpNumber::convert(const char *to) { 158 137 159 138 const RpUnits* toUnit = NULL; 160 double retVal = 0; 161 int my_result = 0; 139 const RpUnits* fromUnit = NULL; 140 double convertedVal = _current; 141 int err = 0; 162 142 163 toUnit = RpUnits::find(toUnitStr); 164 165 // set the result to the default value if it exists 166 if (result) { 167 *result = my_result; 143 // make sure all units functions accept char*'s 144 toUnit = RpUnits::find(std::string(to)); 145 if (!toUnit) { 146 // should raise error! 147 // conversion not defined because unit does not exist 148 return _current; 168 149 } 169 150 170 if (!toUnit) { 171 // should raise error! 151 fromUnit = RpUnits::find(std::string(units(NULL))); 152 if (!fromUnit) { 153 // should raise error! 172 154 // conversion not defined because unit does not exist 173 return retVal;155 return _current; 174 156 } 175 157 176 158 // perform the conversion 177 retVal = convert(toUnit,&my_result); 178 179 // check the result of the conversion and store if necessary 180 if (my_result) { 181 if (result) { 182 *result = my_result; 183 } 184 185 // check if we should store the value and change units 186 if (storeResult) { 187 // no need to deallocate old units, 188 // because they are stored in static dictionary 189 units = toUnit; 190 RpNumber::setCurrentValue(retVal); 191 } 159 convertedVal = fromUnit->convert(toUnit,_default, &err); 160 if (!err) { 161 _default = convertedVal; 192 162 } 193 163 194 return retVal; 164 convertedVal = fromUnit->convert(toUnit,_current, &err); 165 if (!err) { 166 _current = convertedVal; 167 } 168 169 if (err) { 170 convertedVal = _current; 171 } 172 173 return convertedVal; 195 174 } 196 197 /**********************************************************************/198 // METHOD: convert()199 /// Convert the number object to another unit from string.200 /**201 */202 203 double204 RpNumber::convert(std::string toUnitStr, int* result) {205 206 const RpUnits* toUnit = NULL;207 toUnit = RpUnits::find(toUnitStr);208 if (!toUnit) {209 // should raise error!210 // conversion not defined because unit does not exist211 if (result) {212 *result = -1;213 }214 return 0.0;215 }216 return convert(toUnit, result);217 }218 219 /**********************************************************************/220 // METHOD: convert()221 /// Convert the number object to another unit from RpUnits object.222 /**223 */224 225 double226 RpNumber::convert(const RpUnits* toUnit, int *result) {227 228 return units->convert(toUnit,getCurrentValue(), result);229 }230 231 /**********************************************************************/232 // METHOD: put()233 /// Store the information of this Rappture Object into the xml234 /**235 */236 //237 //RpNumber&238 //RpNumber::put() const {239 //240 //241 // return *this;242 //}243 244 175 245 176 // -------------------------------------------------------------------- // -
trunk/src/objects/RpNumber.h
r1018 r1270 1 1 /* 2 2 * ====================================================================== 3 * Copyright (c) 2004-2005 Purdue Research Foundation 3 * AUTHOR: Derrick Kearney, Purdue University 4 * Copyright (c) 2005-2009 Purdue Research Foundation 4 5 * 5 6 * See the file "license.terms" for information on usage and … … 7 8 * ====================================================================== 8 9 */ 9 #include <iostream>10 #include <string>11 #include <sstream>12 #include <stdlib.h>13 10 #include <errno.h> 14 15 16 // #include "RpLibrary.h"17 11 18 12 #ifndef _RpVARIABLE_H … … 20 14 #endif 21 15 22 #ifndef _RpUNITS_H 23 #include "RpUnits.h" 24 #endif 25 26 #ifndef _RpNUMBER_H 16 #ifndef _RpNUMBER_H 27 17 #define _RpNUMBER_H 28 18 … … 31 21 public: 32 22 33 // users member fxns 23 RpNumber ( const char *path, 24 const char *unit, 25 double val); 34 26 35 /* 36 virtual RpNumber& setUnits(std::string newUnits); 37 */ 38 39 virtual RpNumber& setDefaultValue(double newDefaultVal); 40 virtual RpNumber& setCurrentValue(double newCurrentVal); 41 virtual RpNumber& setMin(double newMin); 42 virtual RpNumber& setMax(double newMax); 43 44 std::string getUnits() const; 45 // changed from "Value" to "Val" because base class makes 46 // these functions virtual and derived class has a different 47 // return type. compiler doesnt like this. need to find another 48 // way around this 49 // 50 // if we keep the null_val=NULL will that give us undefined behavior? 51 // 52 double getDefaultValue(void* null_val=NULL) const; 53 double getCurrentValue(void* null_val=NULL) const; 54 double getMin() const; 55 double getMax() const; 56 57 double convert( std::string toUnitStr, 58 int storeResult, 59 int* result = NULL ); 60 double convert(std::string toUnitStr, int* result = NULL); 61 double convert(const RpUnits* toUnit, int* result = NULL); 62 63 // place the information from this object into the xml library 'lib' 64 // virtual RpNumber& put(RpLibrary lib); 65 RpNumber& put() const; 66 RpNumber& put(double currentVal); 67 68 69 70 /* 71 * user provides a 'path' for where this object lives in xml file 72 * user calls define with standard hints as described in Number docs 73 * 'units' - string providing units of the number 74 * 'defaultVal' - numeric value to be used if user provides no value 75 * 'min' - (optional) minimum allowed value 76 * 'max' - (optional) maximum allowed value 77 * 'label' - (optional) name of the input for a gui field 78 * 'desc' - (optional) description of the input for the gui 79 * 80 * Notes: 81 * if the user sets a min or max value the following applies: 82 * if the value of min is greater than the value of default, 83 * then min will be set to default 84 * 85 * if the value of max is less than the value of default, 86 * then max will be set to default. 87 * 88 * 89 * 90 */ 91 92 /* what about unit-less numbers */ 93 RpNumber ( 94 std::string path, 95 std::string units, 96 double defaultVal 97 ) 98 : RpVariable (path, new double (defaultVal) ), 99 // units (units), 100 min (0), 101 max (0), 102 minmaxSet (0) 103 { 104 this->units = RpUnits::find(units); 105 if (! this->units) { 106 this->units = RpUnits::define(units,NULL); 107 } 108 } 109 110 RpNumber ( 111 std::string path, 112 std::string units, 113 double defaultVal, 27 RpNumber ( const char *path, 28 const char *unit, 29 double val, 114 30 double min, 115 31 double max, 116 std::string label, 117 std::string desc 118 ) 119 : RpVariable (path, new double (defaultVal), label, desc), 120 // units (units), 121 min (min), 122 max (max), 123 minmaxSet (0) 124 { 32 const char *label, 33 const char *desc); 125 34 126 this->units = RpUnits::find(units); 127 if (! this->units) { 128 this->units = RpUnits::define(units,NULL); 129 } 35 RpNumber ( const RpNumber& o ); 36 virtual ~RpNumber (); 130 37 131 if ((min == 0) && (max == 0)) { 132 minmaxSet = 0; 133 } 134 else { 38 virtual const double defaultValue (double val); 39 virtual const double currentValue (double val); 40 virtual const double min (double val); 41 virtual const double max (double val); 42 virtual const char *units (const char *val); 43 // need to add a way to tell user conversion failed 44 virtual double convert (const char *to); 135 45 136 if (min > defaultVal) {137 this->min = defaultVal;138 }139 140 if (max < defaultVal) {141 this->max = defaultVal;142 }143 }144 145 }146 147 // copy constructor148 RpNumber ( const RpNumber& myRpNumber )149 : RpVariable(myRpNumber),150 units (myRpNumber.units),151 min (myRpNumber.min),152 max (myRpNumber.max),153 minmaxSet (myRpNumber.minmaxSet)154 {}155 156 // default destructor157 // virtual ~RpNumber ()158 virtual ~RpNumber ()159 {160 // clean up dynamic memory161 162 }163 46 private: 164 47 165 // std::string units;166 const RpUnits* units;167 double min;168 double max;48 double _default; 49 double _current; 50 double _min; 51 double _max; 169 52 170 // flag to tell if the user specified the min and max values 171 int minmaxSet; 172 53 // flag tells if user specified min and max values 54 int _minmaxSet; 173 55 }; 174 56 -
trunk/src/objects/RpVariable.cc
r1018 r1270 7 7 * ====================================================================== 8 8 * AUTHOR: Derrick Kearney, Purdue University 9 * Copyright (c) 200 4-2005Purdue Research Foundation9 * Copyright (c) 2005-2009 Purdue Research Foundation 10 10 * 11 11 * See the file "license.terms" for information on usage and … … 14 14 */ 15 15 16 #include "RpVariable.h" 16 #include <cstring> 17 #include <stdlib.h> 18 #include "RpVariable.h" 19 #include "RpHashHelper.h" 17 20 18 /**********************************************************************/ 19 // METHOD: setPath() 20 /// Set the path of this object 21 /** 22 */ 23 24 RpVariable& 25 RpVariable::setPath(std::string newPath) 21 RpVariable::RpVariable() 26 22 { 27 path = newPath; 28 return *this; 23 __init(); 29 24 } 30 25 31 /**********************************************************************/ 32 // METHOD: setDefaultValue() 33 /// Set the default value of this object 34 /** 35 */ 36 37 RpVariable& 38 RpVariable::setDefaultValue(void* newDefaultVal) 26 RpVariable::RpVariable(const RpVariable& o) 27 : 28 _path (o._path) 39 29 { 40 // who is responsible for freeing the pointer?41 defaultVal = newDefaultVal;42 return *this;30 if (o._h != NULL) { 31 Rp_HashCopy(_h,o._h,charCpyFxn); 32 } 43 33 } 44 34 45 /**********************************************************************/ 46 // METHOD: setCurrentValue() 47 /// Set the current value of this object 48 /** 49 */ 50 51 RpVariable& 52 RpVariable::setCurrentValue(void* newCurrentVal) 35 RpVariable::~RpVariable() 53 36 { 54 // who is responsible for freeing the pointer? 55 currentVal = newCurrentVal; 56 return *this; 37 __close(); 57 38 } 58 39 59 /**********************************************************************/ 60 // METHOD: setLabel() 61 /// Set the label of this object 62 /** 63 */ 64 65 RpVariable& 66 RpVariable::setLabel(std::string newLabel) 40 const char * 41 RpVariable::label( 42 const char *val) 67 43 { 68 about.setLabel(newLabel); 69 return *this; 44 return (const char *) property("label",val); 70 45 } 71 46 72 /**********************************************************************/ 73 // METHOD: setDesc() 74 /// Set the desc of this object 75 /** 76 */ 77 78 RpVariable& 79 RpVariable::setDesc(std::string newDesc) 47 const char * 48 RpVariable::desc( 49 const char *val) 80 50 { 81 about.setDesc(newDesc); 82 return *this; 51 return (const char *) property("desc",val); 83 52 } 84 53 85 /**********************************************************************/ 86 // METHOD: setHints() 87 /// Set the hints of this object 88 /** 89 */ 90 91 RpVariable& 92 RpVariable::setHints(std::string newHints) 54 const char * 55 RpVariable::hints( 56 const char *val) 93 57 { 94 about.setHints(newHints); 95 return *this; 58 return (const char *) property("hints",val); 96 59 } 97 60 98 /**********************************************************************/ 99 // METHOD: setColor() 100 /// Set the color of this object 101 /** 102 */ 103 104 RpVariable& 105 RpVariable::setColor(std::string newColor) 61 const char * 62 RpVariable::color( 63 const char *val) 106 64 { 107 about.setColor(newColor); 108 return *this; 65 return (const char *) property("color",val); 109 66 } 110 67 111 /**********************************************************************/ 112 // METHOD: setIcon() 113 /// Set the icon of this object 114 /** 115 */ 116 117 RpVariable& 118 RpVariable::setIcon(std::string newIcon) 68 const char * 69 RpVariable::icon( 70 const char *val) 119 71 { 120 about.setIcon(newIcon); 121 return *this; 72 return (const char *) property("icon",val); 122 73 } 123 74 124 125 /**********************************************************************/ 126 // METHOD: getPath() 127 /// Report the path of this object 128 /** 129 */ 130 131 std::string 132 RpVariable::getPath() const 75 const char * 76 RpVariable::path( 77 const char *val) 133 78 { 134 return path;79 return (const char *) property("path",val); 135 80 } 136 81 137 /**********************************************************************/ 138 // METHOD: getDefaultValue() 139 /// Report the default value of the object 140 /** 141 */ 82 const void * 83 RpVariable::property( 84 const char *key, 85 const void *val) 86 { 87 const void *r = NULL; 88 if (_h == NULL) { 89 // hash table does not exist, create it 90 _h = (Rp_HashTable*) malloc(sizeof(Rp_HashTable)); 91 Rp_InitHashTable(_h,RP_STRING_KEYS); 92 return NULL; 93 } 142 94 143 void* 144 RpVariable::getDefaultValue() const 145 { 146 return defaultVal; 95 if (val == NULL) { 96 // get the value 97 r = Rp_HashSearchNode(_h,key); 98 } else { 99 //set the value 100 Rp_HashRemoveNode(_h,key); 101 Rp_HashAddNode(_h,key,val); 102 r = val; 103 } 104 105 return r; 147 106 } 148 107 149 /**********************************************************************/ 150 // METHOD: getCurrentValue() 151 /// Report the current value of the object 152 /** 153 */ 154 155 void* 156 RpVariable::getCurrentValue() const 108 void 109 RpVariable::__init() 157 110 { 158 return currentVal; 111 _path = NULL; 112 _h = NULL; 159 113 } 160 114 161 /**********************************************************************/ 162 // METHOD: getLabel() 163 /// Report the label of the object 164 /** 165 */ 115 void 116 RpVariable::__close() 117 { 118 if (_path != NULL) { 119 free((void *)_path); 120 } 166 121 167 std::string 168 RpVariable::getLabel() const 169 { 170 return about.getLabel(); 171 } 122 if (_h != NULL) { 123 Rp_DeleteHashTable(_h); 124 } 172 125 173 /**********************************************************************/ 174 // METHOD: getDesc() 175 /// Report the desc of the object 176 /** 177 */ 178 179 std::string 180 RpVariable::getDesc() const 181 { 182 return about.getDesc(); 183 } 184 185 /**********************************************************************/ 186 // METHOD: getHints() 187 /// Report the hints of this object 188 /** 189 */ 190 191 std::string 192 RpVariable::getHints() const 193 { 194 return about.getHints(); 195 } 196 197 /**********************************************************************/ 198 // METHOD: getColor() 199 /// Report the color of this object 200 /** 201 */ 202 203 std::string 204 RpVariable::getColor() const 205 { 206 return about.getColor(); 207 } 208 209 /**********************************************************************/ 210 // METHOD: getIcon() 211 /// Report the icon of this object 212 /** 213 */ 214 215 std::string 216 RpVariable::getIcon() const 217 { 218 return about.getIcon(); 126 __init(); 219 127 } 220 128 -
trunk/src/objects/RpVariable.h
r1018 r1270 1 1 /* 2 2 * ====================================================================== 3 * Copyright (c) 2004-2005 Purdue Research Foundation 3 * AUTHOR: Derrick S. Kearney, Purdue University 4 * Copyright (c) 2005-2009 Purdue Research Foundation 4 5 * 5 6 * See the file "license.terms" for information on usage and … … 7 8 * ====================================================================== 8 9 */ 9 #include <iostream>10 #include <string>11 #include <sstream>12 #include <stdlib.h>13 #include <errno.h>14 10 11 #ifndef _RpVARIABLE_H 12 #define _RpVARIABLE_H 15 13 16 // #include "RpLibrary.h" 17 18 #ifndef _RpABOUT_H 19 #include "RpAbout.h" 20 #endif 21 22 #ifndef _RpVARIABLE_H 23 #define _RpVARIABLE_H 14 #include "RpInt.h" 15 #include "RpHash.h" 24 16 25 17 class RpVariable 26 18 { 27 19 public: 28 29 // users member fxns 20 RpVariable (); 21 RpVariable (const RpVariable& o); 22 virtual ~RpVariable(); 30 23 31 virtual RpVariable& setPath (std::string newPath); 32 virtual RpVariable& setDefaultValue (void* newDefaultVal); 33 virtual RpVariable& setCurrentValue (void* newCurrentVal); 34 virtual RpVariable& setLabel (std::string newLabel); 35 virtual RpVariable& setDesc (std::string newDesc); 36 virtual RpVariable& setHints (std::string newHints); 37 virtual RpVariable& setColor (std::string newColor); 38 virtual RpVariable& setIcon (std::string newIcon); 39 40 virtual std::string getPath () const; 41 /* maybe we dont need 2 get functions? */ 42 virtual void* getDefaultValue () const; 43 virtual void* getCurrentValue () const; 44 virtual std::string getLabel () const; 45 virtual std::string getDesc () const; 46 virtual std::string getHints () const; 47 virtual std::string getColor () const; 48 virtual std::string getIcon () const; 49 50 // place the information from this object into the xml library 'lib' 51 // virtual RpNumber& put(RpLibrary lib); 52 // virtual RpVariable& put() const; 53 54 // we need a copy of defaultVal in currentVal, not the same pointer. 55 // need to fix this. 56 57 RpVariable ( 58 std::string path, 59 void* defaultVal 60 ) 61 : about (RpAbout()), 62 path (path), 63 defaultVal (defaultVal), 64 currentVal (defaultVal) 65 { 66 // about's default no-arg const is called 67 }; 68 69 RpVariable ( 70 std::string path, 71 void* defaultVal, 72 std::string label, 73 std::string desc 74 ) 75 : about (RpAbout(label,desc)), 76 path (path), 77 defaultVal (defaultVal), 78 currentVal (defaultVal) 79 {} 80 81 // copy constructor 82 RpVariable ( const RpVariable& myRpVariable ) 83 // will the RpAbout copy constructor be called here? 84 : about (RpAbout(myRpVariable.about)), 85 path (myRpVariable.path), 86 defaultVal (myRpVariable.defaultVal), 87 currentVal (myRpVariable.currentVal) 88 {} 89 90 // default destructor 91 virtual ~RpVariable () 92 { 93 // clean up dynamic memory 94 } 24 virtual const char *label (const char *val); 25 virtual const char *desc (const char *val); 26 virtual const char *hints (const char *val); 27 virtual const char *color (const char *val); 28 virtual const char *icon (const char *val); 29 virtual const char *path (const char *val); 30 virtual const void *property (const char *key, const void *val); 95 31 96 32 private: 97 33 98 RpAbout about; 99 std::string path; 100 void* defaultVal; 101 void* currentVal; 34 /// path of the object in the xml tree and key in hash tables 35 const char *_path; 102 36 37 /// hash table holding other object properties 38 Rp_HashTable *_h; 103 39 40 /// initialize the object, set the data members to 0 or null 41 void __init(); 42 43 /// close out the object, freeing its memory 44 void __close(); 104 45 }; 105 46
Note: See TracChangeset
for help on using the changeset viewer.