wiRedPanda
Logic Circuit Simulator
Loading...
Searching...
No Matches
StepEngineCore< StepType > Class Template Reference

Owns the id/title/step-list/progress state machine shared by ExerciseEngine and TourEngine, and the JSON resource-loading logic that builds it. More...

#include <StepEngineCore.h>

Classes

struct  AdvanceResult
 Result of advance(): tells the owning engine what to emit next. More...
struct  Persistence
 The four Settings::* functions each engine persists progress/completion through. More...

Public Types

using FillStep = void (*)(const QString &id, const QJsonObject &stepObj, StepType &step)

Public Member Functions

AdvanceResult advance ()
int currentStep () const
const StepType & currentStepData () const
bool goToPreviousStep ()
QString id () const
bool isActive () const
bool loadFromResource (const QString &resourcePath)
void markCompleted ()
bool retranslate ()
bool start ()
 StepEngineCore (FillStep fillStep, Persistence persistence)
bool stop ()
QString title () const
int totalSteps () const

Detailed Description

template<typename StepType>
class StepEngineCore< StepType >

Owns the id/title/step-list/progress state machine shared by ExerciseEngine and TourEngine, and the JSON resource-loading logic that builds it.

Not a QObject: Qt's moc cannot process a templated QObject that declares signals, so ExerciseEngine/TourEngine each own a StepEngineCore<StepType> member and translate its return values into their own class-specific emit calls (different stepChanged payload types, and ExerciseEngine's extra stepCompleted signal / Scene-validation subsystem, which this core knows nothing about). StepType is ExerciseStep or TourStep; fillStep and persistence are supplied once at construction (see each engine's constructor) since they're fixed per concrete engine type, not per call.

Definition at line 34 of file StepEngineCore.h.

Member Typedef Documentation

◆ FillStep

template<typename StepType>
using StepEngineCore< StepType >::FillStep = void (*)(const QString &id, const QJsonObject &stepObj, StepType &step)

Fills step's type-specific fields from stepObj (one entry of the JSON "steps" array); id is the resource's id, for building translation catalog keys.

Definition at line 39 of file StepEngineCore.h.

Constructor & Destructor Documentation

◆ StepEngineCore()

template<typename StepType>
StepEngineCore< StepType >::StepEngineCore ( FillStep fillStep,
Persistence persistence )
inline

Definition at line 56 of file StepEngineCore.h.

Member Function Documentation

◆ advance()

template<typename StepType>
AdvanceResult StepEngineCore< StepType >::advance ( )
inline

Advances one step, persisting the new position; see AdvanceResult for how the caller should react.

Definition at line 148 of file StepEngineCore.h.

◆ currentStep()

template<typename StepType>
int StepEngineCore< StepType >::currentStep ( ) const
inline

Definition at line 206 of file StepEngineCore.h.

◆ currentStepData()

template<typename StepType>
const StepType & StepEngineCore< StepType >::currentStepData ( ) const
inline

Definition at line 195 of file StepEngineCore.h.

◆ goToPreviousStep()

template<typename StepType>
bool StepEngineCore< StepType >::goToPreviousStep ( )
inline

Steps back one, persisting the new position. Returns true if it moved (caller should emit its stepChanged-equivalent signal).

Definition at line 136 of file StepEngineCore.h.

◆ id()

template<typename StepType>
QString StepEngineCore< StepType >::id ( ) const
inline

Definition at line 204 of file StepEngineCore.h.

◆ isActive()

template<typename StepType>
bool StepEngineCore< StepType >::isActive ( ) const
inline

Definition at line 208 of file StepEngineCore.h.

◆ loadFromResource()

template<typename StepType>
bool StepEngineCore< StepType >::loadFromResource ( const QString & resourcePath)
inline

Loads resourcePath (a Qt resource path) and rebuilds id/title/step list from it. Resets active/current-step state; the caller decides whether to (re)activate.

Definition at line 64 of file StepEngineCore.h.

References ExerciseTourResources::translate().

Referenced by retranslate().

◆ markCompleted()

template<typename StepType>
void StepEngineCore< StepType >::markCompleted ( )
inline

Deactivates, records completion, and resets persisted progress. Caller still owns any Scene disconnection and its own completed signal.

Definition at line 183 of file StepEngineCore.h.

◆ retranslate()

template<typename StepType>
bool StepEngineCore< StepType >::retranslate ( )
inline

Reloads the current resource (picking up any language change) while preserving the current step position and active state. No-op if never loaded or inactive. Returns true if it retranslated (caller should emit its retranslated signal).

Definition at line 165 of file StepEngineCore.h.

References loadFromResource().

◆ start()

template<typename StepType>
bool StepEngineCore< StepType >::start ( )
inline

Activates the engine at its persisted progress (clamped to a valid step). No-op if there are no steps. Returns true if activation happened (caller should emit its stepChanged-equivalent signal).

Definition at line 110 of file StepEngineCore.h.

◆ stop()

template<typename StepType>
bool StepEngineCore< StepType >::stop ( )
inline

Deactivates the engine. Returns true if it was active (caller should emit its stopped signal); false if it was already inactive.

Definition at line 125 of file StepEngineCore.h.

◆ title()

template<typename StepType>
QString StepEngineCore< StepType >::title ( ) const
inline

Definition at line 205 of file StepEngineCore.h.

◆ totalSteps()

template<typename StepType>
int StepEngineCore< StepType >::totalSteps ( ) const
inline

Definition at line 207 of file StepEngineCore.h.


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