Flow123d
release_3.0.0-1192-gc7b86c0
|
#include <lazy_dependecy.hh>
Public Member Functions | |
LazyDependency () | |
Default constructor. More... | |
void | update () |
Increase the change set and set actual values of change sets of objects we depend on. More... | |
void | add_dependency (LazyDependency &object) |
bool | needs_update () const |
Private Attributes | |
unsigned int | change_set_ |
std::list< std::pair< LazyDependency &, unsigned int > > | dependencies_ |
This class implements lazy dependency of objects that inherits from it.
Consider you have equation E which depends on input vector fields A and B which are possibly results of another computations and can change over time. When someone ask you for result of equation E you have to look if your current result is up to date according to input fields A and B. This is purpose of this class.
How to use it: 1) make all classes in the dependency graph inherited form LazyDependency class. Multiple inheritance is OK in this case. 2) equation E should call add_dependency for A and B 3) every time you change A or B call update() 4) when you are asked for result of equation check needs_update() and update the result only if it returns true Possibly call also update() for possible objects that depends on E.
Definition at line 41 of file lazy_dependecy.hh.
|
inline |
Default constructor.
Definition at line 44 of file lazy_dependecy.hh.
|
inline |
Adds new object into dependency list. This do not update this dependency!
object | - any instance of LazyDependency |
Definition at line 60 of file lazy_dependecy.hh.
|
inline |
Returns true if there is at least one object in the dependency list that changed its change set since the last call of update().
Definition at line 68 of file lazy_dependecy.hh.
|
inline |
Increase the change set and set actual values of change sets of objects we depend on.
Definition at line 49 of file lazy_dependecy.hh.
|
private |
Definition at line 77 of file lazy_dependecy.hh.
|
private |
Definition at line 78 of file lazy_dependecy.hh.