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 // Teuchos: Common Tools Package
4 //
5 // Copyright 2004 NTESS and the Teuchos contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef TEUCHOS_DEPENDENCYSHEET_HPP_
11 #define TEUCHOS_DEPENDENCYSHEET_HPP_
12 
17 #include "Teuchos_Dependency.hpp"
18 
19 
20 namespace Teuchos{
21 
22 
27 class TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT DependencySheet{
28 
29 public:
30 
33 
37  typedef std::set<RCP<Dependency>, RCPComp > DepSet;
38 
44 
46 
49 
54 
60  DependencySheet(const std::string &name);
61 
63 
66 
72  void addDependency(RCP<Dependency> dependency);
73 
81  void addDependencies(RCP<DependencySheet> otherSheet);
82 
89  void removeDependency(RCP<Dependency> dependency);
90 
94  void setName(const std::string newName){
95  name_ = newName;
96  }
97 
99 
101 
102 
110  inline bool hasDependents(RCP<const ParameterEntry> dependee) const{
111  return (dependenciesMap_.find(dependee) != dependenciesMap_.end()
112  && dependenciesMap_.find(dependee)->second.size() > 0);
113  }
114 
123  RCP<const DepSet> getDependenciesForParameter(
124  RCP<const ParameterEntry> dependee) const;
125 
129  inline const std::string& getName() const{
130  return name_;
131  }
132 
136  inline bool empty() const{
137  return dependencies_.empty();
138  }
139 
141 
144 
149  inline DepSet::iterator depBegin(){
150  return dependencies_.begin();
151  }
152 
158  inline DepSet::iterator depEnd(){
159  return dependencies_.end();
160  }
161 
165  inline DepSet::const_iterator depBegin() const{
166  return dependencies_.begin();
167  }
168 
172  inline DepSet::const_iterator depEnd() const{
173  return dependencies_.end();
174  }
175 
183  inline DepSet::size_type size(){
184  return dependencies_.size();
185  }
186 
188 
191 
195  void printDeps(std::ostream& out) const;
196 
197 
200  static const std::string& getNameAttributeName(){
201  static const std::string NAME_ATTRIBUTE_NAME="name";
202  return NAME_ATTRIBUTE_NAME;
203  }
205 
206 private:
207 
210 
218  DepMap dependenciesMap_;
219 
223  DepSet dependencies_;
224 
228  std::string name_;
229 
231 
232 };
233 
234 
235 }
236 #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.