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

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

07 Aug 2025 11:18AM UTC coverage: 69.816% (-14.2%) from 84.0%
#203

Pull #22

github

GiuliaNardicchia
refactor: reorganize actuator package structure and update imports for dynamic entities
Pull Request #22: feat: simulation engine

18 of 187 new or added lines in 14 files covered. (9.63%)

3 existing lines in 1 file now uncovered.

606 of 868 relevant lines covered (69.82%)

10.62 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.controller.Event
4
import io.github.srs.model.ModelModule
5
import monix.catnap.ConcurrentQueue
6
import monix.eval.Task
7

8
/**
9
 * Module that defines the view logic for the Scala Robotics Simulator.
10
 */
11
object ViewModule:
12

×
13
  /**
14
   * View trait that defines the interface for the view.
15
   *
16
   * @tparam S
17
   *   the type of the state, which must extend [[ModelModule.State]].
18
   */
19
  trait View[S <: ModelModule.State]:
NEW
20

×
21
    /**
22
     * Initializes the view with a queue for handling events.
23
     * @param queue
24
     *   the queue that will be used to handle events in the view.
25
     * @return
26
     *   the initialization task, which is a [[monix.eval.Task]] that completes when the initialization is done.
27
     */
28
    def init(queue: ConcurrentQueue[Task, Event]): Task[Unit]
29

30
    /**
31
     * Renders the view based on the current state.
32
     * @param state
33
     *   the current state of the simulation, which must extend [[ModelModule.State]].
34
     * @return
35
     *   the rendering task, which is a [[monix.eval.Task]] that completes when the rendering is done.
36
     */
37
    def render(state: S): Task[Unit]
38

39
  /**
40
   * Provider trait that defines the interface for providing a view.
41
   * @tparam S
42
   *   the type of the state, which must extend [[ModelModule.State]].
43
   */
44
  trait Provider[S <: ModelModule.State]:
45
    val view: View[S]
46

47
  /**
48
   * Defines the dependencies required by the view module. In particular, it requires a
49
   * [[io.github.srs.controller.ControllerModule.Provider]].
50
   */
51
  type Requirements[S <: ModelModule.State] = io.github.srs.controller.ControllerModule.Provider[S]
52

53
  /**
54
   * Component trait that defines the interface for creating a view.
55
   *
56
   * @tparam S
57
   *   the type of the simulation state, which must extend [[ModelModule.State]].
58
   */
59
  trait Component[S <: ModelModule.State]:
60
    context: Requirements[S] =>
×
61

62
    object View:
63
      /**
×
64
       * Creates a view instance.
65
       *
66
       * @return
67
       *   a [[View]] instance.
68
       */
69
      def apply(): View[S] = new ViewImpl
70

×
71
      /**
72
       * Private view implementation that uses a simple GUI.
73
       */
74
      private class ViewImpl extends View[S]:
75
        private val gui = new SimpleView[S]
×
76

×
77
        /**
78
         * @inheritdoc
79
         */
80
        override def init(queue: ConcurrentQueue[Task, Event]): Task[Unit] = gui.init(queue)
81

×
82
        /**
83
         * @inheritdoc
84
         */
85
        override def render(state: S): Task[Unit] = gui.render(state)
86

×
87
    end View
88

89
  end Component
90

91
  /**
92
   * Interface trait that combines the provider and component traits for the view module.
93
   * @tparam S
94
   *   the type of the state, which must extend [[ModelModule.State]].
95
   */
96
  trait Interface[S <: ModelModule.State] extends Provider[S] with Component[S]:
97
    self: Requirements[S] =>
98
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