D11815: Simplify the structure of the solver class:

Fabian Kosmale noreply at phabricator.kde.org
Fri Mar 30 18:58:58 UTC 2018


fabiank created this revision.
Restricted Application added a reviewer: KDE Games.
Restricted Application added a subscriber: KDE Games.
fabiank requested review of this revision.

REVISION SUMMARY
  - make firstMoves and winMoves private members and add getter for them
  - replace mutex protected bool with atomic bool
  - do not directly expose m_shouldEnd, but provide a stopExecution function
  - use in-class initialization of member variables
  - remove debug variable, and the DEBUG_HINTS define which controlled it, use #ifndef NDEBUG to print the debug messages for now
  - Solver: use a unique_ptr for the MemoryManager
  
  Introduce a smaller SolverInterface, hiding the complexity of Solver
  
  This change:
  
  - extract all the publically used Solver functionality into SolverInterface, which consists only of virtual functions
  - move solverinterface into its own header, to minimize includes
  - converts users which used Solver directly to SolverInterface
  
  Convert Solver into a template, templated over the number of piles
  
  The number of piles is known in each Solver subclass at compile time,
  thus a subclass with n piles does now inherit from Solver<n>.
  
  m_number_piles and its setter become redundant with this change, and are
  removed
  
  This enable the conversion of member variables which were
  dynamically allocated arrays into std::arrays, increasing type safety
  and causing an abort/exception on out-of-boundary access. Furthermore,
  the compiler can now better reason about some of the loops (though this
  doesn't really matter performance wise)

TEST PLAN
  Everything still compiles, and the Solver can still solve each game

REPOSITORY
  R410 KPatience

BRANCH
  solver_iface

REVISION DETAIL
  https://phabricator.kde.org/D11815

AFFECTED FILES
  dealer.cpp
  dealer.h
  gamestate.h
  main.cpp
  patsolve/clocksolver.cpp
  patsolve/clocksolver.h
  patsolve/fortyeightsolver.cpp
  patsolve/fortyeightsolver.h
  patsolve/freecellsolver.cpp
  patsolve/freecellsolver.h
  patsolve/golfsolver.cpp
  patsolve/golfsolver.h
  patsolve/grandfsolver.cpp
  patsolve/grandfsolver.h
  patsolve/gypsysolver.cpp
  patsolve/gypsysolver.h
  patsolve/idiotsolver.cpp
  patsolve/idiotsolver.h
  patsolve/klondikesolver.cpp
  patsolve/klondikesolver.h
  patsolve/mod3solver.cpp
  patsolve/mod3solver.h
  patsolve/patsolve.cpp
  patsolve/patsolve.h
  patsolve/simonsolver.cpp
  patsolve/simonsolver.h
  patsolve/solverinterface.h
  patsolve/spidersolver.cpp
  patsolve/spidersolver.h
  patsolve/yukonsolver.cpp
  patsolve/yukonsolver.h

To: fabiank, #kde_games
Cc: #kde_games
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-games-devel/attachments/20180330/14c35c3e/attachment.html>


More information about the kde-games-devel mailing list