Flow123d  JS_before_hm-1003-g4e68d2c
Public Member Functions | Private Attributes | List of all members
LazyDependency Class Reference

#include <lazy_dependecy.hh>

Collaboration diagram for LazyDependency:
Collaboration graph
[legend]

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_
 

Detailed Description

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.

Constructor & Destructor Documentation

LazyDependency::LazyDependency ( )
inline

Default constructor.

Definition at line 44 of file lazy_dependecy.hh.

Member Function Documentation

void LazyDependency::add_dependency ( LazyDependency object)
inline

Adds new object into dependency list. This do not update this dependency!

Parameters
object- any instance of LazyDependency

Definition at line 60 of file lazy_dependecy.hh.

bool LazyDependency::needs_update ( ) const
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.

void LazyDependency::update ( )
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.

Member Data Documentation

unsigned int LazyDependency::change_set_
private

Definition at line 77 of file lazy_dependecy.hh.

std::list<std::pair<LazyDependency &, unsigned int> > LazyDependency::dependencies_
private

Definition at line 78 of file lazy_dependecy.hh.


The documentation for this class was generated from the following file: