TT Client Library 1.0.0
C++ library for Tandem Tales clients.
Loading...
Searching...
No Matches
tt::State Class Reference

A state is an assignment of values to each variable in a story world. More...

#include <tt/world/State.h>

Public Member Functions

std::string toString () const
 Returns a string representation of this object.
const std::string & getDescription () const
 Returns a human-readable natural language description of the object.
const std::string & getCode () const
 Returns a string of 1's and 0's that uniquely represents this object among other objects of the same type in the same story world.
const std::vector< const Assignment * > & getAssignments () const
 Returns an unmodifiable list of assignments of a value to each variable in the state.
const Value * get (const Variable *variable) const
 Returns the value assigned to the given variable, or nullptr if the variable does not exist in this state or is assigned a null value.

Friends

std::ostream & operator<< (std::ostream &os, const State &a)
 Override stream insertion operator to allow printing the State class.

Detailed Description

A state is an assignment of values to each variable in a story world.

Author
Gage Birchmeier

Member Function Documentation

◆ get()

const Value * tt::State::get ( const Variable * variable) const

Returns the value assigned to the given variable, or nullptr if the variable does not exist in this state or is assigned a null value.

Parameters
variablea variable whose assigned value is desired
Returns
the value assigned to the given variable in this state

◆ getAssignments()

const std::vector< const Assignment * > & tt::State::getAssignments ( ) const

Returns an unmodifiable list of assignments of a value to each variable in the state.

Returns
an unmodifiable list of variable assignments

◆ getCode()

const std::string & tt::State::getCode ( ) const

Returns a string of 1's and 0's that uniquely represents this object among other objects of the same type in the same story world.

Every encoded object of the same type should return a string of the same length, even if it must be padded with 0's.

Returns
a string of 1's and 0's

◆ getDescription()

const std::string & tt::State::getDescription ( ) const

Returns a human-readable natural language description of the object.

Returns
a human-readable natural language description of the object

◆ toString()

std::string tt::State::toString ( ) const

Returns a string representation of this object.

Returns
a string describing this object

◆ operator<<

std::ostream & operator<< ( std::ostream & os,
const State & a )
friend

Override stream insertion operator to allow printing the State class.

Parameters
osan output stream to insert into
aa reference to a state object
Returns
the output stream referenced

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