00001 /***************************** License ********************************** 00002 00003 Copyright (C) 2008 by Communicative Machines 00004 http://www.cmlabs.com All rights reserved. 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Lesser General Public 00008 License as published by the Free Software Foundation; either 00009 version 2.1 of the License, or (at your option) any later version. 00010 00011 This library 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 GNU 00014 Lesser General Public License for more details. 00015 00016 You should have received a copy of the GNU Lesser General Public 00017 License along with this library; if not, write to the Free Software 00018 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 00020 ************************************************************************/ 00021 00022 00023 // Parameter.h: interface for the Parameter class. 00024 // 00025 ////////////////////////////////////////////////////////////////////// 00026 00027 #if !defined(AFX_PARAM_H__476CF3D1_7C74_4619_B288_79D9E3637683__INCLUDED_) 00028 #define AFX_PARAM_H__476CF3D1_7C74_4619_B288_79D9E3637683__INCLUDED_ 00029 00030 #if _MSC_VER > 1000 00031 #pragma once 00032 #endif // _MSC_VER > 1000 00033 00034 // #include "Object.h" 00035 #include "standard.h" 00036 #include "XMLParser.h" 00037 #include "Collections.h" 00038 00039 namespace cmlabs { 00040 00041 #define NOVALUE -87654321 00042 #define PARAM_ERROR -99999999 00043 00044 //! Parameters can hold a value and you can get, set, increment, decrement 00045 class Parameter : public Object 00046 { 00047 public: 00048 static ObjectDictionary* getParameterCollectionFromNode(XMLNode* node); 00049 static JString getParameterValueFromCollection(ObjectDictionary* parameters, const JString& name); 00050 00051 Parameter(const JString& parametername, const JString& type); 00052 Parameter(const JString& xml); 00053 Parameter(XMLNode* node); 00054 Parameter(const JString& parametername, const JString& type, const Collection& collValues); 00055 Parameter(const JString& parametername, const JString& type, const JString& val, const JString& defaultVal = ""); 00056 // Parameter(JString parametername, double min, double max, double incr = 0); 00057 00058 virtual ~Parameter(); 00059 00060 Object* clone() const; 00061 //! Get total size of payload 00062 virtual unsigned long getPayloadSize() const; 00063 bool unitTest(); 00064 bool fromXML(const JString& xml); 00065 bool fromXML(XMLNode* node); 00066 JString toXML(); 00067 JString print(); 00068 00069 JString name; 00070 JString value; 00071 JString defaultValue; 00072 JString valueType; 00073 JString parameterType; 00074 JString notify; 00075 double step; 00076 00077 bool locked; 00078 double minValue, maxValue; 00079 00080 bool reset(); 00081 bool increment(int steps); 00082 bool decrement(int steps); 00083 00084 JString getName(); 00085 bool setType(const JString& type); 00086 JString getType(); 00087 00088 int getInteger(); 00089 double getDouble(); 00090 JString getString(); 00091 void* getPointer(); 00092 JString getAsString(); 00093 00094 bool set(const JString& val); 00095 bool setString(const JString& val); 00096 bool setInteger(int val); 00097 bool setDouble(double val); 00098 bool setPointer(void* val); 00099 bool setMinMax(double min, double max); 00100 00101 bool addItem(const JString& value); 00102 bool removeItem(const JString& value); 00103 00104 Collection values; 00105 00106 protected: 00107 00108 int current; 00109 int def; 00110 }; 00111 00112 } // namespace cmlabs 00113 00114 #endif // !defined(AFX_PARAM_H__476CF3D1_7C74_4619_B288_79D9E3637683__INCLUDED_)