Anchors
C++ library for Incremental Computing
anchors::Engine Class Reference

Engine is the brain of Anchors, containing the necessary functions and data to retrieve the value of an Anchor object. More...

#include <engine.h>

Public Member Functions

 Engine ()
 Creates an instance of the Engine class.
 
template<typename T >
get (const AnchorPtr< T > &anchor)
 Returns the value of the given Anchor. More...
 
template<typename T >
void set (AnchorPtr< T > &anchor, T val)
 Sets the value of the given Anchor. More...
 
template<typename T >
void observe (AnchorPtr< T > &anchor)
 Marks an Anchor as observed. More...
 
template<typename T >
void observe (std::vector< AnchorPtr< T > > &anchors)
 Marks a vector of Anchors with the same type as observed. More...
 
template<typename T >
void unobserve (AnchorPtr< T > &anchor)
 Marks an Anchor as unobserved. More...
 

Detailed Description

Engine is the brain of Anchors, containing the necessary functions and data to retrieve the value of an Anchor object.

Note that this class is not thread-safe.

Member Function Documentation

◆ get()

template<typename T >
T anchors::Engine::get ( const AnchorPtr< T > &  anchor)

Returns the value of the given Anchor.

This function is only guaranteed to return the latest value of an Anchor marked observed using observe().

For an unobserved Anchor, it may return a stale value—if the Anchor was created with a value or has been computed before—or an undefined value if the Anchor was created with a function e.g. using Anchors::map, and has not been computed before.

Template Parameters
T- type of the Anchor value.
Parameters
anchor- input Anchor.
Returns
the current value of the input Anchor.

◆ observe() [1/2]

template<typename T >
void anchors::Engine::observe ( AnchorPtr< T > &  anchor)

Marks an Anchor as observed.

An observed Anchor is guaranteed to be up to date when you retrieve its value.

Template Parameters
T- type of the Anchor value.
Parameters
anchor- input Anchor.

◆ observe() [2/2]

template<typename T >
void anchors::Engine::observe ( std::vector< AnchorPtr< T > > &  anchors)

Marks a vector of Anchors with the same type as observed.

Template Parameters
T- type of the Anchors.
Parameters
anchors- input Anchors.

◆ set()

template<typename T >
void anchors::Engine::set ( AnchorPtr< T > &  anchor,
val 
)

Sets the value of the given Anchor.

If the provided value is different from the current value of the Anchor, any observed Anchors that depends on the given Anchor will return an up-to-date value when its value is retrieved using get().

Template Parameters
T- type of the Anchor value.
Parameters
anchor- input Anchor.
val- new value of the Anchor.

◆ unobserve()

template<typename T >
void anchors::Engine::unobserve ( AnchorPtr< T > &  anchor)

Marks an Anchor as unobserved.

Template Parameters
T- type of the Anchor value.
Parameters
anchor- input Anchor.

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