• Classes
  • Modules
  • Namespaces
  • Files
  • Related Pages
  • File List
  • File Members

ParameterSet.h

Go to the documentation of this file.
00001 #ifndef _PARAMETER_SET_H
00002 #define _PARAMETER_SET_H
00003 /*******************************************************************************
00004 *    ALMA - Atacama Large Millimiter Array
00005 *    (c) Associated Universities Inc., 2002 
00006 *    (c) European Southern Observatory, 2002
00007 *    Copyright by ESO (in the framework of the ALMA collaboration)
00008 *    and Cosylab 2002, All rights reserved
00009 *
00010 *    This library is free software; you can redistribute it and/or
00011 *    modify it under the terms of the GNU Lesser General Public
00012 *    License as published by the Free Software Foundation; either
00013 *    version 2.1 of the License, or (at your option) any later version.
00014 *
00015 *    This library is distributed in the hope that it will be useful,
00016 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 *    Lesser General Public License for more details.
00019 *
00020 *    You should have received a copy of the GNU Lesser General Public
00021 *    License along with this library; if not, write to the Free Software
00022 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
00023 *
00024 * "@(#) $Id: ParameterSet.h,v 1.12 2010/04/27 12:20:58 htischer Exp $"
00025 *
00026 * who       when      what
00027 * --------  --------  ----------------------------------------------
00028 * sharring  09/27/04  created
00029 */
00030 
00031 #ifndef __cplusplus
00032 #error This is a C++ include file and cannot be used from plain C
00033 #endif
00034 
00035 #include <map>
00036 #include <memory>
00037 #include <string.h>
00038 #include <stdexcept>
00039 #include <stdlib.h>
00040 #include <xercesc/dom/DOMBuilder.hpp>
00041 #include <xercesc/dom/DOMElement.hpp>
00042 #include <xercesc/dom/DOMNode.hpp>
00043 #include <xercesc/util/PlatformUtils.hpp>
00044 #include <ParamStrX.h>
00045 #include <InMemoryXmlData.h>
00046 #include <ParamSetDef.h>
00047 #include <BoolParam.h>
00048 #include <IntParam.h>
00049 #include <IntArrayParam.h>
00050 #include <DoubleArrayParam.h>
00051 #include <DoubleParam.h>
00052 #include <StringParam.h>
00053 #include <StringArrayParam.h>
00054 #include <parameterConstants.h>
00055 
00056 using std::auto_ptr;
00057 using std::domain_error;
00058 using std::invalid_argument;
00059 using std::map;
00060 using std::string;
00061 using XERCES_CPP_NAMESPACE_QUALIFIER DOMElement;
00062 using XERCES_CPP_NAMESPACE_QUALIFIER DOMNodeList;
00063 using XERCES_CPP_NAMESPACE_QUALIFIER DOMBuilder;
00064 
00067 namespace Parameters {
00068 
00072         class ParameterSet
00073         {    
00074                 public:
00075                         /********************** Constructors/Destructors ***************************/
00076 
00084                         ParameterSet(string xmlFileName);
00085 
00090                         ParameterSet(InMemoryXmlData  * fileInfo);
00091 
00095                         virtual ~ParameterSet();
00096 
00097                         /*************************** getters ***************************************/
00098 
00104                         IntParam getIntParam(string paramName);
00105 
00111                         DoubleParam getDoubleParam(string paramName);
00112 
00118                         StringParam getStringParam(string paramName);
00119 
00125                         BoolParam  getBoolParam(string paramName);
00126 
00132                         IntArrayParam getIntArrayParam(string paramName);
00133 
00139                         DoubleArrayParam getDoubleArrayParam(string paramName);
00140 
00146                         StringArrayParam getStringArrayParam(string paramName);
00147 
00148                         /*************************** setters ***************************************/
00149 
00155                         void setParam(string paramName, IntParam value);
00156 
00162                         void setParam(string paramName, DoubleParam value);
00163 
00169                         void setParam(string paramName, StringParam value);
00170 
00176                         void setParam(string paramName, BoolParam value);
00177 
00183                         void setParam(string paramName, IntArrayParam value);
00184 
00190                         void setParam(string paramName, DoubleArrayParam value);
00191 
00197                         void setParam(string paramName, StringArrayParam value);
00198 
00203                         ParamSetDef* getParamSetDef();          
00204 
00208                         string getName();
00209 
00213                         string toString();
00214 
00215                 private:
00216 
00220                         void setName(string psetName);
00221 
00226                         string getParamSetDefFileName();
00227 
00232                         void validate();
00233 
00238                         void validateBoolParams();
00243                         void validateBoolParam(BoolParamDef pDef);
00244 
00249                         void validateIntParams();
00254                         void validateIntParam(IntParamDef pDef);
00255 
00260                         void validateDoubleParams();
00265                         void validateDoubleParam(DoubleParamDef pDef);
00266 
00271                         void validateStringParams();
00276                         void validateStringParam(StringParamDef pDef);
00277 
00282                         void validateIntArrayParams();
00287                         void validateIntArrayParam(IntArrayParamDef pDef);
00288 
00293                         void validateStringArrayParams();
00298                         void validateStringArrayParam(StringArrayParamDef pDef);
00299 
00304                         void validateDoubleArrayParams();
00309                         void validateDoubleArrayParam(DoubleArrayParamDef pDef);
00310 
00314                         int parseDOM(const char* xmlParamSet, InMemoryXmlData * fileInfo);
00315                         int parseFile(const string & xmlFile);
00316                         int parseSAX(const string & xmlParamSet);
00320                         void handleBoolParam(DOMElement *paramElem);
00324                         void handleIntParam(DOMElement *paramElem);
00328                         void handleIntArrayParam(DOMElement *paramElem);
00332                         void handleDoubleParam(DOMElement *paramElem);
00336                         void handleDoubleArrayParam(DOMElement *paramElem);
00340                         void handleStringParam(DOMElement *paramElem);
00344                         void handleStringArrayParam(DOMElement *paramElem);
00348                         void processParamNodes(DOMNodeList *paramNodes);
00352                         void initialize();
00353                         void setSchemaLocation(DOMBuilder * parser);
00354 
00355                         string name;
00356                         string psetDefFileName;
00357                         map<string, IntParam> intParamMap;
00358                         map<string, IntArrayParam> intArrayParamMap;
00359                         map<string, DoubleParam> doubleParamMap;
00360                         map<string, DoubleArrayParam> doubleArrayParamMap;
00361                         map<string, StringParam> stringParamMap;
00362                         map<string, StringArrayParam> stringArrayParamMap;
00363                         map<string, BoolParam> boolParamMap;
00364 
00365                         // Constants
00366                         XMLCh* PSETDEF_TAG_NAME;
00367                         XMLCh* PARAMETER_TAG_NAME;
00368                         XMLCh* NAME_TAG_NAME;
00369                         XMLCh* VALUE_TAG_NAME;
00370                         XMLCh* UNITS_TAG_NAME;
00371 
00372                         XMLCh* INT_PARAM_TYPE;
00373                         XMLCh* DOUBLE_PARAM_TYPE;
00374                         XMLCh* STRING_PARAM_TYPE;
00375                         XMLCh* BOOL_PARAM_TYPE;
00376                         XMLCh* INT_ARRAY_PARAM_TYPE;
00377                         XMLCh* DOUBLE_ARRAY_PARAM_TYPE;
00378                         XMLCh* STRING_ARRAY_PARAM_TYPE;
00379 
00380                         auto_ptr<ParamSetDef> ParameterSetDef;
00381         };
00382 
00383 }
00384 #endif 

Generated on Thu Jan 12 2012 23:13:51 for ACS-10.0 C++ API by  doxygen 1.7.0