Optika_Dependency.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_DEPENDENCY_HPP_
00029 #define OPTIKA_DEPENDENCY_HPP_
00030 #include "Teuchos_RCPDecl.hpp"
00031 #include "Teuchos_ParameterList.hpp"
00032 #include "Optika_InvalidDependencyException.hpp"
00033 namespace Optika{
00034 
00035 
00041 class Dependency{
00042 public:
00046   class DepComp{
00047   public:
00048     bool operator () (const Teuchos::RCP<Dependency> dep1, const Teuchos::RCP<Dependency> dep2) const{
00049       return dep1->getDependents().begin()->first >= dep2->getDependents().begin()->first;
00050     }
00051   };
00052 
00056   enum Type{VisualDep, ValidatorDep, NumberValidatorAspectDep, NumberArrayLengthDep};
00057 
00061   typedef std::map<const std::string, const Teuchos::RCP<Teuchos::ParameterList> > ParameterParentMap;
00062 
00070   Dependency(ParameterParentMap& dependees, ParameterParentMap& dependents, Type type);
00071 
00080   Dependency(ParameterParentMap& dependees, std::string dependentName, Teuchos::RCP<Teuchos::ParameterList> dependentParentList, Type type);
00081 
00090   Dependency(std::string dependeeName, Teuchos::RCP<Teuchos::ParameterList> dependeeParentList,
00091   ParameterParentMap& dependents, Type type);
00092 
00102   Dependency(std::string dependeeName, Teuchos::RCP<Teuchos::ParameterList> dependeeParentList,
00103   std::string dependentName, Teuchos::RCP<Teuchos::ParameterList> dependentParentList, Type type);
00104 
00110   virtual ~Dependency(){}
00111 
00121   static bool doesListContainList(Teuchos::RCP<Teuchos::ParameterList> parentList, Teuchos::RCP<Teuchos::ParameterList> listToFind);
00122 
00128   ParameterParentMap getDependees() const;
00129 
00135   ParameterParentMap getDependents() const;
00136 
00142   std::set<std::string> getDependeeNames() const;
00143 
00149   std::set<std::string> getDependentNames() const;
00150 
00156   std::string getDependeeNamesString() const;
00157 
00163   std::string getDependentNamesString() const;
00164 
00171   std::string getDependeeName(const Teuchos::ParameterEntry* dependee) const;
00172 
00178   Type getType() const;
00179 
00184   virtual void evaluate() =0;
00185 
00186 protected:
00191   ParameterParentMap dependees;
00192 
00197   ParameterParentMap dependents;
00198 
00202   std::set<std::string> dependeeNames;
00203 
00207   std::set<std::string> dependentNames;
00208 
00214   inline const Teuchos::ParameterEntry* getFirstDependee() const{
00215     return dependees.begin()->second->getEntryPtr(dependees.begin()->first);
00216   }
00217 
00223   template<class S>
00224   inline const S getFirstDependeeValue() const{
00225     return dependees.begin()->second->get<S>(dependees.begin()->first);
00226   }
00227 
00233   inline std::string getFirstDependeeName() const{
00234     return dependees.begin()->first;
00235   }
00236 
00237 private:
00241   Type type;
00242 
00247   virtual void validateDep() = 0;
00248 
00249 
00257   void intitializeDependeesAndDependents(ParameterParentMap& dependees, ParameterParentMap& dependents);
00258 };
00259 
00260 
00261 }
00262 #endif //OPTIKA_DEPENDENCY_HPP_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends
Generated on Wed Apr 13 10:05:58 2011 for Optika GUI Toolik by  doxygen 1.6.3