Teuchos - Trilinos Tools Package  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Teuchos_DependencySheet.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Teuchos: Common Tools Package
5 // Copyright (2004) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
38 //
39 // ***********************************************************************
40 // @HEADER
41 
42 
43 
44 #ifndef TEUCHOS_DEPENDENCYSHEET_HPP_
45 #define TEUCHOS_DEPENDENCYSHEET_HPP_
46 
51 #include "Teuchos_Dependency.hpp"
52 
53 
54 namespace Teuchos{
55 
56 
61 class TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT DependencySheet{
62 
63 public:
64 
67 
71  typedef std::set<RCP<Dependency>, RCPComp > DepSet;
72 
78 
80 
83 
88 
94  DependencySheet(const std::string &name);
95 
97 
100 
106  void addDependency(RCP<Dependency> dependency);
107 
115  void addDependencies(RCP<DependencySheet> otherSheet);
116 
123  void removeDependency(RCP<Dependency> dependency);
124 
128  void setName(const std::string newName){
129  name_ = newName;
130  }
131 
133 
135 
136 
144  inline bool hasDependents(RCP<const ParameterEntry> dependee) const{
145  return (dependenciesMap_.find(dependee) != dependenciesMap_.end()
146  && dependenciesMap_.find(dependee)->second.size() > 0);
147  }
148 
157  RCP<const DepSet> getDependenciesForParameter(
158  RCP<const ParameterEntry> dependee) const;
159 
163  inline const std::string& getName() const{
164  return name_;
165  }
166 
170  inline bool empty() const{
171  return dependencies_.empty();
172  }
173 
175 
178 
183  inline DepSet::iterator depBegin(){
184  return dependencies_.begin();
185  }
186 
192  inline DepSet::iterator depEnd(){
193  return dependencies_.end();
194  }
195 
199  inline DepSet::const_iterator depBegin() const{
200  return dependencies_.begin();
201  }
202 
206  inline DepSet::const_iterator depEnd() const{
207  return dependencies_.end();
208  }
209 
217  inline DepSet::size_type size(){
218  return dependencies_.size();
219  }
220 
222 
225 
229  void printDeps(std::ostream& out) const;
230 
231 
234  static const std::string& getNameAttributeName(){
235  static const std::string NAME_ATTRIBUTE_NAME="name";
236  return NAME_ATTRIBUTE_NAME;
237  }
239 
240 private:
241 
244 
252  DepMap dependenciesMap_;
253 
257  DepSet dependencies_;
258 
262  std::string name_;
263 
265 
266 };
267 
268 
269 }
270 #endif //TEUCHOS_DEPENDENCYSHEET_HPP_
A Dependency sheet keeps track of dependencies between various ParameterEntries.
DepSet::const_iterator depBegin() const
Returns a const iterator to the beginning of all the dependees in the sheet.
DepSet::iterator depBegin()
Returns an iterator to the beginning of all the dependees in the sheet.
Struct for comparing two RCPs. Simply compares the raw pointers contained within the RCPs...
map< RCP< const ParameterEntry >, DepSet, RCPConstComp > DepMap
Convience typedef. Maps dependee parameter entries to a set of their corresponding dependencies...
std::set< RCP< Dependency >, RCPComp > DepSet
Convience typedef representing a set of dependencies.
Struct for comparing two RCPs. Simply compares the raw pointers contained within the RCPs...
bool hasDependents(RCP< const ParameterEntry > dependee) const
Determines whether or not a parameter is depended upon by any another parameters or parameter lists...
const std::string & getName() const
Gets the name of the dependency sheet.
DepSet::size_type size()
Returns the number of Dependencies in this DependencySheet.
bool empty() const
Determines whether or not this dependency sheet has any dependencies.
DepSet::const_iterator depEnd() const
Returns a const iterator to the end of all of the dependees in the sheet.
void setName(const std::string newName)
sets the name of the dependency sheet
Smart reference counting pointer class for automatic garbage collection.
This class creates a basic std::map object for platforms where the std::map is deficient, otherwise the std::map is injected into the Teuchos namespace.
static const std::string & getNameAttributeName()
When serializing to XML, this string should be used as the name of the name attribute.