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

Container for an InkCPP runtime snapshot. More...

#include <snapshot.h>

Public Member Functions

virtual const unsigned char * get_data () const =0
 access blob inside snapshot
 
virtual size_t get_data_len () const =0
 size of blob inside snapshot
 
virtual size_t num_runners () const =0
 number of runners which are stored inside this snapshot
 
virtual bool can_be_migrated () const =0
 if this snapshot can be migrated, if the story file changes (slightly).
 
void write_to_file (const char *filename) const
 serialize snapshot to file
 

Static Public Member Functions

static snapshotfrom_binary (const unsigned char *data, size_t length, bool freeOnDestroy=true)
 Construct snapshot from blob.
 
static snapshotfrom_file (const char *filename)
 deserialize snapshot from file.
 

Detailed Description

Container for an InkCPP runtime snapshot.

Each snapshot contains a globals store and all associated runners/threads For convinience there exist ink::runtime::globals_interface::create_snapshot() and runner_interface::create_snapshot() . If the runner is associated to the globals the snapshot will be identical. If multiple runners are associated to the same globals all will be contained, and cann be reconsrtucted with the id parameter of ink::runtime::story::new_runner_from_snapshot() A snapshot can be applied to an identical story file or an simulare if the snapshot is can_be_migrated(). A not migrated snapshot contiouse at exactly the place you are currently at.

A migrated one will "snap bag" to the last knot.

  • Global variables which (name) still exist will be transfared.
    • New ones will be initelized with its default value
    • Old ones will be droped
  • Temp variables which (name) still exist will be tranfared
    • new ones will be initelized with its default vaule (possible missing transformations)
    • old ones will be kept
    • attention declarations in Tunnels will be missed
  • Stack/Threads/Tunnels must not be used in the moment of the snapshot for it to be migratable.
    • best practice is to create hub knots which names do not change in the progress of the update and which do not have local variables. Then only store after you stepped inside this knot.
  • Lists definitions are matched after best knowladge
    • for each pair of old list value and new list value the best good matching is used
      • the similarty is calculated based on the jaro-winkler similiarty of the value names, and the normalized difference of the values
    • for each pair of old and new list (definition) the best good match is taken
      • the similiraty is calculated based on the jaccard similiraty of the contained flags, and the jaro-winkler similarty of the lists names
  • visit counts (e.g. used for once only choices)

    • existing ones (exact name match) are kept
      • !! a choice with no explicit label is tracked via its position in the list, reordering choices can therfore break your visit counts
    • new ones are zero
    • old ones are discarded
    Todo
    Currently the id is equal to the creation order, a way to name the single runner/threads is WIP

Member Function Documentation

◆ from_binary()

static snapshot * ink::runtime::snapshot::from_binary ( const unsigned char * data,
size_t length,
bool freeOnDestroy = true )
static

Construct snapshot from blob.

Memory must be kept valid until the snapshot is deconstructed.

Parameters
datapointer to blob
lengthnumber of bytes in blob
freeOnDestroyif the memory should be freed (delete[]) when the snapshot is deconstructed
Returns
newly created snapshot

◆ from_file()

static snapshot * ink::runtime::snapshot::from_file ( const char * filename)
static

deserialize snapshot from file.

Parameters
filenameof input file
Exceptions
ink_exceptionif it fails to open the file

◆ write_to_file()

void ink::runtime::snapshot::write_to_file ( const char * filename) const

serialize snapshot to file

Parameters
filenameoutput file filename, if already exist it will be overwritten
Exceptions
ink_exceptionif it fails to open the file

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