Optika GUI Toolik Version of the Day
Optika_StandardDependencies.hpp
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 #ifndef OPTIKA_STANDARDDEPENDCIES_HPP_
00029 #define OPTIKA_STANDARDDEPENDCIES_HPP_
00030 #include "Optika_Dependency.hpp"
00031 #include "Optika_SpecificParameterEntryValidators.hpp"
00032 #include "Optika_Condition.hpp"
00033 
00034 namespace Optika{
00035 
00044 class VisualDependency : public Dependency{
00045 public:
00055   VisualDependency(std::string dependeeName, Teuchos::RCP<Teuchos::ParameterList> dependeeParentList,
00056   std::string dependentName, Teuchos::RCP<Teuchos::ParameterList> dependentParentList, bool showIf=true);
00057 
00066   VisualDependency(std::string dependeeName, Teuchos::RCP<Teuchos::ParameterList> dependeeParentList,
00067   ParameterParentMap dependents, bool showIf=true);
00068 
00077   VisualDependency(ParameterParentMap dependees, std::string dependentName, Teuchos::RCP<Teuchos::ParameterList> dependentParentList, bool showIf=true);
00078 
00086   VisualDependency(ParameterParentMap dependees, ParameterParentMap dependents, bool showIf=true);
00087 
00095   VisualDependency(std::string dependeeName, Teuchos::RCP<Teuchos::ParameterList> dependeeParentList,
00096   ParameterParentMap dependents);
00097 
00105   VisualDependency(ParameterParentMap dependees, std::string dependentName, Teuchos::RCP<Teuchos::ParameterList> dependentParentList);
00106 
00113   VisualDependency(ParameterParentMap dependees, ParameterParentMap dependents);
00114 
00120   virtual ~VisualDependency(){}
00121 
00122   virtual void evaluate() = 0;
00123 
00127   bool isDependentVisible();
00128 
00129 protected:
00130 
00134   bool dependentVisible;
00135 
00139   bool showIf;
00140 
00141 private:
00142   virtual void validateDep() = 0;
00143 };
00144 
00145 
00149 class ValidatorDependency : public Dependency{
00150 public:
00159   ValidatorDependency(std::string dependeeName, Teuchos::RCP<Teuchos::ParameterList> dependeeParentList,
00160   std::string dependentName, Teuchos::RCP<Teuchos::ParameterList> dependentParentList);
00161 
00169   ValidatorDependency(std::string dependeeName, Teuchos::RCP<Teuchos::ParameterList> dependeeParentList,
00170   ParameterParentMap dependents);
00171 
00177   virtual ~ValidatorDependency(){}
00178 
00179   virtual void evaluate() = 0;
00180 
00181 private:
00182   virtual void validateDep() = 0;
00183 
00184 };
00185 
00193 class StringVisualDependency : public VisualDependency{
00194 public:
00198   typedef Teuchos::Array<std::string> ValueList; 
00199 
00211   StringVisualDependency(std::string dependeeName, Teuchos::RCP<Teuchos::ParameterList> dependeeParentList,
00212   std::string dependentName, Teuchos::RCP<Teuchos::ParameterList> dependentParentList, std::string value, bool showIf=true);
00213 
00224   StringVisualDependency(std::string dependeeName, std::string dependentName, Teuchos::RCP<Teuchos::ParameterList> parentList, 
00225   std::string value, bool showIf=true);
00226 
00238   StringVisualDependency(std::string dependeeName, Teuchos::RCP<Teuchos::ParameterList> dependeeParentList,
00239   std::string dependentName, Teuchos::RCP<Teuchos::ParameterList> dependentParentList, const ValueList& values, bool showIf=true);
00240 
00251   StringVisualDependency(std::string dependeeName, std::string dependentName, Teuchos::RCP<Teuchos::ParameterList> parentList, 
00252   const ValueList& values, bool showIf=true);
00253 
00264   StringVisualDependency(std::string dependeeName, Teuchos::RCP<Teuchos::ParameterList> dependeeParentList,
00265   ParameterParentMap dependents, std::string value, bool showIf=true);
00266 
00277   StringVisualDependency(std::string dependeeName, Teuchos::RCP<Teuchos::ParameterList> dependeeParentList,
00278   ParameterParentMap dependents, const ValueList& values, bool showIf=true);
00279 
00280   void evaluate();
00281 
00282 private:
00286   const ValueList values;
00287 
00288   void validateDep();
00289 };
00290 
00298 class BoolVisualDependency : public VisualDependency{
00299 public:
00310   BoolVisualDependency(std::string dependeeName, Teuchos::RCP<Teuchos::ParameterList> dependeeParentList,
00311   std::string dependentName, Teuchos::RCP<Teuchos::ParameterList> dependentParentList, bool showIf=true);
00312 
00322   BoolVisualDependency(std::string dependeeName, std::string dependentName, Teuchos::RCP<Teuchos::ParameterList> parentList, 
00323   bool showIf=true);
00324 
00334   BoolVisualDependency(std::string dependeeName, Teuchos::RCP<Teuchos::ParameterList> dependeeParentList,
00335   ParameterParentMap dependents, bool showIf=true);
00336 
00337   void evaluate();
00338 
00339   void validateDep();
00340 };
00341 
00350 class ConditionVisualDependency : public VisualDependency{
00351 public:
00363   ConditionVisualDependency(Teuchos::RCP<Condition> condition,
00364   std::string dependentName, Teuchos::RCP<Teuchos::ParameterList> dependentParentList, bool showIf=true);
00365 
00375   ConditionVisualDependency(Teuchos::RCP<Condition> condition, ParameterParentMap dependents, bool showIf=true);
00376 
00377   void evaluate();
00378 
00379   void validateDep();
00380 
00381 private:
00385   Teuchos::RCP<Condition> condition;
00386 };
00387 
00395 template <class S>
00396 class NumberVisualDependency : public VisualDependency{
00397 public:
00412   NumberVisualDependency(std::string dependeeName, Teuchos::RCP<Teuchos::ParameterList> dependeeParentList,
00413   std::string dependentName, Teuchos::RCP<Teuchos::ParameterList> dependentParentList, S (*func)(S) =0)
00414     :VisualDependency(dependeeName, dependeeParentList, dependentName, dependentParentList), func(func)
00415   {
00416     validateDep();
00417   }
00418 
00432   NumberVisualDependency(std::string dependeeName, std::string dependentName, Teuchos::RCP<Teuchos::ParameterList> parentList, S 
00433   (*func)(S) =0)
00434     :VisualDependency(dependeeName, parentList, dependentName, parentList), func(func)
00435   {
00436     validateDep();
00437   }
00438 
00452   NumberVisualDependency(std::string dependeeName, Teuchos::RCP<Teuchos::ParameterList> dependeeParentList,
00453   ParameterParentMap dependents, S (*func)(S) =0)
00454     :VisualDependency(dependeeName, dependeeParentList, dependents), func(func)
00455   {
00456     validateDep();
00457   }
00458 
00459   void evaluate(){
00460     S functionVal = runFunction(getFirstDependeeValue<S>());
00461     functionVal > 0 ? dependentVisible = true : dependentVisible = false;
00462   }
00463 
00464 private:
00469   S (*func)(S);
00470 
00479   S runFunction(S argument) const{
00480     if(func !=0)
00481       return (*func)(argument);
00482     else
00483       return argument;
00484   } 
00485 
00486   void validateDep(){
00487     /*
00488      * This error should never get thrown, unless someone
00489      * is doing something wonky in a sublcass.
00490      */
00491     if(dependees.size() != 1){
00492       throw InvalidDependencyException("Uh oh. Looks like you tried to make a " 
00493       "Number Visual Dependency doesn't have exactly one dependee. This is kind of a problem. " 
00494       "You should probably take a look into it. I'm actually amazed you even threw this error. You must "
00495       "be doing some subclassing you sly-dog ;)\n\n" 
00496       "Error: A Number Visual Dependency must have exactly 1 dependee. " 
00497       "You have tried to assign it " + QString::number(dependees.size()).toStdString() + " dependees.\n" 
00498       "Dependees: " + getDependeeNamesString() + "\n" 
00499       "Dependents: " + getDependentNamesString());
00500     }
00501     const Teuchos::ParameterEntry* dependee = getFirstDependee();
00502     if(!dependee->isType<int>()
00503     && !dependee->isType<short>()
00504     && !dependee->isType<double>()
00505     && !dependee->isType<float>()){
00506       throw InvalidDependencyException("The dependee of a "
00507       "Number Visual Dependency must be of a supported number type!\n"
00508       "Problem dependee: " + getFirstDependeeName() + "\n"
00509       "Actual type: " + dependee->getAny().typeName() + "\n"
00510       "Dependees: " + getDependeeNamesString() + "\n"
00511       "Dependents: " + getDependentNamesString());
00512     }
00513   }
00514 };
00515 
00533 template <class S>
00534 class NumberValidatorAspectDependency : public Dependency{
00535 public:
00540   enum ValidatorAspect{
00541     Min,
00542     Max,
00543     Step
00544   };
00545 
00558   NumberValidatorAspectDependency(std::string dependeeName, Teuchos::RCP<Teuchos::ParameterList> dependeeParentList,
00559   std::string dependentName, Teuchos::RCP<Teuchos::ParameterList> dependentParentList, 
00560   Teuchos::RCP<Optika::EnhancedNumberValidator<S> > validator,
00561   ValidatorAspect aspect, S (*func)(S) =0)
00562     :Dependency(dependeeName, dependeeParentList, dependentName, dependentParentList, Dependency::NumberValidatorAspectDep),
00563     aspect(aspect),
00564     validator(validator),
00565     func(func)
00566 
00567   {
00568     validateDep();
00569   }
00570 
00582   NumberValidatorAspectDependency(std::string dependeeName, std::string dependentName, 
00583   Teuchos::RCP<Teuchos::ParameterList> parentList, 
00584   Teuchos::RCP<Optika::EnhancedNumberValidator<S> > validator,
00585   ValidatorAspect aspect, S (*func)(S) =0)
00586     :NumberValidatorAspectDependency(dependeeName, parentList, dependentName, parentList, validator, aspect, func) {}
00587 
00600   NumberValidatorAspectDependency(std::string dependeeName, Teuchos::RCP<Teuchos::ParameterList> dependeeParentList,
00601   std::string dependentName, Teuchos::RCP<Teuchos::ParameterList> dependentParentList, 
00602   Teuchos::RCP<Optika::ArrayNumberValidator<S> > validator,
00603   ValidatorAspect aspect, S (*func)(S) =0)
00604     :Dependency(dependeeName, dependeeParentList, dependentName, dependentParentList, Dependency::NumberValidatorAspectDep),
00605     aspect(aspect),
00606     validator(validator->getPrototype()),
00607     func(func)
00608   {
00609     validateDep();
00610   }
00611 
00623   NumberValidatorAspectDependency(std::string dependeeName, std::string dependentName, 
00624   Teuchos::RCP<Teuchos::ParameterList> parentList,
00625   Teuchos::RCP<Optika::ArrayNumberValidator<S> > validator,
00626   ValidatorAspect aspect, S (*func)(S) =0)
00627     :Dependency(dependeeName, parentList, dependentName, parentList, Dependency::NumberValidatorAspectDep),
00628     aspect(aspect),
00629     validator(validator),
00630     func(func)
00631 
00632   {
00633     validateDep();
00634   }
00635 
00647   NumberValidatorAspectDependency(std::string dependeeName, Teuchos::RCP<Teuchos::ParameterList> dependeeParentList,
00648   ParameterParentMap dependents, 
00649   Teuchos::RCP<Optika::EnhancedNumberValidator<S> > validator,
00650   ValidatorAspect aspect, S (*func)(S) =0)
00651     :Dependency(dependeeName, dependeeParentList, dependents, Dependency::NumberValidatorAspectDep),
00652     aspect(aspect),
00653     validator(validator),
00654     func(func)
00655 
00656   {
00657     validateDep();
00658   }
00659 
00671   NumberValidatorAspectDependency(std::string dependeeName, Teuchos::RCP<Teuchos::ParameterList> dependeeParentList,
00672   ParameterParentMap dependents,
00673   Teuchos::RCP<Optika::ArrayNumberValidator<S> > validator,
00674   ValidatorAspect aspect, S (*func)(S) =0)
00675     :Dependency(dependeeName, dependeeParentList, dependents, Dependency::NumberValidatorAspectDep),
00676     aspect(aspect),
00677     validator(validator->getPrototype()),
00678     func(func)
00679   {
00680     validateDep();
00681   }
00682 
00683   void evaluate(){
00684     S newAspectValue = runFunction(getFirstDependeeValue<S>());
00685     switch(aspect){
00686       case NumberValidatorAspectDependency<S>::Min:
00687         validator->setMin(newAspectValue);
00688         break;
00689       case NumberValidatorAspectDependency<S>::Max:
00690         validator->setMax(newAspectValue);
00691         break;
00692       case NumberValidatorAspectDependency<S>::Step:
00693         validator->setStep(newAspectValue);
00694         break;
00695     }
00696   }
00697 
00698 private:
00702   ValidatorAspect aspect;
00703 
00707   Teuchos::RCP<Optika::EnhancedNumberValidator<S> > validator;
00708 
00713   S (*func)(S);
00714   
00722   S runFunction(S argument) const{
00723     if(func !=0)
00724       return (*func)(argument);
00725     else
00726       return argument;
00727   } 
00728 
00729   void validateDep(){
00730     /*
00731      * This error should never get thrown, unless someone
00732      * is doing something wonky in a sublcass.
00733      */
00734     if(dependees.size() != 1){
00735       throw InvalidDependencyException("Uh oh. Looks like you tried to make a "
00736       "Number Visual Dependency doesn't have exactly one dependee. This is kind of a problem. " 
00737       "You should probably take a look into it. I'm actually amazed you even threw this error. You must "
00738       "be doing some subclassing you sly-dog ;)\n\n" 
00739       "Error: A Number Visual Dependency must have exactly 1 dependee. " 
00740       "You have tried to assign it "+ QString::number(dependees.size()).toStdString() + " dependees.\n" 
00741       "Dependees: " + getDependeeNamesString() + "\n" 
00742       "Dependents: " + getDependentNamesString());
00743     }
00744 
00745     const Teuchos::ParameterEntry* dependee = getFirstDependee();
00746     std::string dependeeName = getFirstDependeeName();
00747     if(!dependee->isType<int>()
00748     && !dependee->isType<short>()
00749     && !dependee->isType<double>()
00750     && !dependee->isType<float>()){
00751       throw InvalidDependencyException("The dependee of a "
00752       "Number Validator Aspect Dependency must be of a supported number type!\n"
00753       "Problem dependee: " + dependeeName + "\n"
00754       "Actual type: " + dependee->getAny().typeName() + "\n"
00755       "Dependents: " + getDependentNamesString());
00756     }
00757 
00758     if(typeid(S) != dependee->getAny().type()){
00759       throw InvalidDependencyException("The dependee type and EnhancedNumberValidator "
00760       "template type must all be the same for a Number Validator Aspect Dependency.\n"
00761       "Problem Dependee: " + dependeeName + "\n"
00762       "Dependee Type: " + dependee->getAny().typeName() + "\n"
00763       "Validator Template Type: " + typeid(S).name());
00764     }
00765 
00766     typename ParameterParentMap::const_iterator it;
00767     Teuchos::ParameterEntry *currentDependent;
00768     for(it = dependents.begin(); it != dependents.end(); ++it){ 
00769       currentDependent = it->second->getEntryPtr(it->first);
00770       if(currentDependent->validator() == Teuchos::null){
00771         throw InvalidDependencyException("The dependent of an "
00772         "Number Validator Aspect Dependency must have an EnhancedNumberValidator "
00773         "or an ArrayNumberValidator\n"
00774         "Problem dependent: " + it->first + "\n" 
00775         "Dependees: " + getDependeeNamesString() + "\n"
00776         "Dependents: " + getDependentNamesString());
00777       }
00778       if(validator != currentDependent->validator()){
00779         throw InvalidDependencyException("The dependent's validator and the validator specified "
00780         "in the constructor must be the same for a Number Validator Aspect Dependency!\n"
00781         "Problem dependent: " + it->first + "\n" 
00782         "Dependees: " + getDependeeNamesString() + "\n"
00783         "Dependents: " + getDependentNamesString());
00784       }
00785       if(typeid(S) != currentDependent->getAny().type()){
00786         throw InvalidDependencyException("The dependent type and EnhancedNumberValidator "
00787         "template type must all be the same for a Number Validator Aspect Dependency.\n"
00788         "Dependent: " + it->first + "\n" 
00789         "Dependent Type: " + currentDependent->getAny().typeName() + "\n"
00790         "Validator Template Type: " + typeid(S).name());
00791       }
00792     }
00793   }
00794 };
00795 
00806 class NumberArrayLengthDependency : public Dependency{
00807 public:
00818   NumberArrayLengthDependency(std::string dependeeName, Teuchos::RCP<Teuchos::ParameterList> dependeeParentList,
00819   std::string dependentName, Teuchos::RCP<Teuchos::ParameterList> dependentParentList, int (*func)(int) = 0);
00820 
00830   NumberArrayLengthDependency(std::string dependeeName, std::string dependentName, 
00831   Teuchos::RCP<Teuchos::ParameterList> parentList, int (*func)(int) = 0);
00832 
00842   NumberArrayLengthDependency(std::string dependeeName, Teuchos::RCP<Teuchos::ParameterList> dependeeParentList,
00843   ParameterParentMap dependents, int (*func)(int) = 0);
00844   
00845   void evaluate();
00846 
00847 private:
00852   int (*func)(int);
00853   
00861   int runFunction(int argument) const;
00862 
00869   template <class S>
00870   void modifyArrayLength(int newLength, Teuchos::ParameterEntry* dependentToModify);
00871 
00872   void validateDep();
00873 };
00874 
00888 class StringValidatorDependency : public ValidatorDependency{
00889 public:
00893   typedef std::map<std::string, Teuchos::RCP<const Teuchos::ParameterEntryValidator> > ValueToValidatorMap;
00894 
00907   StringValidatorDependency(std::string dependeeName, Teuchos::RCP<Teuchos::ParameterList> dependeeParentList,
00908   std::string dependentName, Teuchos::RCP<Teuchos::ParameterList> dependentParentList,  ValueToValidatorMap valuesAndValidators, 
00909   Teuchos::RCP<Teuchos::ParameterEntryValidator> defaultValidator);
00910 
00922   StringValidatorDependency(std::string dependeeName, std::string dependentName, 
00923   Teuchos::RCP<Teuchos::ParameterList> parentList,  ValueToValidatorMap valuesAndValidators, 
00924   Teuchos::RCP<Teuchos::ParameterEntryValidator> defaultValidator);
00925 
00937   StringValidatorDependency(std::string dependeeName, Teuchos::RCP<Teuchos::ParameterList> dependeeParentList,
00938   ParameterParentMap dependents,  ValueToValidatorMap valuesAndValidators, 
00939   Teuchos::RCP<Teuchos::ParameterEntryValidator> defaultValidator);
00940 
00941 
00942   void evaluate();
00943 
00944 private:
00949   Teuchos::RCP<Teuchos::ParameterEntryValidator> defaultValidator;
00950 
00955   ValueToValidatorMap valuesAndValidators;
00956   
00957   void validateDep();
00958 };
00959 
00973 class BoolValidatorDependency : public ValidatorDependency{
00974 public:
00985   BoolValidatorDependency(std::string dependeeName, Teuchos::RCP<Teuchos::ParameterList> dependeeParentList,
00986   std::string dependentName, Teuchos::RCP<Teuchos::ParameterList> dependentParentList,
00987   Teuchos::RCP<const Teuchos::ParameterEntryValidator> trueValidator,
00988   Teuchos::RCP<const Teuchos::ParameterEntryValidator> falseValidator);
00989 
00999   BoolValidatorDependency(std::string dependeeName, 
01000   std::string dependentName, Teuchos::RCP<Teuchos::ParameterList> parentList,
01001   Teuchos::RCP<const Teuchos::ParameterEntryValidator> trueValidator,
01002   Teuchos::RCP<const Teuchos::ParameterEntryValidator> falseValidator);
01003 
01013   BoolValidatorDependency(std::string dependeeName, Teuchos::RCP<Teuchos::ParameterList> dependeeParentList,
01014   ParameterParentMap dependents,
01015   Teuchos::RCP<const Teuchos::ParameterEntryValidator> trueValidator,
01016   Teuchos::RCP<const Teuchos::ParameterEntryValidator> falseValidator);
01017 
01018   void evaluate();
01019 
01020 private:
01025   Teuchos::RCP<const Teuchos::ParameterEntryValidator> trueValidator, falseValidator;
01026 
01027   void validateDep();
01028 };
01029 
01030 
01048 template<class S>
01049 class RangeValidatorDependency : public ValidatorDependency{
01050 public:
01054   typedef std::pair<S,S> Range;
01055   typedef std::map<Range, Teuchos::RCP<const Teuchos::ParameterEntryValidator> > RangeToValidatorMap;
01056 
01069   RangeValidatorDependency(std::string dependeeName, Teuchos::RCP<Teuchos::ParameterList> dependeeParentList,
01070   std::string dependentName, Teuchos::RCP<Teuchos::ParameterList> dependentParentList, RangeToValidatorMap rangesAndValidators,
01071   Teuchos::RCP<Teuchos::ParameterEntryValidator> defaultValidator)
01072     :ValidatorDependency(dependeeName, dependeeParentList, dependentName, dependentParentList),
01073     defaultValidator(defaultValidator),
01074     rangesAndValidators(rangesAndValidators)
01075   {
01076     validateDep();
01077   }
01078 
01090   RangeValidatorDependency(std::string dependeeName, std::string dependentName, 
01091   Teuchos::RCP<Teuchos::ParameterList> parentList, RangeToValidatorMap rangesAndValidators,
01092   Teuchos::RCP<Teuchos::ParameterEntryValidator> defaultValidator)
01093     :ValidatorDependency(dependeeName, parentList, dependentName, parentList),
01094     defaultValidator(defaultValidator),
01095     rangesAndValidators(rangesAndValidators)
01096   {
01097     validateDep();
01098   }
01099 
01111   RangeValidatorDependency(std::string dependeeName, Teuchos::RCP<Teuchos::ParameterList> dependeeParentList,
01112   ParameterParentMap dependents, RangeToValidatorMap rangesAndValidators,
01113   Teuchos::RCP<Teuchos::ParameterEntryValidator> defaultValidator)
01114     :ValidatorDependency(dependeeName, dependeeParentList, dependents),
01115     defaultValidator(defaultValidator),
01116     rangesAndValidators(rangesAndValidators)
01117   {
01118     validateDep();
01119   }
01120 
01121   void evaluate(){
01122     typename RangeToValidatorMap::const_iterator it;
01123     S dependeeValue = getFirstDependeeValue<S>();
01124     for(it = rangesAndValidators.begin(); it != rangesAndValidators.end(); ++it){
01125       S min = it->first.first;
01126       S max = it->first.second;
01127       if(dependeeValue >= min && dependeeValue <=max){
01128         typename ParameterParentMap::iterator it2;
01129         Teuchos::ParameterEntry *currentDependent;
01130         for(it2 = dependents.begin(); it2 != dependents.end(); ++it2){ 
01131           currentDependent = it2->second->getEntryPtr(it2->first);
01132           currentDependent->setValidator(it->second);
01133         }
01134         return;
01135       }
01136     }
01137 
01138   }
01139 private:
01143   Teuchos::RCP<const Teuchos::ParameterEntryValidator> defaultValidator;
01144 
01148   RangeToValidatorMap rangesAndValidators;
01149   
01150   void validateDep(){
01151     /*
01152      * This error should never get thrown, unless someone
01153      * is doing something wonky in a sublcass.
01154      */
01155     if(dependees.size() != 1){
01156       throw InvalidDependencyException("Uh oh. Looks like you tried to make a "
01157       "Number Visual Dependency doesn't have exactly one dependee. This is kind of a problem. "
01158       "You should probably take a look into it. I'm actually amazed you even threw this error. You must "
01159       "be doing some subclassing you sly-dog ;)\n\n" 
01160       "Error: A Number Visual Dependency must have exactly 1 dependee. "
01161       "You have tried to assign it "+ QString::number(dependees.size()).toStdString() + " dependees.\n"
01162       "Dependees: " + getDependeeNamesString() + "\n" 
01163       "Dependents: " + getDependentNamesString());
01164     }
01165 
01166     const Teuchos::ParameterEntry* dependee = getFirstDependee();
01167     std::string dependeeName = getFirstDependeeName();
01168     if(!dependee->isType<int>()
01169     && !dependee->isType<short>()
01170     && !dependee->isType<double>()
01171     && !dependee->isType<float>()){
01172       throw InvalidDependencyException("The dependee of a "
01173       "Range Validator Dependency must be of a supported number type!\n"
01174       "Problem dependee: " + dependeeName + "\n"
01175       "Actual type: " + dependee->getAny().typeName() + "\n"
01176       "Dependents: " + getDependentNamesString());
01177     }
01178 
01179     typename RangeToValidatorMap::const_iterator it;
01180     for(it = rangesAndValidators.begin(); it != rangesAndValidators.end(); ++it){
01181       typename ParameterParentMap::const_iterator it2;
01182       Teuchos::ParameterEntry *currentDependent;
01183       for(it2 = dependents.begin(); it2 != dependents.end(); ++it2){ 
01184         currentDependent = it2->second->getEntryPtr(it2->first);
01185         if(typeid(*(currentDependent->validator().get())) != typeid(*(it->second.get()))){
01186           throw InvalidDependencyException("The validator of a dependent of a "
01187           "Range Validator Dependency must be the same type as all of the validators "
01188           "in the rangesAndValidators map.\n"
01189           "Note this means that the dependent must have an initial validator.\n"
01190           "Problem dependent: " + it2->first + "\n"
01191           "Validator Type: " + typeid(*(currentDependent->validator())).name() + "\n"
01192           "One of the validators in the rangesAndValidators map is of type: " + typeid(*(it->second)).name());
01193         }
01194       }
01195     }
01196   }
01197 };
01198 
01199 
01200 }
01201 #endif //OPTIKA_STANDARDDEPENDCIES_HPP_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends