ppap4lmp  0.7.2
updater.cpp
Go to the documentation of this file.
1 
9 #include "updater.h"
10 
11 /* ------------------------------------------------------------------ */
12 
14  const int elementid)
15 {
16  bool compute_required;
17 
18  #pragma omp critical (check_skippable_elementids)
19  {
20  compute_required
21  = skippable_elementids.find(elementid) == skippable_elementids.end();
22 
23  if (compute_required)
24  {
25  skippable_elementids.insert(elementid);
26  }
27  }
28 
29  return compute_required;
30 }
31 
32 /* ------------------------------------------------------------------ */
33 
35  const ElPtr &elem,
36  const int elementid,
37  Json &data)
38 {
39  if (check_compute_request_for(elementid))
40  {
41  compute_body(elem, data);
42  }
43 }
44 
45 /* ------------------------------------------------------------------ */
46 
48  const ElPtr &elem,
49  Json &data)
50 {
51  Str myclassname
52  = abi::__cxa_demangle(typeid(*this).name(), 0, 0, new int());
53 
54  elem->accessed_by_instance_of(myclassname);
55 
56  if (ext_generator)
57  {
58  ext_generator->accessed_by_instance_of(myclassname);
59  }
60 
62  data,
63  [elem](const Json &key_)
64  {
65  elem->check_required_keys(key_);
66  },
67  [elem](const Json &key_)
68  {
69  return elem->check_optional_keys(key_);
70  });
71 }
72 
73 /* ------------------------------------------------------------------ */
74 
76  const int elementid)
77 {
78  #pragma omp critical (remove_skippable_elementid)
79  {
80  skippable_elementids.erase(elementid);
81  }
82 }
83 
84 /* ------------------------------------------------------------------ */
85 
87 {
88  return ext_generator;
89 }
virtual void compute_body(const ElPtr &elem, Json &data)=0
Managing computation to update Element::data.
ShPtr< Element > ElPtr
An alias for a shared pointer of Element class.
Definition: element.h:378
void remove_from_skippable_elementids(const int elementid)
Remove Element::elementid from skippable_elementids.
Definition: updater.cpp:75
std::string Str
Str is an alias for string.
Definition: std.h:21
const ShPtr< Generator > & get_ext_generator()
Get ext_generator of this object.
Definition: updater.cpp:86
nlohmann::json Json
Json is an alias for nlohmann::json.
Definition: json.h:22
bool check_compute_request_for(const int elementid)
Definition: updater.cpp:13
Set< int > skippable_elementids
Definition: updater.h:41
ShPtr< Generator > ext_generator
Definition: updater.h:64
virtual void compute_impl(Json &data, JsonToVoidFunc check_required_keys, JsonToBoolFunc check_optional_keys)=0
Implementation of computation updating Element::data.
std::shared_ptr< T > ShPtr
ShPtr is an alias for shared pointer.
Definition: std.h:16
void compute(const ElPtr &elem, const int elementid, Json &data)
Managing computation to update Element::data.
Definition: updater.cpp:34
virtual void compute_common(const ElPtr &elem, Json &data)
Common part of compute_body.
Definition: updater.cpp:47
This file has a definition of Updater class, which is one of the cores of this program.