Maze Builder Docs 8.10.23
Loading...
Searching...
No Matches
mazes::write_to_output_state Class Referenceabstract

Base state for creating output from mazes (pixels, stringify, OBJ) This state encapsulates the common setup, creation, and output-writing logic for states that generate maze output in various formats. The output argument is either a file path (the extension selects the format) or a bare keyword that prints to stdout: "stdout" (plain string), "obj" (Wavefront OBJ), "b64" (base64-encoded string). More...

#include <write_to_output_state.h>

Inheritance diagram for mazes::write_to_output_state:
[legend]
Collaboration diagram for mazes::write_to_output_state:
[legend]

Public Member Functions

 write_to_output_state (const runtime_app::context &ctx, runtime_stack *stack)
 Construct a new write to output state.
bool update (randomizer &rng, double delta_time) noexcept override final
 Update the state with the given arguments and delta time Common logic for parsing arguments, creating output, and writing to file.
void draw () const noexcept override
Public Member Functions inherited from mazes::state
 state (const runtime_app::context &c, runtime_stack *rs)

Protected Member Functions

configurator make_config (const args &a) noexcept
 Builds the configuration for create(), sizing it to the current grid.
virtual bool write_output (const std::string &output_target, const std::string &output_content) noexcept=0
 Write the output to the target destination Subclasses should override this to handle format-specific writing.
Protected Member Functions inherited from mazes::state
void request_stack_push (ID state_id) const noexcept
void request_stack_pop () const noexcept
void request_stack_clear () const noexcept
const runtime_app::context & get_context () const noexcept
runtime_stack & get_stack () const noexcept

Protected Attributes

args_manager * args_mapper
grid_manager * grid_mapper
processed_text_manager * processed_text_mapper
grid_identifier current_grid_id
std::string m_result

Additional Inherited Members

Public Types inherited from mazes::state
enum class  ID : unsigned int {
  EMPTY = 0 , LINK_WITH_BINARY_TREE = 1 , LINK_WITH_DFS = 2 , LINK_WITH_SIDEWINDER = 3 ,
  LINK_WITH_PRIMS = 4 , LOAD = 5 , PARSE = 6 , WRITE_TO_IMAGE = 7 ,
  WRITE_TO_STRING = 8 , WRITE_TO_WF_OBJ = 9 , LINK_WITH_MASKED = 10 , TOTAL = 11
}

Detailed Description

Base state for creating output from mazes (pixels, stringify, OBJ) This state encapsulates the common setup, creation, and output-writing logic for states that generate maze output in various formats. The output argument is either a file path (the extension selects the format) or a bare keyword that prints to stdout: "stdout" (plain string), "obj" (Wavefront OBJ), "b64" (base64-encoded string).

Constructor & Destructor Documentation

◆ write_to_output_state()

mazes::write_to_output_state::write_to_output_state ( const runtime_app::context & ctx,
runtime_stack * stack )
explicit

Construct a new write to output state.

Parameters
ctxThe runtime context
stackThe runtime stack to allow pushing/popping states

Member Function Documentation

◆ draw()

void mazes::write_to_output_state::draw ( ) const
overridevirtualnoexcept

Implements mazes::state.

◆ make_config()

configurator mazes::write_to_output_state::make_config ( const args & a)
nodiscardprotectednoexcept

Builds the configuration for create(), sizing it to the current grid.

Also selects current_grid_id from the distances argument

◆ update()

bool mazes::write_to_output_state::update ( randomizer & rng,
double delta_time )
finaloverridevirtualnoexcept

Update the state with the given arguments and delta time Common logic for parsing arguments, creating output, and writing to file.

Parameters
rngThe randomizer for the algorithm
delta_timeTime elapsed since the last update
Returns
False to indicate the state has completed (pops itself from the stack)

Implements mazes::state.

◆ write_output()

virtual bool mazes::write_to_output_state::write_output ( const std::string & output_target,
const std::string & output_content )
nodiscardprotectedpure virtualnoexcept

Write the output to the target destination Subclasses should override this to handle format-specific writing.

Parameters
output_targetThe target file path; never called for stdout keywords
output_contentThe content to write
Returns
True if write was successful, false otherwise

Implemented in mazes::pixels_create_state, mazes::stringify_create_state, and mazes::wavefront_object_create_state.


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