inkcpp
Loading...
Searching...
No Matches
ink::runtime::globals_interface Class Referenceabstract

Represents a global store to be shared amongst ink runners. More...

#include <globals.h>

Public Member Functions

template<typename T >
optional< T > get (const char *name) const
 Access global variable of Ink runner.
 
template<typename T >
bool set (const char *name, const T &val)
 Write new value in global store.
 
template<typename F >
void observe (const char *name, F callback)
 Observers global variable.
 
virtual snapshotcreate_snapshot () const =0
 create a snapshot of the current runtime state.
 
Instanciations
template<>
optional< valueget (const char *name) const
 getter and setter instanciations for supported types
 
template<>
bool set (const char *name, const value &val)
 getter and setter instanciations for supported types
 
template<>
optional< bool > get (const char *name) const
 getter and setter instanciations for supported types
 
template<>
bool set (const char *name, const bool &val)
 getter and setter instanciations for supported types
 
template<>
optional< uint32_tget (const char *name) const
 getter and setter instanciations for supported types
 
template<>
bool set (const char *name, const uint32_t &val)
 getter and setter instanciations for supported types
 
template<>
optional< int32_t > get (const char *name) const
 getter and setter instanciations for supported types
 
template<>
bool set (const char *name, const int32_t &val)
 getter and setter instanciations for supported types
 
template<>
optional< float > get (const char *name) const
 getter and setter instanciations for supported types
 
template<>
bool set (const char *name, const float &val)
 getter and setter instanciations for supported types
 
template<>
optional< const char * > get (const char *name) const
 getter and setter instanciations for supported types
 
template<>
bool set (const char *name, const char *const &val)
 getter and setter instanciations for supported types
 
template<>
optional< listget (const char *name) const
 getter and setter instanciations for supported types
 
template<>
bool set (const char *name, const list &val)
 getter and setter instanciations for supported types
 

Detailed Description

Represents a global store to be shared amongst ink runners.

Stores global variable values, visit counts, turn counts, etc.

Member Function Documentation

◆ create_snapshot()

virtual snapshot * ink::runtime::globals_interface::create_snapshot ( ) const
pure virtual

create a snapshot of the current runtime state.

(inclusive all runners assoziated with this globals)

◆ get()

template<typename T >
optional< T > ink::runtime::globals_interface::get ( const char * name) const
inline

Access global variable of Ink runner.

Parameters
namename of variable, as defined in InkScript
Template Parameters
Tc++ type of variable
Returns
nullopt if variable won't exist or type won't match

◆ observe()

template<typename F >
void ink::runtime::globals_interface::observe ( const char * name,
F callback )
inline

Observers global variable.

Calls callback with value or with casted value if it is one of values variants. The callback will also be called with the current value when the observe is bind.

Parameters
nameof variable to observe
callbackfunctor with:
  • 0 arguments
  • 1 argument: new_value
  • 2 arguments: new_value, ink::optional<old_value>: first time call will not contain a old_value

◆ set()

template<typename T >
bool ink::runtime::globals_interface::set ( const char * name,
const T & val )
inline

Write new value in global store.

Parameters
namename of variable, as defined in InkScript
val
Template Parameters
Tc++ type of variable
Return values
trueon success

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