27 #ifndef SCHNEK_DEPENDENCIES_HPP_ 28 #define SCHNEK_DEPENDENCIES_HPP_ 30 #include "variables.hpp" 31 #include "blockparameters.hpp" 33 #include <boost/variant.hpp> 34 #include <boost/shared_ptr.hpp> 35 #include <boost/foreach.hpp> 43 class DependencyUpdater;
52 typedef std::set<long> DependencySet;
56 DependencySet dependsOn;
57 DependencySet modifies;
60 VarInfo(pVariable v_, DependencySet dependsOn_, DependencySet modifies_)
61 : v(v_), dependsOn(dependsOn_), modifies(modifies_), counter(0) {
66 typedef std::map<long, VarInfo> DepMap;
69 typedef std::map<long, VarInfo*> RefDepMap;
70 typedef boost::shared_ptr<RefDepMap> pRefDepMap;
72 typedef std::set<pVariable> VariableSet;
73 typedef std::list<pVariable> VariableList;
76 pBlockVariables blockVars;
82 void constructMapRecursive(
const pBlockVariables vars);
83 void constructMap(
const pBlockVariables vars);
86 void makeUpdateList(
const VariableSet &independentVars,
const VariableSet &dependentVars, VariableList &updateList);
87 pRefDepMap makeUpdatePredecessors(
const VariableSet &independentVars,
const VariableSet &dependentVars);
88 pRefDepMap makeUpdateFollowers(
const VariableSet &independentVars, pRefDepMap reverseDeps);
89 void makeUpdateOrder(pRefDepMap deps, VariableList &updateList);
93 void recreate() { constructMap(blockVars); }
94 pBlockVariables getBlockVariables();
100 typedef boost::shared_ptr<DependencyMap> pDependencyMap;
105 typedef std::set<pParameter> ParameterSet;
106 typedef std::set<pVariable> VariableSet;
107 typedef std::list<pVariable> VariableList;
109 VariableList updateList;
110 VariableSet independentVars;
111 VariableSet dependentVars;
112 ParameterSet dependentParameters;
114 pDependencyMap dependencies;
118 void addIndependent(pParameter v);
119 void addDependent(pParameter v);
120 void clearDependent();
122 template<
int rank,
template<
int>
class CheckingPolicy>
124 {
for (
int i=0; i<rank; ++i) addIndependent(v[i]); }
126 template<
int rank,
template<
int>
class CheckingPolicy>
128 {
for (
int i=0; i<rank; ++i) addDependent(v[i]); }
137 dependencies->makeUpdateList(independentVars, dependentVars, updateList);
140 BOOST_FOREACH(pVariable v, updateList) v->evaluateExpression();
141 BOOST_FOREACH(pParameter p, dependentParameters) p->update();
145 typedef boost::shared_ptr<DependencyUpdater> pDependencyUpdater;
150 #endif // SCHNEK_DEPENDENCIES_HPP_ Definition: dependencies.hpp:49
void update()
Definition: dependencies.hpp:134
Definition: dependencies.hpp:102