Optika GUI Toolik Version of the Day
test/gui/datatypes/main.cpp
Go to the documentation of this file.
00001 // @HEADER
00002 // ***********************************************************************
00003 // 
00004 //         Optika: A Tool For Developing Parameter Obtaining GUIs
00005 //                Copyright (2009) Sandia Corporation
00006 // 
00007 // Under terms of Contract DE-AC04-94AL85000, with Sandia Corporation, the 
00008 // U.S. Government retains certain rights in this software.
00009 // 
00010 // This library is free software; you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as
00012 // published by the Free Software Foundation; either version 2.1 of the
00013 // License, or (at your option) any later version.
00014 //  
00015 // This library is distributed in the hope that it will be useful, but
00016 // 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
00023 // USA
00024 // Questions? Contact Kurtis Nusbaum (klnusbaum@gmail.com) 
00025 // 
00026 // ***********************************************************************
00027 // @HEADER
00028 #include "Teuchos_XMLParameterListHelpers.hpp"
00029 #include "Teuchos_VerboseObject.hpp"
00030 #include "Teuchos_FancyOStream.hpp"
00031 #include "Optika_GUI.hpp"
00032 
00033 int main(){
00034   Teuchos::RCP<Teuchos::FancyOStream> out = Teuchos::VerboseObjectBase::getDefaultOStream();
00035 
00036   Teuchos::RCP<Teuchos::ParameterList> My_List2 = Teuchos::RCP<Teuchos::ParameterList>(new Teuchos::ParameterList);
00037   Teuchos::ParameterList&
00038     validatorList = My_List2->sublist("Validator List", false, "Validator testing\nWorking June 27th 2009");
00039   Teuchos::RCP<Optika::FileNameValidator> filnameVali = 
00040     Teuchos::RCP<Optika::FileNameValidator>(new Optika::FileNameValidator);
00041   validatorList.set("filename", "", "filename tester", filnameVali);
00042   Teuchos::RCP<Optika::EnhancedNumberValidator<int> > intVali = 
00043     Teuchos::rcp(new Optika::EnhancedNumberValidator<int>(0,10,2));
00044   validatorList.set("Int", 8, "Int tester", intVali);
00045   Teuchos::RCP<Optika::EnhancedNumberValidator<short> > shortVali = 
00046     Teuchos::rcp(new Optika::EnhancedNumberValidator<short>(0,10,4));
00047   validatorList.set("Short", (short)4, "short tester", shortVali);
00048   Teuchos::RCP<Optika::EnhancedNumberValidator<float> > floatVali = 
00049     Teuchos::rcp(new Optika::EnhancedNumberValidator<float>(0,20,1e-2, 6));
00050   validatorList.set("Float", (float)4.5, "float tester", floatVali);
00051   Teuchos::RCP<Optika::EnhancedNumberValidator<double> > doubleVali = 
00052     Teuchos::rcp(new Optika::EnhancedNumberValidator<double>(0,20,1e-2, 6));
00053   validatorList.set("Double", (double)4.5, "double tester", doubleVali);
00054   Teuchos::RCP<Teuchos::StringToIntegralParameterEntryValidator<int> >
00055     solverValidator2 = Teuchos::rcp(
00056       new Teuchos::StringToIntegralParameterEntryValidator<int>(
00057         Teuchos::tuple<std::string>( "GMRES", "CG", "TFQMR" )
00058         ,"Solver"
00059         )
00060       );
00061   validatorList.set(
00062     "Solver"
00063     ,"GMRES" // This will be validated by solverValidator right here!
00064     ,"The type of solver to use."
00065     ,solverValidator2
00066     );
00067   Teuchos::Array<std::string> validValues;
00068   validValues.append("value1");
00069   validValues.append("value2");
00070   validValues.append("value3");
00071   Teuchos::RCP<Optika::StringValidator> stringVali2 = Teuchos::RCP<Optika::StringValidator>(new Optika::StringValidator(validValues));
00072   validatorList.set("Easy String", "value1", "easy string validator tester", stringVali2);
00073 
00074   Teuchos::ParameterList&
00075     NoValiList = My_List2->sublist("No validator list",false,"sublist containing data types without validators on them for checking default behavior.");
00076   NoValiList.set("Int1", 8, "Int tester");
00077   NoValiList.set("Short1", (short)4, "short tester");
00078   NoValiList.set("Float1", (float)4.5, "float tester");
00079   NoValiList.set("Double1", (double)4.5, "double tester");
00080   NoValiList.set("Bool1", true);
00081   NoValiList.set("Bool", true);
00082   NoValiList.set("Free String", "fee");
00083   
00084   //Arrays
00085   Teuchos::RCP<Optika::StringValidator> easyStringValidator = Teuchos::RCP<Optika::StringValidator>(new Optika::StringValidator(Teuchos::tuple<std::string>("value1", "value2", "value3")));
00086   Teuchos::Array<int> intArray(10,0);
00087   Teuchos::Array<short> shortArray(10,3);
00088   Teuchos::Array<float> floatArray(10,4.4);
00089   Teuchos::Array<double> doubleArray(10, 5.5);
00090   Teuchos::Array<std::string> stringArray(10,"CG");
00091   Teuchos::Array<std::string> easyStringArray(10, "value1");
00092   Teuchos::Array<std::string> freestringArray(10,"Blah");
00093   Teuchos::Array<std::string> filenameArray(3,"/net/home/f07/klnusbau/blah.txt");
00094   Teuchos::ParameterList&
00095     ArrayList = My_List2->sublist("Arrays", false, "sublist containing arrays.");
00096   ArrayList.set("IntArray", intArray, "intarray tester", Teuchos::RCP<Optika::ArrayNumberValidator<int> >(new Optika::ArrayNumberValidator<int>(intVali)));
00097   ArrayList.set("ShortArray", shortArray, "shortarray tester", Teuchos::RCP<Optika::ArrayNumberValidator<short> >(new Optika::ArrayNumberValidator<short>(shortVali)));
00098   ArrayList.set("DoubleArray", doubleArray, "doublearray tester", Teuchos::RCP<Optika::ArrayNumberValidator<double> >(new Optika::ArrayNumberValidator<double>(doubleVali)));
00099   ArrayList.set("FloatArray", floatArray, "floatarray tester", Teuchos::RCP<Optika::ArrayNumberValidator<float> >(new Optika::ArrayNumberValidator<float>(floatVali)));
00100   ArrayList.set("StringArray", stringArray, "string tester", 
00101   Teuchos::RCP<Optika::ArrayStringValidator>(new Optika::ArrayStringValidator(solverValidator2))); 
00102   ArrayList.set("EasyStringArray", easyStringArray, "testing the easy validator", Teuchos::RCP<Optika::ArrayStringValidator>(new Optika::ArrayStringValidator(easyStringValidator)));
00103   ArrayList.set("FreeStringArray", freestringArray, "free string array tester");
00104   ArrayList.set("Filename Array", filenameArray, "filename array tester",
00105     Teuchos::RCP<Optika::ArrayFileNameValidator>(new Optika::ArrayFileNameValidator(filnameVali)));
00106 
00107   Optika::getInput(My_List2);
00108   Teuchos::writeParameterListToXmlOStream(*My_List2, *out);
00109   My_List2->print(std::cout,Teuchos::ParameterList::PrintOptions().showDoc(true).indent(2).showTypes(true));
00110 
00111   return 0;
00112 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends