Skip to content
This repository has been archived by the owner on Sep 26, 2018. It is now read-only.

Logger Interface

Andrew Gresyk edited this page Jun 30, 2018 · 5 revisions

Logger Interface

It is often useful to see the history of state transitions and state method calls. One option for that would be by putting log statements in every method, which can be tedious and error prone.

HFSM also provides the interface for attachable logger, for a more convenient solution, removing the need to clutter user state code with the custom logging code:

// enable logger functionality
#define HFSM_ENABLE_STRUCTURE_REPORT

#include <hfsm/machine_single.hpp>

namespace hfsm {
struct LoggerInterface {
	enum class Method {
		Substitute,
		Enter,
		Update,
		Transition,
		React,
		Leave,
	};
	virtual void record(const char* state, const Method method) = 0;
};
} // namespace hfsm

Example code walkthrough

Source code: debug logger interface example

Documentation

Design

  • Core principles
  • Another FSM lib?
  • NoUML compliance
  • Proactive vs. reactive approach
  • Gamedev requirements
  • Alternatives

Basic features

  • Context and M:: 'namespace'
  • Basic state methods
  • Basic transitions
  • Roots and regions
  • Transitions within hierarchy
  • Active chain
  • Quering state activation status

Advanced features

  • Substitutions, aka State guards on steroids
  • State reuse with injections
  • Event handling

Debugging

  • Structure and activity report API
  • Assisted debugging with custom .natvis
  • Logger interface
Clone this wiki locally