Teuchos - Trilinos Tools Package Version of the Day
Loading...
Searching...
No Matches
Teuchos_Dependency.cpp
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#include "Teuchos_Dependency.hpp"
11
12
13namespace Teuchos{
14
15
16Dependency::Dependency(
19 dependees_(dependees), dependents_(dependents)
20{
21 checkDependeesAndDependents();
22 createConstDependents();
23}
24
25Dependency::Dependency(
28 dependees_(dependees),
29 dependents_(ParameterEntryList(&dependent, &dependent+1))
30{
31 checkDependeesAndDependents();
32 createConstDependents();
33}
34
35
36Dependency::Dependency(
39 dependees_(ConstParameterEntryList(&dependee, &dependee+1)),
40 dependents_(dependents)
41{
42 checkDependeesAndDependents();
43 createConstDependents();
44}
45
46Dependency::Dependency(
49 dependees_(ConstParameterEntryList(&dependee, &dependee+1)),
50 dependents_(ParameterEntryList(&dependent, &dependent+1))
51{
52 checkDependeesAndDependents();
53 createConstDependents();
54}
55
56
57void Dependency::createConstDependents(){
58 for(
59 ParameterEntryList::iterator it = dependents_.begin();
60 it != dependents_.end();
61 ++it)
62 {
63 constDependents_.insert(it->getConst());
64 }
65}
66
67void Dependency::print(std::ostream& out) const{
68 out << "Type: " << getTypeAttributeValue() << std::endl;
69 out << "Number of dependees: " << dependees_.size() << std::endl;
70 out << "Number of dependents: " << dependents_.size() << std::endl;
71
72}
73
74void Dependency::checkDependeesAndDependents(){
75 ConstParameterEntryList::iterator it1 = dependees_.begin();
76 for(; it1 != dependees_.end(); ++it1){
77 TEUCHOS_TEST_FOR_EXCEPTION((*it1).is_null(),
79 "Cannot have a null dependee!" << std::endl << std::endl);
80 }
81
82 ParameterEntryList::iterator it2 = dependents_.begin();
83 for(; it2 != dependents_.end(); ++it2){
84 TEUCHOS_TEST_FOR_EXCEPTION((*it2).is_null(),
85 InvalidDependencyException,
86 "Cannot have a null dependent!" << std::endl << std::endl);
87 }
88}
89
90} //namespace Teuchos
91
virtual std::string getTypeAttributeValue() const =0
Returns the string to be used for the value of the type attribute when converting the dependency to X...
std::set< RCP< ParameterEntry >, RCPComp > ParameterEntryList
A list of Dependees.
virtual void print(std::ostream &out) const
prints out information about the dependency.
std::set< RCP< const ParameterEntry >, RCPConstComp > ConstParameterEntryList
A list of dependents.
Smart reference counting pointer class for automatic garbage collection.
RCP< const T > getConst() const
Return an RCP<const T> version of *this.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging.
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos,...