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

ParamSetDef.h

Go to the documentation of this file.
00001 #ifndef _PARAM_SET_H
00002 #define _PARAM_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: ParamSetDef.h,v 1.10 2010/04/27 12:20:58 htischer Exp $"
00025 *
00026 * who       when      what
00027 * --------  --------  ----------------------------------------------
00028 * sharring  10/26/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 <vector>
00037 #include <string.h>
00038 #include <stdexcept>
00039 #include <stdlib.h>
00040 #include <xercesc/dom/DOMElement.hpp>
00041 #include <xercesc/dom/DOMNode.hpp>
00042 #include <xercesc/dom/DOMBuilder.hpp>
00043 #include <xercesc/util/PlatformUtils.hpp>
00044 
00045 #include <IntParamDef.h>
00046 #include <IntArrayParamDef.h>
00047 #include <DoubleParamDef.h>
00048 #include <DoubleArrayParamDef.h>
00049 #include <StringParamDef.h>
00050 #include <StringArrayParamDef.h>
00051 #include <BoolParamDef.h>
00052 #include <ParamStrX.h>
00053 #include <parameterConstants.h>
00054 
00055 using std::auto_ptr;
00056 using std::domain_error;
00057 using std::map;
00058 using std::string;
00059 using std::vector;
00060 using XERCES_CPP_NAMESPACE_QUALIFIER DOMNodeList;
00061 using XERCES_CPP_NAMESPACE_QUALIFIER DOMElement;
00062 using XERCES_CPP_NAMESPACE_QUALIFIER DOMBuilder;
00063 
00066 namespace Parameters {
00067 
00071         class ParamSetDef
00072         {    
00073                 public:
00074                 
00075                 enum paramTypesEnum { BOOL, DOUBLE, DOUBLE_ARRAY, INT, INT_ARRAY, STRING, STRING_ARRAY};
00076 
00081                 ParamSetDef(const string & xmlParamSetDef);
00082                 
00086                 virtual ~ParamSetDef();
00087 
00094                 paramTypesEnum getParamTypeForName(string paramName);
00095 
00101                 BoolParamDef getBoolParamDef(string paramName);
00102                 
00108                 IntParamDef getIntParamDef(string paramName);
00109 
00115                 DoubleParamDef getDoubleParamDef(string paramName);
00116 
00122                 StringParamDef getStringParamDef(string paramName);
00123 
00129                 IntArrayParamDef getIntArrayParamDef(string paramName);
00130 
00136                 DoubleArrayParamDef getDoubleArrayParamDef(string paramName);
00137 
00143                 StringArrayParamDef getStringArrayParamDef(string paramName);
00144 
00148                 auto_ptr< vector<BoolParamDef> > getBoolParamDefs();
00149 
00153                 auto_ptr< vector<IntParamDef> > getIntParamDefs();
00154 
00158                 auto_ptr< vector<StringParamDef> > getStringParamDefs();
00159 
00163                 auto_ptr< vector<DoubleParamDef> > getDoubleParamDefs();
00164 
00168                 auto_ptr< vector<IntArrayParamDef> > getIntArrayParamDefs();
00169 
00173                 auto_ptr< vector<DoubleArrayParamDef> > getDoubleArrayParamDefs();
00174 
00178                 auto_ptr< vector<StringArrayParamDef> > getStringArrayParamDefs();
00179 
00180                 
00181                 private:
00182 
00183                 int parseFile(const string & xmlFile);
00184                 int parseDOM(const string & xmlFile);
00185                 int parseSAX(const string & xmlFile);
00189                 void processParamDefNodes(DOMNodeList *paramNodes);
00193                 void handleBoolParamDef(DOMElement *paramElem);
00197                 void handleIntParamDef(DOMElement *paramElem);
00201                 void handleIntArrayParamDef(DOMElement *paramElem);
00205                 void handleDoubleParamDef(DOMElement *paramElem);
00209                 void handleDoubleArrayParamDef(DOMElement *paramElem);
00213                 void handleStringParamDef(DOMElement *paramElem);
00217                 void handleStringArrayParamDef(DOMElement *paramElem);
00218                 void setSchemaLocation(DOMBuilder * parser);
00219 
00220                 map<string, BoolParamDef> boolParamDefMap;
00221                 map<string, IntParamDef> intParamDefMap;
00222                 map<string, DoubleParamDef> doubleParamDefMap;
00223                 map<string, StringParamDef> stringParamDefMap;
00224                 map<string, IntArrayParamDef> intArrayParamDefMap;
00225                 map<string, DoubleArrayParamDef> doubleArrayParamDefMap;
00226                 map<string, StringArrayParamDef> stringArrayParamDefMap;
00227 
00228                 // Constants
00229                 XMLCh* PARAMETER_TAG_NAME;
00230                 XMLCh* NAME_TAG_NAME;
00231                 XMLCh* REQUIRED_TAG_NAME;
00232                 XMLCh* PROMPT_TAG_NAME;
00233                 XMLCh* HELP_TAG_NAME;
00234                 XMLCh* DEFAULT_TAG_NAME;
00235                 XMLCh* STRING_DEFAULT_TAG_NAME;
00236                 XMLCh* LENGTH_TAG_NAME;
00237                 XMLCh* VALID_VALUES_TAG_NAME;
00238                 XMLCh* VALUE_TAG_NAME;
00239                 XMLCh* MAX_TAG_NAME;
00240                 XMLCh* MIN_TAG_NAME;
00241                 XMLCh* UNITS_TAG_NAME;
00242                 XMLCh* MAXLEN_TAG_NAME;
00243 
00244                 XMLCh* INT_PARAM_TYPE;
00245                 XMLCh* DOUBLE_PARAM_TYPE;
00246                 XMLCh* STRING_PARAM_TYPE;
00247                 XMLCh* BOOL_PARAM_TYPE;
00248                 XMLCh* INT_ARRAY_PARAM_TYPE;
00249                 XMLCh* DOUBLE_ARRAY_PARAM_TYPE;
00250                 XMLCh* STRING_ARRAY_PARAM_TYPE;
00251         };
00252 }
00253 #endif 

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