• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Scala-Robotics-Simulator / PPS-22-srs / #103

26 Jul 2025 09:04AM UTC coverage: 65.217% (-2.7%) from 67.873%
#103

Pull #16

github

GiuliaNardicchia
refactor: add missing end marker for Component in ModelModule
Pull Request #16: feat: mvc with generic state and simulation loop

0 of 31 new or added lines in 6 files covered. (0.0%)

9 existing lines in 5 files now uncovered.

150 of 230 relevant lines covered (65.22%)

8.78 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/main/scala/io/github/srs/view/ViewModule.scala
1
package io.github.srs.view
2

3
import io.github.srs.model.ModelModule
4

5
/**
6
 * Module that defines the view logic for the Scala Robotics Simulator.
7
 */
8
object ViewModule:
9

×
10
  /**
11
   * View trait that defines the interface for the view.
12
   *
13
   * @tparam S
14
   *   the type of the state, which must extend [[ModelModule.State]].
15
   */
16
  trait View[S <: ModelModule.State]:
NEW
17
    /**
×
18
     * Initializes the view.
19
     */
20
    def init(): Unit
21

22
    /**
23
     * Renders the view based on the current state.
24
     *
25
     * @param state
26
     *   the current state of the simulation.
27
     */
28
    def render(state: S): Unit
29

30
  /**
31
   * Provider trait that defines the interface for providing a view.
32
   * @tparam S
33
   *   the type of the state, which must extend [[ModelModule.State]].
34
   */
35
  trait Provider[S <: ModelModule.State]:
36
    val view: View[S]
37

38
  /**
39
   * Defines the dependencies required by the view module. In particular, it requires a
40
   * [[io.github.srs.controller.ControllerModule.Provider]].
41
   */
42
  type Requirements[S <: ModelModule.State] = io.github.srs.controller.ControllerModule.Provider[S]
43

44
  /**
45
   * Component trait that defines the interface for creating a view.
46
   *
47
   * @tparam S
48
   *   the type of the simulation state, which must extend [[ModelModule.State]].
49
   */
50
  trait Component[S <: ModelModule.State]:
NEW
51
    context: Requirements[S] =>
×
52

53
    object View:
NEW
54
      /**
×
55
       * Creates a view instance.
56
       *
57
       * @return
58
       *   a [[View]] instance.
59
       */
60
      def apply(): View[S] = new ViewImpl
NEW
61

×
62
      /**
63
       * Private view implementation that uses a simple GUI.
64
       */
65
      private class ViewImpl extends View[S]:
NEW
66
        private val gui = new SimpleView[S]
×
NEW
67

×
68
        /**
69
         * Initializes the GUI.
70
         */
71
        override def init(): Unit = gui.init()
NEW
72

×
73
        /**
74
         * Renders the GUI based on the current state.
75
         *
76
         * @param state
77
         *   the current state of the simulation.
78
         */
79
        override def render(state: S): Unit = gui.render(state)
UNCOV
80

×
81
    end View
82

83
  end Component
84

85
  /**
86
   * Interface trait that combines the provider and component traits for the view module.
87
   * @tparam S
88
   *   the type of the state, which must extend [[ModelModule.State]].
89
   */
90
  trait Interface[S <: ModelModule.State] extends Provider[S] with Component[S]:
91
    self: Requirements[S] =>
92
end ViewModule
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc