28 context_dependencies::context_dependencies(
const context_dependencies &cd)
30 touched(static_cast<bool>(cd.touched)),
31 dependencies(cd.dependencies),
32 dependent(cd.dependent),
37 context_dependencies::operator=(
const context_dependencies &cd) {
39 touched =
static_cast<bool>(cd.touched);
40 dependencies = cd.dependencies;
41 dependent = cd.dependent;
45 void context_dependencies::sup_dependent_
46 (
const context_dependencies &cd)
const {
47 getfem::local_guard lock = locks_.get_lock();
49 iterator_list it1 = dependent.begin(), it2 = it1, ite = dependent.end();
50 for (; it1 != ite; ++it1) {
60 void context_dependencies::sup_dependency_
61 (
const context_dependencies &cd)
const {
62 getfem::local_guard lock = locks_.get_lock();
64 iterator_list it1=dependencies.begin(), it2=it1, ite=dependencies.end();
65 for (; it1 != ite; ++it1) {
72 dependencies.resize(s);
75 void context_dependencies::invalid_context()
const {
76 if (state != CONTEXT_INVALID) {
77 for (
auto &it : dependent)
78 it->invalid_context();
79 getfem::local_guard lock = locks_.get_lock();
80 state = CONTEXT_INVALID;
84 void context_dependencies::add_dependency(
const context_dependencies &cd) {
85 cd.context_check(); cd.touched =
false;
87 getfem::local_guard lock = locks_.get_lock();
88 for (
auto &it : dependencies)
89 if (it == &cd)
return;
90 dependencies.push_back(&cd);
92 getfem::local_guard lock = cd.locks_.get_lock();
93 cd.dependent.push_back(
this);
96 bool context_dependencies::go_check()
const {
97 if (state == CONTEXT_CHANGED) {
98 for (
auto &it : dependencies) {
102 getfem::local_guard lock = locks_.get_lock();
103 state = CONTEXT_NORMAL;
104 update_from_context();
107 GMM_ASSERT1(state != CONTEXT_INVALID,
"Invalid context");
111 void context_dependencies::touch()
const {
113 for (
auto &it : dependent)
114 it->change_context();
119 void context_dependencies::clear_dependencies() {
120 for (
auto &it : dependencies)
121 it->sup_dependent_(*
this);
122 dependencies.clear();
125 context_dependencies::~context_dependencies() {
127 for (
auto &it : dependencies) it->sup_dependent_(*
this);
128 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.