27 context_dependencies::context_dependencies(
const context_dependencies &cd)
29 touched(static_cast<bool>(cd.touched)),
30 dependencies(cd.dependencies),
31 dependent(cd.dependent),
36 context_dependencies::operator=(
const context_dependencies &cd) {
38 touched =
static_cast<bool>(cd.touched);
39 dependencies = cd.dependencies;
40 dependent = cd.dependent;
44 void context_dependencies::sup_dependent_
45 (
const context_dependencies &cd)
const {
46 getfem::local_guard lock = locks_.get_lock();
48 iterator_list it1 = dependent.begin(), it2 = it1, ite = dependent.end();
49 for (; it1 != ite; ++it1) {
59 void context_dependencies::sup_dependency_
60 (
const context_dependencies &cd)
const {
61 getfem::local_guard lock = locks_.get_lock();
63 iterator_list it1=dependencies.begin(), it2=it1, ite=dependencies.end();
64 for (; it1 != ite; ++it1) {
71 dependencies.resize(s);
74 void context_dependencies::invalid_context()
const {
75 if (state != CONTEXT_INVALID) {
76 for (
auto &it : dependent)
77 it->invalid_context();
78 getfem::local_guard lock = locks_.get_lock();
79 state = CONTEXT_INVALID;
83 void context_dependencies::add_dependency(
const context_dependencies &cd) {
84 cd.context_check(); cd.touched =
false;
86 getfem::local_guard lock = locks_.get_lock();
87 for (
auto &it : dependencies)
88 if (it == &cd)
return;
89 dependencies.push_back(&cd);
91 getfem::local_guard lock = cd.locks_.get_lock();
92 cd.dependent.push_back(
this);
95 bool context_dependencies::go_check()
const {
96 if (state == CONTEXT_CHANGED) {
97 for (
auto &it : dependencies) {
101 getfem::local_guard lock = locks_.get_lock();
102 state = CONTEXT_NORMAL;
103 update_from_context();
106 GMM_ASSERT1(state != CONTEXT_INVALID,
"Invalid context");
110 void context_dependencies::touch()
const {
112 for (
auto &it : dependent)
113 it->change_context();
118 void context_dependencies::clear_dependencies() {
119 for (
auto &it : dependencies)
120 it->sup_dependent_(*
this);
121 dependencies.clear();
124 context_dependencies::~context_dependencies() {
126 for (
auto &it : dependencies) it->sup_dependent_(*
this);
127 for (
auto &it : dependent) it->sup_dependency_(*
this);
Deal with interdependencies of objects (getfem::context_dependencies).
size_t size_type
used as the common size type in the library
GEneric Tool for Finite Element Methods.